Show modal screen while in a screen

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
GetOutOfMyLab
Newbie
Posts: 11
Joined: Sun Apr 03, 2022 8:04 pm
Contact:

Show modal screen while in a screen

#1 Post by GetOutOfMyLab »

So here's what I'm trying to do. Players will reach a part where a screen is called. It's basically a background picture of a computer screen with some imagebuttons and other items strategically placed.

I have a boolean variable that is default to False. When the above screen is called I want the variable to be checked and if it is still False, I want to display a modal screen over the screen above that requires player input. The input will set the above variable to True and set another value as well. So basically, this is a runonce scenario.

It seems you can't automatically call another screen without some sort of button. Is this possible?

I'm also open to other suggestions to achieve the result of first time player sees this screen, it will still be visible, but with a modal open to obtain input. Player submits change, necessary variables are changed and the modal closes.

TIA

GetOutOfMyLab
Newbie
Posts: 11
Joined: Sun Apr 03, 2022 8:04 pm
Contact:

Re: Show modal screen while in a screen

#2 Post by GetOutOfMyLab »

I think I may have solved it. In the first screen, I can do this:

Code: Select all

if not name_set:
    use entry_screen
The entry_screen appears over the other screen as expected. Not sure if this is the best solution, so will still accept others if provided.

GetOutOfMyLab
Newbie
Posts: 11
Joined: Sun Apr 03, 2022 8:04 pm
Contact:

Re: Show modal screen while in a screen

#3 Post by GetOutOfMyLab »

Ok, that won't work. By using "use entry_screen", calling the Hide("entry_screen") action doesn't seem to work.

rayminator
Miko-Class Veteran
Posts: 793
Joined: Fri Feb 09, 2018 12:05 am
Location: Canada
Contact:

Re: Show modal screen while in a screen

#4 Post by rayminator »

you have to do something else hide won't by using use screen_name

you want to do this
pass is for so renpy won't show a error

Code: Select all

default want_to_see_this_screen = True or False
    if want_to_see_this_screen == True:
        if not name_set:
            use entry_screen
    else:
        pass
when ever you want to hide it you use a textbutton or $ want_to_see_this_screen = False

GetOutOfMyLab
Newbie
Posts: 11
Joined: Sun Apr 03, 2022 8:04 pm
Contact:

Re: Show modal screen while in a screen

#5 Post by GetOutOfMyLab »

With use entry_screen, I noticed that the imagebuttons on the first screen are interactable under the modal. Doing some more research, it doesn't seem to be the way to go. I tested by having that modal open up through an imagebutton action and it worked as expected.


Now, if I can only find a way to open that second screen automatically if name_set == False.

GetOutOfMyLab
Newbie
Posts: 11
Joined: Sun Apr 03, 2022 8:04 pm
Contact:

Re: Show modal screen while in a screen

#6 Post by GetOutOfMyLab »

Perhaps I'm going at this wrong. Maybe I could just do something like this:

Code: Select all

if not name_set:    
    window:

        style "entry_window"
        
        text prompt
        input id "entry"

GetOutOfMyLab
Newbie
Posts: 11
Joined: Sun Apr 03, 2022 8:04 pm
Contact:

Re: Show modal screen while in a screen

#7 Post by GetOutOfMyLab »

The solution thanks to jDD on discord:

Code: Select all

screenA():

    if not name_set:
        timer .1 action Show("ScreenB")

and someone else just showed me a different way, which I like better:

Code: Select all

screenA():
    on 'show' action If(name_set is False, Show("ScreenB"), NullAction())

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Amazon [Bot]