Letting player show or hide quick menu in preferences. [Solved]

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
sheetcakeghost
Veteran
Posts: 383
Joined: Sat Sep 19, 2009 9:19 pm
Contact:

Letting player show or hide quick menu in preferences. [Solved]

#1 Post by sheetcakeghost »

So I'm having trouble making this code work as needed.

Code: Select all

vbox:
                    style_prefix "check"
                    label _("Quick Menu")
                    textbutton _("Show") action Show("quick_menu")
                    textbutton _("Hide") action Hide("quick_menu")
From how I understand renpy (which is not very much) putting those options in should allow the player to click on either show or hide to do just that, show or hide. However it is not doing this at all. Clicking them, as far as I can tell, performs no function. In fact, when I put those options in it just hides the quick menu and never shows it.

To fix that I had to add "default show_quick_menu = True" at the beginning of my script which does show the quick menu, but then it never hides without me using "$ quick_menu = False" which is, I imagine, working as intended with "default show".

I have tried another method which also does not work for me.

Code: Select all

vbox:
                    style_prefix "check"
                    label _("Quick Menu")
                    textbutton _("Show") action Show("quickmenushow")
                    textbutton _("Hide") action Show("quickmenuhide")
Where I made custom screens which contained only one line.

Code: Select all

screen quickmenushow:
    $ quick_menu = True

screen quickmenuhide:
    $ quick_menu = False
I also tried the "show_quick_menu = Blah" variant of the code from the older renpy.

Now, this thread viewtopic.php?t=26263 talks about what I want to do, but "make it 2 buttons inside a screen with a conditional branch" confuses me a bit. I think that's what I was doing with my second failed solution? But I'm not sure.

If someone could help me out I would appreciate it. I'm sure this is a very simple thing to do, but my google-fu really failed me on finding out how to do it.

Edit: Also, yes, my quick menu does have the "if quick_menu" statement which is why I thought the Show Hide buttons would work in the first place.
Last edited by sheetcakeghost on Sat Mar 30, 2019 6:00 pm, edited 1 time in total.

User avatar
xavimat
Eileen-Class Veteran
Posts: 1461
Joined: Sat Feb 25, 2012 8:45 pm
Completed: Yeshua, Jesus Life, Cops&Robbers
Projects: Fear&Love
Organization: Pilgrim Creations
Github: xavi-mat
itch: pilgrimcreations
Location: Spain
Discord: xavimat
Contact:

Re: Letting player show or hide quick menu in preferences.

#2 Post by xavimat »

Renpy already has a variable to control if the quickmenu is visible or not. It's called "quick_menu" and is already "defaulted" in screens.rpy (line 271).
You only need to change that variable. You can toggle it with one button (style check) or use two buttons: On/Off (style radio)

Code: Select all

vbox:
    style_prefix "check"
    label _("Quick Menu")
    textbutton _("Show Quick Menu") action ToggleVariable("quick_menu", True, False)

Code: Select all

vbox:
    style_prefix "radio"
    label _("Quick Menu")
    textbutton _("Show") action SetVariable("quick_menu", True)
    textbutton _("Hide") action SetVariable("quick_menu", False)

Two comments to your code:
1.Show() and Hide() are used to actually show or hide a screen, in your case, putting these options in the preferences had no meaning.
2. Screens shouldn't have side effects (like assigning values to global variables) because they are predicted many times and those codes are executed on prediction.
Comunidad Ren'Py en español: ¡Únete a nuestro Discord!
Rhaier Kingdom A Ren'Py Multiplayer Adventure Visual Novel.
Cops&Robbers A two-player experiment | Fear&Love Why can't we say I love you?
Honest Critique (Avatar made with Chibi Maker by ~gen8)

User avatar
sheetcakeghost
Veteran
Posts: 383
Joined: Sat Sep 19, 2009 9:19 pm
Contact:

Re: Letting player show or hide quick menu in preferences.

#3 Post by sheetcakeghost »

Oh! Thank you for giving me two options to pick from with one button or two. That'll be very nice for anyone else who finds my topic looking for a similar solution.

The second one was exactly what I was hoping to achieve, and thank you for the explanation too. I have a better understanding of the Show and Hide command now. I also didn't even consider looking for a quickmenu = true variable in the screen.rpy file itself, and I should have. d: That's on me.

Post Reply

Who is online

Users browsing this forum: Majestic-12 [Bot], piinkpuddiin, Semrush [Bot], snotwurm