Ren'Py Open modal automatically inside another screen

GetOutOfMyLab

Conversation Conqueror
Modder
Aug 13, 2021
6,123
16,435
I'm trying to automatically open a modal screen inside a current screen based on the value of a variable.

pseudo-example:
Python:
screen A():
    #Do some stuff
   
    if not name_set:
        # Open the modal ScreenB
This is sort of a run once deal for code reusability. Is this possible? Open to other suggestions to achieve the same effect. Basically, player hits a point in the script where they reach a computer screen that has some image buttons. Before they can interact with anything, it checks if a variable is False. If False, a modal screen pops up that allows them to input a value. After input, modal closes and they are returned to the first screen, the computer screen.


Now that I'm typing this and thinking more...maybe I could use a renpy input. Something like this?
Python:
    if not name_set:
        window:
            modal True
            style_prefix "entry"

            text "Enter your username..."
            input id "entry"
But even that wouldn't act like a modal and I would be able to interact with buttons underneath.
 
Last edited:

GetOutOfMyLab

Conversation Conqueror
Modder
Aug 13, 2021
6,123
16,435
The solution:
Python:
screenA():

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

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,369
15,285
I'm trying to automatically open a modal screen inside a current screen based on the value of a variable.

Hmm, this should do it:
Python:
screen whatever():
    on "show" action If( someFlag is False, Show( "modalScreen" ), NullAction() )

Edit: typo.
 
Last edited:
  • Like
Reactions: gojira667

GetOutOfMyLab

Conversation Conqueror
Modder
Aug 13, 2021
6,123
16,435
Hmm, this should do it:
Python:
screen whatever():
    on show action If( someFlag is False, Show( "modalScreen" ), NullAction() )
Even though I have a working solution, I gave this a try anyway, because it looks less hacky than using a timer lol.

Anyway, this gives the error: 'show' is not a keyword argument or valid child for the on statement.
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,369
15,285
Even though I have a working solution, I gave this a try anyway, because it looks less hacky than using a timer lol.

Anyway, this gives the error: 'show' is not a keyword argument or valid child for the on statement.
Oops, my bad, it's on "show" action [...]. I wrote it too fast, sorry.
 
  • Like
Reactions: GetOutOfMyLab