Page 1 of 1
Lock buttons after an option is selected
Posted: Fri May 13, 2022 10:54 am
by Exodus13
In my Renpy game, I have this 3 second animation that plays once you click the 'new game' button. I was wondering if there was a way to prevent the pressing of the button once the new game option has been selected. Any help is appreciated.

Re: Lock buttons after an option is selected
Posted: Fri May 13, 2022 12:50 pm
by m_from_space
Since the "New Game" button is probably part of the navigation() screen, you can just do something like the following 3 options. Normally the "New Start" button should disappear anyway though, since you jump into the start label. Don't know what you're doing in your game exactly.
Code: Select all
default game_started = False
screen navigation():
textbutton _("New Game") action If(game_started, NullAction(), [SetVariable("game_started", True), Start()])
# or
textbutton _("New Game") action If(not game_started, [SetVariable("game_started", True), Start()])
# or
if game_started:
text _("New Game")
else:
textbutton _("New Game") action [SetVariable("game_started", True), Start()]
Re: Lock buttons after an option is selected
Posted: Fri May 13, 2022 2:13 pm
by Exodus13
To give a detailed explanation of what happens:
The new game button is an image, which once pressed changes out the background for another one and changes the music. So while the new background is being displayed, I want the user to not be able to press any buttons.
Re: Lock buttons after an option is selected
Posted: Fri May 13, 2022 2:48 pm
by m_from_space
In that case you can just show an empty screen in front of the screen where the new game button is on (probably navigation). To ensure this make the zorder higher and set modal to True, so the player cannot interact with anything other than the screen - which has nothing to interact with. Then hide the screen after the animation is done.
Code: Select all
screen block():
modal True
zorder 100
# optional: make this screen hide itself after 10.0 seconds if you forget about it
# timer 10.0 action Hide("block")
label myanimation:
show screen block
...
hide screen block
Does this make sense?
Re: Lock buttons after an option is selected
Posted: Fri May 13, 2022 3:24 pm
by Exodus13
Yes, it does. Thanks. It works.