Any simple way to disable all hotkeys in particular 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
User avatar
SONTSE
Regular
Posts: 95
Joined: Sun Nov 24, 2013 10:49 pm
Completed: 8 VN's so far
Contact:

Any simple way to disable all hotkeys in particular screen?

#1 Post by SONTSE » Sat Dec 27, 2014 2:07 pm

Hi!
on a splashscreen I have a disclaimer I want user to unavoidably "accept" to proceed.
but I figured out it can be avoided using default keymap's hotkeys
(jumping to "load" screen, preference, etc.) i don't know the full potential of the keymaps
so i want to temporary (for this screen) completely disable it.
is there any simple method for it? Maybe some specific command line?
Thanks!
Look! It's moving. It's alive. It's alive... IT'S ALIVE! Oh, in the name of God! Now I know what it feels like to be God!(@Henry_Frankenstein. Sums up my coding style)

User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: Any simple way to disable all hotkeys in particular scre

#2 Post by trooper6 » Sat Dec 27, 2014 6:53 pm

I have something like this in my game "A Close Shave"--but in my case I don't want the user to be able to dismiss the slow text of the barber before it finishes printing without hitting an "Interrupt" button.

Go here and look at the various keybindings: http://www.renpy.org/doc/html/keymap.html
Notice that under #Say there is the list of the default keybindings that let you dismiss text: 'mouseup_1', 'K_RETURN', 'K_SPACE', 'K_KP_ENTER', 'joy_dismiss'

Now we don't want the user to be able to dismiss text. So the way to do this is to take all those bindings away. So, in options.rpy, at the end of the file, I added this code:

Code: Select all

    config.keymap["dismiss"] = None
This is great because now the user can't interact with the game anymore except by pressing our button. Only one problem...now the user can't ever interact with the game anymore...at all. Oops! Now you can't change config variables after the game is started (or so I have been told), so what do you do?

Well, I created a screen (that the user can't see because it has nothing on it), that returns functionality to those keys I took functionality away from. It looks like this:

Code: Select all

screen keyscreen:
    key "mouseup_1" action Return("smth")
    key "K_RETURN" action Return("smth")
    key "K_SPACE" action Return("smth")
    key "K_KP_ENTER" action Return("smth")
    key "joy_dismiss" action Return("smth")
So, in the game whenever I want the user to have regular interaction functionality (most of the time), I make sure I am showing the keyscreen. When I don't want the user to be able to dismiss the slow text without pressing the interrupt button on the speaker, I hide the keyscreen. It works like a charm for my game, maybe it'll work for yours, too?
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

User avatar
xavimat
Eileen-Class Veteran
Posts: 1458
Joined: Sat Feb 25, 2012 8:45 pm
Completed: Yeshua, Jesus Life, Cops&Robbers
Projects: Fear&Love, unknown
Organization: Pilgrim Creations
Github: xavi-mat
itch: pilgrimcreations
Location: Spain
Contact:

Re: Any simple way to disable all hotkeys in particular scre

#3 Post by xavimat » Sat Dec 27, 2014 7:08 pm

Is it possible to use a reverse version of trooper6's solution? (Because you only need this in one moment of your game)

Create a screen that overrrides all the "dismiss" keys and show that screen only in that splashscreen label.

I've done a simple test to override the use of the "h" key (hide the window) and it's working. When I show that screen, the 'h' key is not hiding the window. When the screen is hidden, the 'h' key works again:

Code: Select all

screen my_keys:
    key "h" action NullAction()
Comunidad Ren'Py en español: ¡Únete a nuestro Discord!
Rhaier Kingdom A Ren'Py Multiplayer Adventure Visual Novel.
Cops&Robbers A two-player experiment | Fear&Love Why can't we say I love you?
Honest Critique (Avatar made with Chibi Maker by ~gen8)

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot]