Is there anyway for this to happen?
At the moment, I am working on a little text adventure. I have also recently discovered the joy of functions, but they have one problem; they can't return a value for a global variable!
The following code is a test for a question system I am making for my text adventure game.
At the moment, I want my function to give a value for "answer".
inventory = [ "cat" , "gun" , "wallet" , "condom" ]
answer = 0
def questions(q,ansone,anstwo,ansoneres,anstwores,ansunknown):
questionloop = 0
while questionloop != 3:
ans = raw_input(q)
if ans == "inven":
print inventory
elif ans == ansone:
print ansoneres
questionloop = 3
answer = 1
elif ans == anstwo:
print anstwores
questionloop = 3
answer = 2
else:
print ansunknown
questions("Where is my cat?! :","dead","alive","NOOOOOOOO!","THANK GOD!","WTF?!")
if answer == 1:
print " answer equals 1, the story will continue with this path."
elif answer == 2:
print " answer equals 2, the story will continue with this path."
else:
print "no one is going to ever see this text. HAHAHAHAHA!"
And obviously, I always get the text no one will ever see.
Can anyone help me out here?