I feel like I've tried everything to get this working and it just wont run... I'm also still learning python, my class for it started the start of fall a few months ago.
Long story short, I'm making a text-based "escape the room" game in Python. The player chooses objects to interact with, and the results gives them items to use until they find the key to unlock the door. It's quite short and linear, to save my sanity.
I think this is the part of my code that isn't running, which is in a big function that contains similar code for all 4 objects (sorry if its a little long.
This is all basically, "While they choose the painting, describe it, as them if they want to search it, (1=yes, 2=no).
If they do, describe the search result. Because this is the last object for the story (safe behind painting has the door key), Once the safe is opened and they have the key, I don't want it to ask them the main question again, but it does!?
main question that is repeated is;
def main_choice_input():
main_choice = input("""
What would you like to check out? (1=Bed, 2=Desk, 3=Dresser, 4=Painting): """)
return main_choice;
#code for describing the objects, the inputs for the player to search them
#and the search results, if tried to name them as self-explanatory as
#possible
previous whiles are for the other objects, this is all in one big function.
while main_choice == "4":
painting_description()
#painting_input is the "search this?" question
painting_input = painting_interaction()
if painting_input =="1":
painting_search(painting_input,dresser_input)
if use_key=="1" and painting_input =="1":
#If they 'used the key' on the desk to get the code:
painting_search(painting_input,dresser_input)
unlock = input("""
Would you like to unlock the safe? [1=Yes/2=No]: """)
if unlock == "1":
#print (story for opening the safe)
safe=1 #for ending the game- checking if the safe is open
if unlock == "2":
print("""
That's too bad, let's try again...""")
main_choice = main_choice_input()
main_route(main_choice,bed_input,desk_input,dresser_input,
painting_input,use_key,)
if painting_input =="2":
print("""
The code must be around here somewhere... Let's keep looking!
""")
#main_route is the name of this whole function
main_choice = main_choice_input()
main_route(main_choice,bed_input,desk_input,
dresser_input,painting_input,use_key,)
#I had it re-ask and re-run here too, so if they dont have the code/choose not to search or whatever, they can go back and get it
break
while main_choice != "1" or main_choice != "2" or main_choice != "3" or
main_choice != "4":
main_choice = main_choice_input()
main_route(main_choice,bed_input,desk_input,dresser_input,painting_input,use_key,)
return;
My problem is that this program doesn't even run the unlock = input function, it plays the search description and then asks the main "what would you like to check out" question like this;
Take a look? [1=Yes/2=No]
1
You walk up and inspect the painting as if it were displayed in a museum.
It's clearly just a copy of the painting, not even trying to be the real thing.
You begin to notice that the painting is hanging a couple inches off the wall...
You grab the painting on either side of the frame, and gently place it on
the floor, revealing a safe built into the wall!
What would you like to check out? (1=Bed, 2=Desk, 3=Dresser, 4=Painting):
instead of that last question, it should have asked if I wanted to open the safe, since I got the code, but it doesn't? why? Please help, I'm so lost and frustrated.
Aucun commentaire:
Enregistrer un commentaire