Jan-19-2019, 09:55 PM
I just started learning Python this week and after doing a few simple scripts, I've started work on a simple text adventure, I'm trying to create different outcomes if the player does not enter the dungeon a certain amount of times, but I can't find a way to do this as setting the value of wait to 0 inside of game() makes it run multiple times (not letting the value change) and putting it outside doesn't give it a value at all. Any other generally better ways to code this would be helpful too, thanks!
import time import random def start(): print("You wake up in a hole") time.sleep(1) print("You grab a stick nearby and stand up") time.sleep(2) print("You are at the end of a long hallway made of some kind of stone bricks") time.sleep(3) print("All of the bricks are covered in moss and dust") time.sleep(2) print("It's to hard to see very far into the hallway") time.sleep(2) def game(): enter = str(input("Walk into the cave? [y/n]:\n")) if enter.lower() == ["yes","y"]: print("You walk into a room with a small, dusty chest infront of you") else: wait = wait + 1 if(wait<=5): print("You sit on the cold stone floor") time.sleep(1) game() elif(wait==6): print("Your stomach rumbles as you start to get hungry") time.sleep(2) game() elif(wait<=15): print("Your stomach rumbles as become even more hungry") time.sleep(2) game() start() game()