trying to make a text adventure here. I was setting up the actions module, and testing out the movements when the code keeps telling me my functions are not defined even though I defined them in the code itself (wouldn't recognize it in the player module) I am stuck, any ideas?
Error:
go_north(self)
NameError: name 'go_north' is not defined
Code:
def go(self, dx, dy):
self.location_x += dx
self.location_y += dy
print(world.tile_exists(self.location_x, self.location_y).intro_text())
def go_north(self):
self.go(dx=0, dy=-1)
def go_south(self):
self.go(dx=0, dy=1)
def go_east(self):
self.go(dx=1, dy=0)
def go_west(self):
self.go(dx=-1, dy=0)
game = "play"
while game == "play":
x = input()
y = " is not a valid command"
string = x + y
if x == "go north":
go_north(self)
if x == "go south":
go_south(self)
if x == "go east":
go_east(self)
if x == "go west":
go_west(self)
else:
print(string)
Try
self.go_north()instead ofgo_north(self)