This is a bit of code from my text based game:
location_now = ""
class what_do:
def whaat(self):
interactions = what_do()
print "*What will you do? Type help_ to see all the actions*"
what = raw_input("")
if what == "help_":
print ' '.join(help_)
interactions.whaat()
if what == "travel":
print "These are all the cities you can travel to:"
mapje.map()
travel = raw_input("To which city do you want to travel?(Takes 10 seconds)")
if travel == locations[0] or travel == locations[1] or travel == locations[2] or travel == locations[3] or travel == locations[4] or travel == locations[5] or travel == locations[6] or travel == locations[7] or travel == locations[8]:
print "You are now travelling to %s" % travel
time.sleep(10)
print "You are now in %s!" % travel
location_now = travel
else:
print "That is no location in Skyrim!"
interactions.whaat()
I want the input from travel = raw_input
etc. to be stored and saved in the variable location_now
(That I created before and outside the class). I have to use that input later in my code.
This class will be repeated because it is a sort of 'What would you like to do next?', so if the input from the second time, what = raw_input("")
, is asked, it must replace the earlier input stored in location_now = ""