[SOLVED] Make menu items disappear after being clicked

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
Night130
Newbie
Posts: 13
Joined: Sun Apr 22, 2018 9:57 am
Contact:

[SOLVED] Make menu items disappear after being clicked

#1 Post by Night130 »

I'm trying to make choices from the the menu go away after being selected, so that when the menu comes up again, that choice you selected is now gone.
I keep getting this error:

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/script.rpy", line 279, in script
    if menuchoices == 3:
  File "game/script.rpy", line 279, in <module>
    if menuchoices == 3:
NameError: name 'menuchoices' is not defined

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

Full traceback:
  File "game/script.rpy", line 279, in script
    if menuchoices == 3:
  File "C:\Users\Anya\Desktop\renpy-6.99.14.3-sdk\renpy\ast.py", line 1729, in execute
    if renpy.python.py_eval(condition):
  File "C:\Users\Anya\Desktop\renpy-6.99.14.3-sdk\renpy\python.py", line 1919, in py_eval
    return py_eval_bytecode(code, globals, locals)
  File "C:\Users\Anya\Desktop\renpy-6.99.14.3-sdk\renpy\python.py", line 1912, in py_eval_bytecode
    return eval(bytecode, globals, locals)
  File "game/script.rpy", line 279, in <module>
    if menuchoices == 3:
NameError: name 'menuchoices' is not defined

Windows-8-6.2.9200
Ren'Py 6.99.14.3.3347
 1.0
Sat May 26 17:59:47 2018
This is the code I have right now:

Code: Select all

label start:
$ menuchoices = 0
$ foutain = False
$ dance = False
$ benches = False

Code: Select all

label partychoices:
    
    if menuchoices == 3:
        jump snackbar

    else:
        menu:
            "Look at the fountain" if fountain == False:
                jump fountain

            "Sit on the benches" if benches == False:
                jump benches

            "Go dance" if dance == False:
                jump dance
    

label fountain:
    $ fountain = True
    $ menuchoices += 1
"something happend"
jump partychoices

label benches:
    $ benches = True
    $ menuchoices += 1
"something happend"
jump partychoices

label dance:
    $ dance = True
    $ menuchoices += 1
"something happend"
jump partychoices

label snackbar:
    "Something happened"

Last edited by Night130 on Sun May 27, 2018 9:46 am, edited 1 time in total.

User avatar
Remix
Eileen-Class Veteran
Posts: 1628
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I'm still looking for an artist)
Projects: An un-named anime based trainer game
Contact:

Re: Make menu items disappear after being clicked

#2 Post by Remix »

Code: Select all


default chosen_menu_choices = []

label start:

    menu:

        set chosen_menu_choices

        "Lots of choices"

        "Choice 1":
            jump start

        "Choice 2":
            jump start

        "Choice 3":
            jump start

        "Choice 4":
            jump start

        "Choice 5":
            jump start

    "Onto next"

    menu:

        set chosen_menu_choices

        "Lots of choices"

        ### note this one is missing as it uses same caption as above
        ### we could use a different set variable or just clean it after last one
        "Choice 5":
            jump start

        "Choice 6":
            jump start
Frameworks & Scriptlets:

Night130
Newbie
Posts: 13
Joined: Sun Apr 22, 2018 9:57 am
Contact:

Re: Make menu items disappear after being clicked

#3 Post by Night130 »

Thank you so much! It worked!

Post Reply

Who is online

Users browsing this forum: Bing [Bot]