So it makes more sense, I will post all my code here:
**I know that it is messy, (maybe)inefficient, and the use of certain aspects is bad.**
import random
import time
import sys
import inspect
Answer1 = ["Push Walls", "PUSH WALLS", "push walls", "Push walls", "push Walls"] #Array of all possible answers.
Answer2 = ["Red Green Yellow", "Red, Green, Yellow", "red green yellow", "Red green yellow", "red Green yellow", "red green Yellow", "red, green, yellow",
"Red, green, yellow", "red, Green, yellow", "red, green, Yellow", "RED GREEN YELLOW", "RED, GREEN, YELLOW"] #Array of all possible answers.
Answer3 = ["Look Up", "look Up", "LOOK UP", "look up"] #Array of all possible answers.
lives = 3
a = 0 #
b = 0 #used to see if a room has already been picked. 0 is 'not picked' and 1 is 'is picked'
c = 0 #
#introduction
def intro():
env = """
"""
print(env)
time.sleep(0.5)
print("""
""")
time.sleep(0.5)
#main story
def main():
intro() #introduction
######
random.choice([room1,room2,room3])() #pick random room
def room1():
global currentFuncName
global a
global lives #making lives global so it can be accessed from outoflives()
a = 1
currentFuncName = current = inspect.stack()[0].function
#print(currentFuncName)
time.sleep(0.5)
print("""
""")
correct1 = input("")
if correct1 in Answer1:
print("")
else:
lives = 2
outoflives()
def room2():
global b
b = 1
print("")
def room3():
global c
c = 1
print("")
#called if you lose
def lose():
print("")
time.sleep(2)
main()
#called if you win
def win():
print("")
time.sleep(2)
main()
def outoflives():
global lives
while lives != 0:
time.sleep(0.3)
print("")
time.sleep(0.5)
print("", str(lives), "")
time.sleep(1)
print("")
currentFuncName()
break
while lives == 0:
print("")
lose()
break
def roompick():
if a == 1:
random.choice([room2,room3])()
elif b == 1:
random.choice([room1,room3])()
elif c == 1:
random.choice([room1,room2])()
main()
As a brief overview, a random room is picked. a / b / c is set to 1. If you lose a life you go to outoflifes(). Then it uses currentFuncName() to call the previous function you were just in - room1() for instance. IF you pass taht room roompick() is called. depending on what room is set to 1 means you wont get that room again.
Nevermind I got this to work after lots of experimenting!
import inspect #this a test
def main():
room1()
def room1():
global current
current = inspect.stack()[0].function
dead()
def dead():
print("dd")
eval(current + '()')
main()
I know eval() should be avoided at all times but I have no user inputs in that area of my code.
Thanks for all the help!