[SOLVED]keymapped panic button

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
rebellare
Regular
Posts: 34
Joined: Mon Nov 06, 2017 9:34 am
Contact:

[SOLVED]keymapped panic button

#1 Post by rebellare »

So, I've been trying to make a "panic button" in the game where, at any point in the game, when you press "P" or "p", an image appears over everything and moves only when you press the button again. I've been googling and researching like mad, but all I've gotten is that it DOES appear, just not right away. (example: I press P and nothing happens until I go to another label. It does what it's supposed to, goes over everything, but then I can't remove it...)

current code:
default pan_but = 0


init python:
def show_panic_button():
global pan_but
if pan_but == 0:
renpy.show_screen("panic_button")
pan_but = 1
elif pan_but == 1:
renpy.hide_screen("panic_button")
pan_but = 0
config.keymap["open_panic_button"] = ["P", "p"]
config.overlay.append(renpy.Keymap(open_panic_button=show_panic_button))


And, in my custom_screens.rpy file:

screen panic_button:
layer "screens"
zorder 99
modal True
tag menu
vbox:
image "bg/panic_display.jpg"

Someone please find where I'm being an idiot and making the mistake. I tried changing the config.underlay part to confing.overlay but it doesn't recognize it.
Last edited by rebellare on Mon Nov 26, 2018 8:15 am, edited 1 time in total.

User avatar
Remix
Eileen-Class Veteran
Posts: 1628
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I'm still looking for an artist)
Projects: An un-named anime based trainer game
Contact:

Re: keymapped panic button

#2 Post by Remix »

I tend to use something like:

Code: Select all

screen panic_button():
    # ...

init python:

    config.underlay.append(
        renpy.Keymap( 
            K_p = lambda: renpy.run( ToggleScreen("panic_button") ) 
        )
    )
Frameworks & Scriptlets:

rebellare
Regular
Posts: 34
Joined: Mon Nov 06, 2017 9:34 am
Contact:

Re: keymapped panic button

#3 Post by rebellare »

Works like a charm! Thank you! Also, can I turn off the menu buttons while it's on? I want it so nothing can be done until you press "p" again.

Post Reply

Who is online

Users browsing this forum: No registered users