My Choice Menu doesn't refresh after it's shown (and it's very important to me that it does)

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
Aureus
Veteran
Posts: 278
Joined: Sun Aug 06, 2017 4:49 am
Completed: The Tavern, Tales From Windy Meadow
Projects: Roadwarden
Organization: Moral Anxiety Studio
itch: moral-anxiety
Location: Breslau, Poland
Contact:

My Choice Menu doesn't refresh after it's shown (and it's very important to me that it does)

#1 Post by Aureus »

Greetings!
The problem I have is absolutely crucial for me and if I won't be able to solve it, my entire design will have to be changed significantly. I was hoping that you could try to help me, I really tried for hours now and looking for answers didn't change anything at all.

Here are two simple buttons from a screen, just an example for the purpose of this post:

Code: Select all

                imagebutton:
                    idle "gui/attitudes/image.png"
                    action [SetVariable("at_friendly", 1)]
                imagebutton:
                    idle "gui/attitudes/image.png"
                    action [SetVariable("at_friendly", 0)]
And here is an example of a choice based on the at_friendly variable.

Code: Select all

'unrelated dialogue line'
menu:
    'intro to the actual choice'
    'option is displayed only' if at_friendly:
        jump afterchoice01
    'option is always displayed':
        jump afterchoice02
So what I need and want to have is something that works like this:

Code: Select all

# buttons are displayed, I can click them to set ~~at_friendly~~ to either True or False

'unrelated dialogue line'
menu:
    'intro to the actual choice'
    'option is displayed only' if at_friendly:   # this either disappears or displays itself depending on the value of the variable. so if I go for True, it shows up, if I press the "0" button, it instantly disappears
        jump afterchoice01
    'option is always displayed':
        jump afterchoice02
What I have, however, works like this:

Code: Select all

# buttons are displayed, everything works fine 

'unrelated dialogue line'  # if I use my buttons to set the at_friendly to True here, the dialogue option in the next menu shows up. if not, it doesn't show up.
menu:
    'intro to the actual choice'
    'option is displayed only' if at_friendly:   # this doesn't refresh itself at all. it's either displayed or shown, based on the value of the variable that was set before I displayed this menu.
        jump afterchoice01
    'option is always displayed':
        jump afterchoice02
Can you help me solve this problem? I tried to do something to introduce the renpy.restart_interaction(), for example by adding it to every button, but it didn't work for me.
Tales From Windy Meadow - slice of life, pixel art Visual Novel set in a fantasy village. now available on Steam.

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3794
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: My Choice Menu doesn't refresh after it's shown (and it's very important to me that it does)

#2 Post by Imperf3kt »

Do you want to return to the menu and reuse it? The variable will still be 1 if it was previously 1, so the option will still show as you never changed it after.
Otherwise, everything looks fine to me. Maybe you could add a bit more about the issue you are experiencing?
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

User avatar
Aureus
Veteran
Posts: 278
Joined: Sun Aug 06, 2017 4:49 am
Completed: The Tavern, Tales From Windy Meadow
Projects: Roadwarden
Organization: Moral Anxiety Studio
itch: moral-anxiety
Location: Breslau, Poland
Contact:

Re: My Choice Menu doesn't refresh after it's shown (and it's very important to me that it does)

#3 Post by Aureus »

Hi!
I basically want the menu to refresh itself and re-decide which dialogue options to display based on the new variable value.
So if I display a menu and it has a "Hidden Choice" in it as long as at_friendly == 0,
but a player changes the value of at_friendly to 1 through a different screen,
I want this Hidden Choice to be displayed.

Currently, it always stays the same, depending on the value of various variables as they were before the Menu was displayed.
Tales From Windy Meadow - slice of life, pixel art Visual Novel set in a fantasy village. now available on Steam.

User avatar
Aureus
Veteran
Posts: 278
Joined: Sun Aug 06, 2017 4:49 am
Completed: The Tavern, Tales From Windy Meadow
Projects: Roadwarden
Organization: Moral Anxiety Studio
itch: moral-anxiety
Location: Breslau, Poland
Contact:

Re: My Choice Menu doesn't refresh after it's shown (and it's very important to me that it does)

#4 Post by Aureus »

Oh! I think it may be important to add that I use the NVL style.
Tales From Windy Meadow - slice of life, pixel art Visual Novel set in a fantasy village. now available on Steam.

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3794
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: My Choice Menu doesn't refresh after it's shown (and it's very important to me that it does)

#5 Post by Imperf3kt »

Can I assume you have defaulted the variable outside any label?

Code: Select all

default at_friendly = 0

start:
I don't see why what you typed shouldn't work.
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

User avatar
Aureus
Veteran
Posts: 278
Joined: Sun Aug 06, 2017 4:49 am
Completed: The Tavern, Tales From Windy Meadow
Projects: Roadwarden
Organization: Moral Anxiety Studio
itch: moral-anxiety
Location: Breslau, Poland
Contact:

Re: My Choice Menu doesn't refresh after it's shown (and it's very important to me that it does)

#6 Post by Aureus »

Thank you! Yes, I did set the default value, and I keep seeing in the dev console that the numbers are changing as intended.

I just created a new project to make sure I can reproduce the problem that I have and indeed, it exists even in the very basic version. The variable changes, but the menu doesn't update itself. But if the variable is changed before the menu is displayed, it work fine. It's just not enough for the design I'm working on.
Tales From Windy Meadow - slice of life, pixel art Visual Novel set in a fantasy village. now available on Steam.

rames44
Veteran
Posts: 233
Joined: Sun May 29, 2016 4:38 pm
Contact:

Re: My Choice Menu doesn't refresh after it's shown (and it's very important to me that it does)

#7 Post by rames44 »

I think that the core problem is that the menu has decided on its options, and is now waiting for an interaction from the user. (I.e. blocked, waiting for one of the buttons (IN THE MENU) to be pressed. In parallel, you have a screen that has been shown which updates the variable. But this action doesn’t cause the menu to be re-executed, so the choices don’t update. That part of the code is still buried inside, waiting for one of the menu buttons to be pressed.

A better approach might be to create a custom screen that includes both the menu buttons and also the buttons that toggle the variable, and use a screen variable to enable/disable the choice. Changing a screen variable will cause the screen to be re-evaluated, so that part will work. You can steal the menu layout logic from the choice screen. Then, “call” your new screen (in place of your current “manu” command) which will block, and have each of the menu buttons Return() a value. Then, after the “call screen” line, you can test the _return variable to determine which choice the player made and continue from there.

User avatar
Aureus
Veteran
Posts: 278
Joined: Sun Aug 06, 2017 4:49 am
Completed: The Tavern, Tales From Windy Meadow
Projects: Roadwarden
Organization: Moral Anxiety Studio
itch: moral-anxiety
Location: Breslau, Poland
Contact:

Re: My Choice Menu doesn't refresh after it's shown (and it's very important to me that it does)

#8 Post by Aureus »

Thank you, Rames! This is a similar diagnose to the one I'm thinking of.

I actually tried to do something like what you've described, not exactly the same, but it resembles it, I think. I tried to add the entire screen with buttons to my "choices" screen (which is also a part of the NVL screen, though, as I mentioned, in a full-vanilla ADV game I had the same core problem). The reason why I hesitate to make a completely new screen like you described and Call it whenever I want to introduce this interaction is that I'm going to use it probably a hundred time or so during the course of the game, and I'm afraid to go this far with dev-unfriendly screen switching...

I'm definitely going to try to follow your lead if nothing else is going to help, but I have another issue and maybe you could help me with it. Whenever I call "Return()" from any of the screens, for whatever reason it skips to the next label. As if: it selects one of the choices and goes forward. Is "Return()" something I should replace with "Return(SomethingUnknownToMe)"?

I have also a new desperate idea that I think should work, but with a sacrifice to it as well. I'm thinking about setting up a dynamic variable that borrows its value from every last label the players encounters. And then I would force all the image buttons that I want to change variables to have a "jump to a label that is the same as the variable I just mentioned", basically looping the menu. It Should work : P, but I'm afraid it's going to ruin the History system by multiplying entries as well as completely damage the "text speed" setting. So I'm not sure. : P
Tales From Windy Meadow - slice of life, pixel art Visual Novel set in a fantasy village. now available on Steam.

rames44
Veteran
Posts: 233
Joined: Sun May 29, 2016 4:38 pm
Contact:

Re: My Choice Menu doesn't refresh after it's shown (and it's very important to me that it does)

#9 Post by rames44 »

Just for clarity, “call screen x” puts screen x up on the screen, and then waits for the execution of a Return or Jump action. If (via a button, for example) you execute the action Return(), the screen will be removed and execution will continue with the statement right after the “call screen x” statement. If you execute, for example, Return(123), then the value 123 will be assigned to the variable “_return”, and can be checked in the code that executes after the screen. So if you assign a different value to each button, you’ll know what choice the user pressed and can use “if” statements to execute appropriate blocks.

I’m mobile right now, so I can’t give you example code.

Post Reply

Who is online

Users browsing this forum: Google Feedfetcher