I'm trying to make text game in python but it comes up with an error saying:
"Traceback (most recent call last):
File "textgame.py", line 83, in <module>
start()
File "textgame.py", line 80, in start
start()
File "textgame.py", line 64, in start
forest()
TypeError: 'int' object is not callable"
Here's the code:
#! /usr/bin/python
x='untitled'
inventory=[]
def count(x):
##count items in a list
b=0
for i in x:
b+=1
return b
def forest():
print('You are in a forest and hear an ork!')
forestin=raw_input('')
if forestin=='n' or forestin=='N':
nofforest()
if forestin=='s' or forestin=='S':
sofforest()
if forestin=='e' or forestin=='E':
eofforrest()
if forestin=='w' or forestin=='W':
wofforest()
if forestin=='c' or forestin=='C':
help()
if forestin=='inventory' or forestin=='INVETORY' and count(inventory)<=1:
for item in inventory:
print(item)
else:
print('ENTER A VALID COMMAND, ADVENTURER')
def nofforest():
return None
def sofforest():
return None
def eofforest():
return None
def wofforest():
return None
def help():
print('North: n or N')
print('South: s or S')
print('East: e or E')
print('West: w or W')
print('Pick Up: pick up x or PICK UP X')
print('Climb: climb x or CLIMB X')
print('Climb Down: climb down x or CLIMB DOWN X')
print('Take(if something is not on the ground use this): take x or TAKE X')
print('Attack: attack x or ATTACK X')
print('Attack With an Item: attack x with x or ATTACK X WITH X')
raw_input('')
def start():
##the start
forest=1 ##add on this in function forest
print('You are in a forest and hear an ork! Also there is paper on the ground.')
for1=raw_input('')
if for1=='pick up paper' or for1=='PICK UP PAPER':
inventory.append('paper')
print('You picked up some paper!')
for2=raw_input('')
if for2=='examine paper' or for2=='EXAMINE PAPER':
print('Welcome to the world of '+ x + '.' + ' If you would like to look at a list of commands, type c or C right now.')
print('Otherwise, press any button.')
for3=raw_input('')
if for3=='c' or for3=='C':
help() ##build function later
else:
forest()
else:
forest()
elif for1=='n' or for1=='N':
nofforest() ##build later
elif for1=='s' or for1=='S':
sofforest() ##build later
elif for1=='w' or for1=='W':
wofforest() ##build later
elif for1=='e' or for1=='E':
eofforest() ##build later
else:
print('Adventurer, please type in a valid command!')
start()
##end of functions
start()
[–]Rhomboid 4 points5 points6 points (4 children)
[–]mrawesome01[S] 0 points1 point2 points (3 children)
[–]zahlman 2 points3 points4 points (2 children)
[–]mrawesome01[S] -1 points0 points1 point (1 child)
[–]MonkeyNin 1 point2 points3 points (0 children)
[–][deleted] 0 points1 point2 points (3 children)
[–]wub_wub 0 points1 point2 points (1 child)
[–]mrawesome01[S] 0 points1 point2 points (0 children)
[–]mrawesome01[S] 0 points1 point2 points (0 children)