on mapping keyboard keys

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
Unabomberman

on mapping keyboard keys

#1 Post by Unabomberman »

Hello, I've checked Renpy, and I'm trying to figure out a way for making a system that whenever I press a key in the keyboard something happens. I have been looking at the reference manual and found something called "Keymap" that I think can help me but I'm still not sure how. Can anyone take a little time to assist me? I've looked hard around the manual and still; maybe I'm missing something.

So far I've encountered this:

bar_activate = [ 'mousedown_1', 'K_RETURN', 'K_KP_ENTER', 'joy_dismiss' ]

or

skip = [ 'K_LCTRL', 'K_RCTRL' ]

I'm trying to find where those functions (bar_activate, skip)are defined in code but so far no luck.

It seems that I can setup keys to perform certain preprogrammed functions in renpy, but I'm not sure if I can set up my own. Any help would be greatly appreciated, thanks.

chronoluminaire
Eileen-Class Veteran
Posts: 1153
Joined: Mon Jul 07, 2003 4:57 pm
Completed: Elven Relations, Cloud Fairy, When I Rule The World
Tumblr: alextfish
Skype: alextfish
Location: Cambridge, UK
Contact:

Re: on mapping keyboard keys

#2 Post by chronoluminaire »

In this case, what you want is probably not Keymap, but actually ui.keymap. The example there goes:

Code: Select all

label easter_egg:
    "You win!"
    return

init:
    python hide:
         def overlay():
             ui.keymap(W=renpy.curried_call_in_new_context("easter_egg"))

         config.overlay_functions.append(overlay)
Is this closer to what you want to do?
Last edited by chronoluminaire on Sun Feb 24, 2008 10:31 am, edited 1 time in total.
I released 3 VNs, many moons ago: Elven Relations (IntRenAiMo 2007), When I Rule The World (NaNoRenO 2005), and Cloud Fairy (the Cute Light & Fluffy Project, 2009).
More recently I designed the board game Steam Works (published in 2015), available from a local gaming store near you!

Unabomberman

Re: on mapping keyboard keys

#3 Post by Unabomberman »

Yes. I think so. Can't get it to run, still. I put the label before the init block and that's enough to get me an error. I think you are pointing me in the right direction but I'm still a bit lost and at this time (2:54 AM) way too sleepy.

Thanks a lot. I'll surely try it again with a fresher and more rested head.

Bye, and thanks again.

Post Reply

Who is online

Users browsing this forum: Google [Bot], LegsWild