Complex menu

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
User avatar
Roselia-Thorns
Regular
Posts: 27
Joined: Tue Sep 13, 2016 10:01 pm
Projects: Undertale: Kissy Cutie
Tumblr: roseradetea
itch: roseradetea
Contact:

Complex menu

#1 Post by Roselia-Thorns »

So I'm trying to make a multiple choice menu when the player has to decide which path to take.
Each answer of this menu is supposed to take you to a short scene when you talk to the character. In that scene you are going to decide yes/no to date him. If you say yes you continue to that path. If no you came back to this menu, but is suppose to hide the character you already spoke to. If you say no to dating all the characters, it should take you to a hidden path. I really don't know how to make it work. I'm very very noob.

Code: Select all

label dates_menu:
menu:
    "Papyrus" if (sans_choice == False) and (und_choice == False):
       "(Let's see how Papyrus is doing)" 
       $ pap_choice = True
       jump pap_date
     

    "Sans" if (pap_choice == False) and (und_choice == False):
       "(I wonder if Sans is ok)"
       $ sans_choice = True
       jump sans_date
    
    "Undyne." if (sans_choice == False) and (pap_choice == False):
       "(Maybe we should visit Undyne)" 
       $ und_choice = True
       jump und_date
       
    "All" if if (sans_choice == False) and (pap_choice == False) and (und_choice == False):
        "(Let's visit them all)"
        jump all_date
       

philat
Eileen-Class Veteran
Posts: 1912
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: Complex menu

#2 Post by philat »

Something like this, basically.

Code: Select all

default character1_seen = False
default character2_seen = False

label dates_menu:
    menu:
    
        "Character 1" if not character1_seen:
            "Saw character 1"
            character1_seen = True
            jump dates_menu
    
        "Character 2" if not character2_seen:
            "Saw character 2"
            character2_seen = True
            jump dates_menu

        "Saw both" if character2_seen and character1_seen:
            "Hidden until both seen"
            jump dates_menu

User avatar
Roselia-Thorns
Regular
Posts: 27
Joined: Tue Sep 13, 2016 10:01 pm
Projects: Undertale: Kissy Cutie
Tumblr: roseradetea
itch: roseradetea
Contact:

Re: Complex menu

#3 Post by Roselia-Thorns »

Yes! It worked! Thank you so much!

User avatar
Roselia-Thorns
Regular
Posts: 27
Joined: Tue Sep 13, 2016 10:01 pm
Projects: Undertale: Kissy Cutie
Tumblr: roseradetea
itch: roseradetea
Contact:

Re: Complex menu

#4 Post by Roselia-Thorns »

The code works just fine, except when you save before the decision. I don't know why that happens, but if you load a game you get this error

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/script.rpy", line 1871, in script
    menu:
  File "game/script.rpy", line 1872, in <module>
    "Papyrus" if not papyrus_seen:
NameError: name 'papyrus_seen' is not defined

-- Full Traceback ------------------------------------------------------------

Full traceback:
  File "game/script.rpy", line 1871, in script
    menu:
  File "C:\Users\cabal_000\Desktop\renpy\renpy\ast.py", line 1459, in execute
    choice = renpy.exports.menu(choices, self.set)
  File "C:\Users\cabal_000\Desktop\renpy\renpy\exports.py", line 823, in menu
    if renpy.python.py_eval(condition) ]
  File "C:\Users\cabal_000\Desktop\renpy\renpy\python.py", line 1725, in py_eval
    return py_eval_bytecode(code, globals, locals)
  File "C:\Users\cabal_000\Desktop\renpy\renpy\python.py", line 1719, in py_eval_bytecode
    return eval(bytecode, globals, locals)
  File "game/script.rpy", line 1872, in <module>
    "Papyrus" if not papyrus_seen:
NameError: name 'papyrus_seen' is not defined

Windows-8-6.2.9200
Ren'Py 6.99.12.2.2029
UT: Kissy Cutie 1.3

This doesn't happen if you play the game since the beggining. Or if you use the code in an empty file, it works just fine.

My code is this

Code: Select all

default papyrus_seen = False
default sans_seen = False
default undyne_seen = False

label dates_menu:
"(Who do you want to visit?)"
menu:
    "Papyrus" if not papyrus_seen:
            "(Let's visit Papyrus)"
            $ papyrus_seen = True
            jump papyrus_yesno
    "Sans" if not sans_seen:
            "(I wonder how San's is doing)"
            $ sans_seen = True
            jump sans_yesno
            
    "Undyne" if not undyne_seen:
            "(Are you worried about Undyne?)"
            $ undyne_seen = True
            jump undyne_yesno

    "Visit All!" if sans_seen and undyne_seen and papyrus_seen:
            "(Well what do you want to do then?)"
            jump true_path

Post Reply

Who is online

Users browsing this forum: Ocelot