[Solved] Custom screen menu, return to previous

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
GMHLee
Regular
Posts: 27
Joined: Thu Aug 25, 2022 7:00 am
Contact:

[Solved] Custom screen menu, return to previous

#1 Post by GMHLee »

Hi all,

Firstly yes, I did see a tutorial on how to actually change the choice menu but since I've already changed it in a way like so:

Code: Select all

screen choice(items):
    style_prefix "choice"

    vbox:
        for i in items:
            textbutton i.caption.format(*i.args, **i.kwargs) action i.action
Where I needed access to variables (help provided from another thread I made), and the tutorial that I don't have the link for right now was to change said choice menu, thereby negating the current changes, I didn't bother. Wouldn't know how to reimplement it.

So I decided to make my own simple text based menu.
It's crass but it kinda works.

Code: Select all

screen select_training:
    frame:
        xpadding 5
        ypadding 5
        xalign 0.5
        yalign 0.5
        
        vbox:
            text "Select Action to Take"
            null height 10
        
            grid 2 4:
            
                textbutton "{font=SitkaZ.ttc}{color=#aaaaaa}{size=35}Gym" action Jump ("Return5")
                text "check1" 
                textbutton "{font=SitkaZ.ttc}{color=#aaaaaa}{size=35}Dance" action Jump ("Return6")
                text "check2"
                textbutton "{font=SitkaZ.ttc}{color=#aaaaaa}{size=35}Act" action Jump ("Return7")
                text "check3"
                textbutton "{font=SitkaZ.ttc}{color=#aaaaaa}{size=35}Write" action Call (select_training2)
                text "check4"

screen select_training2:
    frame:
        xpadding 5
        ypadding 5
        xalign 0.5
        yalign 0.5
        
        vbox:
            text "Select Action to Take again"
            null height 10
        
            grid 2 4:
            
                textbutton "{font=SitkaZ.ttc}{color=#aaaaaa}{size=35}short story" action Jump ("Return5")
                text "check1" 
                textbutton "{font=SitkaZ.ttc}{color=#aaaaaa}{size=35}essay" action Jump ("Return6")
                text "check2"
                textbutton "{font=SitkaZ.ttc}{color=#aaaaaa}{size=35}novel" action Jump ("Return7")
                text "check3"
                textbutton "{font=SitkaZ.ttc}{color=#aaaaaa}{size=35}Return" action (select_training)
                text "check4"
Or I should say works if all you you had was one menu and no need to move to another menu as shown above.
In the example which most will notice won't work, the action to Call "select training2" screen will crash.
I've tried different iterations.

action call (lower case c).
action Call
action Call screen
select_training with and without brackets, in quotes, etc...

Is this in anyway feasible or do I have no choice but to rewrite the choice menu?

Thanks in advance.
Last edited by GMHLee on Wed Aug 31, 2022 11:02 am, edited 1 time in total.

User avatar
Alex
Lemma-Class Veteran
Posts: 3094
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: Custom screen menu, return to previous

#2 Post by Alex »

GMHLee wrote: Tue Aug 30, 2022 2:12 pm ...Is this in anyway feasible or do I have no choice but to rewrite the choice menu?..
'Call' action is for labels. You can show another screen using 'Show' action.
And to make screens replace each other give them the same tag, like

Code: Select all

screen select_training:
    tag my_menu # use any name you want
    frame:
        xpadding 5
        ypadding 5
        xalign 0.5
        yalign 0.5
        
        vbox:
            text "Select Action to Take"
            null height 10
        
            grid 2 4:
            
                textbutton "{font=SitkaZ.ttc}{color=#aaaaaa}{size=35}Gym" action Jump ("Return5")
                text "check1" 
                textbutton "{font=SitkaZ.ttc}{color=#aaaaaa}{size=35}Dance" action Jump ("Return6")
                text "check2"
                textbutton "{font=SitkaZ.ttc}{color=#aaaaaa}{size=35}Act" action Jump ("Return7")
                text "check3"
                textbutton "{font=SitkaZ.ttc}{color=#aaaaaa}{size=35}Write" action Show ("select_training2")
                text "check4"

screen select_training2:
    tag my_menu # use the same name
    frame:
        xpadding 5
        ypadding 5
        xalign 0.5
        yalign 0.5
        
        vbox:
            text "Select Action to Take again"
            null height 10
        
            grid 2 4:
            
                textbutton "{font=SitkaZ.ttc}{color=#aaaaaa}{size=35}short story" action Jump ("Return5")
                text "check1" 
                textbutton "{font=SitkaZ.ttc}{color=#aaaaaa}{size=35}essay" action Jump ("Return6")
                text "check2"
                textbutton "{font=SitkaZ.ttc}{color=#aaaaaa}{size=35}novel" action Jump ("Return7")
                text "check3"
                textbutton "{font=SitkaZ.ttc}{color=#aaaaaa}{size=35}Return" action Show ("select_training")
                text "check4"
https://www.renpy.org/doc/html/screen_a ... ol-actions
https://www.renpy.org/doc/html/screens. ... -statement

GMHLee
Regular
Posts: 27
Joined: Thu Aug 25, 2022 7:00 am
Contact:

Re: Custom screen menu, return to previous

#3 Post by GMHLee »

Ah, thanks much appreciated.
I should have actually tried that but for some reason I was thinking it'd show under the dialogue box.
Eh, the dialogue box gets hidden by the initial Call from script so meh.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot]