Reputation: 13
I'm creating a test 'text adventure' game, and code is run based on the input() text, but when I try out the code and type in text for the input variable it doesn't run until I have tried a couple of times.
I've tried moving the location of the input() but it does the same thing.
def Inputs():
while True:
global Hour
global Wait
if input() == 'search' and Wait == False:
for x in range(1):
print('You got +',random.randint(0,5), 'food and +', random.randint(0,5), 'water')
Hour = Hour + 1
Wait = True
t.start
if input() == 'search' and Wait == True:
print('You decide to wait before looking again.')
if input() == 'search' and Wait == True:
print('You decide to wait before looking again.')
if input() == 'light' and Day == True:
print('You light a fire.')
if input() == 'light' and Day == False:
print('You cannot light a fire, it\'s day.')
if input() == 'info':
print(Info())
if input() == 'craft':
print('Test Text (Finish)')
if input() == 'help':
print(Instructions)
It should display 'You light a fire.'
Upvotes: 1
Views: 36
Reputation: 333
Each time you call input() == XXX
the interpreter ask for a new input so the loop takes 8 inputs before looping back.
You should call input
once and store result in a variable.
Upvotes: 2