Ren'Py Rebel Quick Menu

iOtero

Active Member
Aug 4, 2020
925
1,459
Hello, here I come back with another little problem.

In the game I am developing I want a photo book to appear.

In principle, until there is no photo in the game, I want that the option to call the photo album is neither in the main menu nor in the quick menu.

For this I have defined the variable "show_photos".

In gui.rpy I have defined the variable:

Code:
define show_photos = False
In screens.rpy in main menu I have added the option like this:

Code:
...
        textbutton _("Load") action ShowMenu("load")

        textbutton _("Options") action ShowMenu("preferences")

        if show_photos:

            textbutton _("Photo Book") action ShowMenu("album_fotos")

        if _in_replay:

            textbutton _("En Replay") action EndReplay(confirm=True)
...
And in Quick menu I have put this (the quick menu is graphic):

Code:
...
        imagebutton:
            idle "gui/textbox/Hide.png"
            hover "gui/textbox/HideHover.png"
            action HideInterface()
            tooltip "Hide UI."

        if show_photos:

            imagebutton:
                idle "gui/textbox/Album.png"
                hover "gui/textbox/AlbumHover.png"
                action ShowMenu('photo_book)
                tooltip "Photo Book."

        imagebutton:
            idle "gui/textbox/Quit.png"
            hover "gui/textbox/QuitHover.png"
            action Quit(confirm=False)
            tooltip "Quit."
..
In the game code I release the Photo Book with:

Code:
    scene raquel_photo2
    $ show_photos = True
    $ renpy.restart_interaction()
    scene raquel_photo3
    com "The Photo Book is now available."
If I go back to the main menu the option to view the Photo Book is available, but in the Quick Menu there is no change, the new button does not appear.

Is there any way to fix this, what am I doing wrong?
 
Apr 24, 2020
192
257
You likely need to use persistent variables, the documentation even use an image gallery as an example.
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,363
15,280
Code:
    $ renpy.restart_interaction()
This is useless. Ren'py isn't in an interaction at this moment, so it just do nothing.


If I go back to the main menu the option to view the Photo Book is available, but in the Quick Menu there is no change, the new button does not appear.
Hmm. In case like that, just add text "[show_photos]", before the "if...". It will be ugly, but you'll always know what is the value of the flag seen from the screen. It don't necessarily give you the answer, but you aren't anymore wondering if it's the value that is wrong, or if it's your code.

Now, as for my thoughts, I noticed some strange things with Ren'py screen in the few last release (mostly after the apparition of the "local to screen" concept). Depending of the screen, where its used, as well as how and where the variable is used, it sometime can be implicit variableName and sometimes have to be explicit store.variableName.
So, it's possible that, being an overlay, the quick menu have some problems knowing its locale because of that. So, try to use if store.show_photos: just to be sure.
 

iOtero

Active Member
Aug 4, 2020
925
1,459
Thanks.

Well, I don't know how, with a series of persistent numerical variables I have managed to make it work.

If someone is interested in the solution, let me know and I will post it, but in a few days, when I have everything well checked.

Thanks again. (y)
 
Last edited:

79flavors

Well-Known Member
Respected User
Jun 14, 2018
1,581
2,219
One small note relating to your original post.

You create the variable using define show_photos = False.
That really should be default show_photos = False.

define is generally for objects/variables that will never change while the game is running. If the value is going to change... use default.

It might even be the reason why the quick_menu wasn't working as you hoped - though I haven't tested that.

But yeah, as a general rule... variables are very unpredictable when accessed via the screen main_menu:. That code is executed before the game starts and before a saved game is loaded. Like if _in_replay: code, all variables should be bypassed or ignored - as their values can't be relied upon. It's why persistent variables tend to be used for things like galleries and such, which can be accessed from the main menu (and can be sometimes disabled when accessed from the game_menu variation of the same screen).
 
  • Like
Reactions: iOtero