Using a 'frame' menu. Causing issues with caching?

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
Eligar
Newbie
Posts: 14
Joined: Thu Apr 24, 2014 11:55 am
Contact:

Using a 'frame' menu. Causing issues with caching?

#1 Post by Eligar »

Hey there! So I decided to have a dropdown menu for my game using something like this:

Code: Select all

define bool = True
screen menu1():
    frame:
        pos (107, 30)
        has vbox
        if bool == True:
            textbutton "Option 1":
                clicked Hide("menu1"), Jump("label1")
        if bool == False:
            textbutton "Option 2":
                clicked Hide("menu1"), Jump("label2")
The issue is, that the frame won't directly update if I were to change the boolean. Meaning that even if I turn it to False, it will still show me the menu as if it were True, 'until' I click the menu once > click cancel and then click it again. By this time it has update itself to show the proper menu options.
It almost seems like a caching issue. Is there any way for me to fix this?

User avatar
papiersam
Veteran
Posts: 231
Joined: Fri Aug 12, 2016 2:24 pm
Completed: Gem Hunt Beta, 1/Probably, Animunch
Projects: The Panda Who Dreamed
Contact:

Re: Using a 'frame' menu. Causing issues with caching?

#2 Post by papiersam »

It's something to do with the way if statements and vboxes are coded, I think. Anyways, you could try this:

Code: Select all

define bool = True
screen menu1():
    
   # text "[bool]"
    if bool:
        frame:
            pos (107, 30)
            has vbox
            textbutton "Option 1":
                clicked Hide("menu1"), Jump("label1")
                    
    if not bool:
        frame:
            pos (107, 30)
            has vbox
            textbutton "Option 2":
                clicked Hide("menu1"), Jump("label2")
                
                
label start:
    
    show screen menu1
    
    "A"
    
    $bool = False
    
    
    "a"

Eligar
Newbie
Posts: 14
Joined: Thu Apr 24, 2014 11:55 am
Contact:

Re: Using a 'frame' menu. Causing issues with caching?

#3 Post by Eligar »

I think having put the if statement 'before' the frame might have fixed it! I'll experiment a bit more with it tomorrow, but thanks for the help!

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot]