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.
-
umineko
- Regular
- Posts: 42
- Joined: Sun Jan 09, 2022 7:12 am
- Projects: Ikimashou!
- Organization: Bagel Poutine
- itch: umineko-chan.itch.io
-
Contact:
#1
Post
by umineko » Sun Feb 27, 2022 6:55 pm
Hi, I am looking for a way to prevent my game's "panic button" from being activated outside of the main game (on the main menu, config, history) etc as it breaks the game if done so.
In short, I want to stop players from pressing the "P" key outside of the main game (Not on the config, history or main menu screens etc) and to only allow it on the main screen, where the dialogue is.
Here's the current code:
Code: Select all
screen panic_button():
layer "screens"
zorder 99
modal True
tag menu
on 'show' action PauseAudio('music', value=True), PauseAudio('ambience', value=True), PauseAudio('sound', value=True)
on 'hide' action PauseAudio('music', value=False), PauseAudio('ambience', value=False), PauseAudio('sound', value=False)
vbox:
image renpy.random.choice(["gui/panic.png", "gui/game_menu.png", "gui/panic2.png"])
init python:
config.underlay.append(renpy.Keymap( K_p = lambda: renpy.run( ToggleScreen("panic_button") ) ) )
"I like kemomimi and I cannot lie."
-
PyTom
- Ren'Py Creator
- Posts: 15893
- Joined: Mon Feb 02, 2004 10:58 am
- Completed: Moonlight Walks
- Projects: Ren'Py
- IRC Nick: renpytom
- Github: renpytom
- itch: renpytom
- Location: Kings Park, NY
-
Contact:
#2
Post
by PyTom » Mon Feb 28, 2022 1:34 am
The _menu variable is True in menus, False otherwise. So you could do:
Code: Select all
init python:
def PanicButton():
if not _menu:
renpy.run(ToggleScreen("panic_button"))
config.underlay.append(renpy.Keymap( K_p = PanicButton() ) )
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
"Silly and fun things are important." - Elon Musk
Software > Drama •
https://www.patreon.com/renpytom
-
umineko
- Regular
- Posts: 42
- Joined: Sun Jan 09, 2022 7:12 am
- Projects: Ikimashou!
- Organization: Bagel Poutine
- itch: umineko-chan.itch.io
-
Contact:
#3
Post
by umineko » Mon Feb 28, 2022 3:07 am
PyTom wrote: ↑Mon Feb 28, 2022 1:34 am
The _menu variable is True in menus, False otherwise. So you could do:
Code: Select all
init python:
def PanicButton():
if not _menu:
renpy.run(ToggleScreen("panic_button"))
config.underlay.append(renpy.Keymap( K_p = PanicButton() ) )
Thanks, managed to get it working

"I like kemomimi and I cannot lie."
Users browsing this forum: Bing [Bot], Google [Bot]