need some help.
can someone tell me how can we detect input from keyboard in renpy?
I mean, I want it so that when the user click some arrow [K_UP], [K_DOWN], [K_LEFT], [K_RIGHT],
then detect the input,
then do something, like move to the next scenery according with the key pressed.
detect keyboard input?
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.
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.
- PyTom
- Ren'Py Creator
- Posts: 16096
- 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:
Re: detect keyboard input?
You generally want a screen, with various key entries.
You can then show or call the screen, and it will listen for keys and jump where you want it to.
Code: Select all
screen keynav:
key "K_UP" action Jump("up")
key "K_DOWN" action Jump("down")
# ... etc.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom(When was the last time you backed up your game?)
Software > Drama • https://www.patreon.com/renpytom
Re: detect keyboard input?
Thanks PyTom...
it really helps..
I'm still a noob after all
it really helps..
I'm still a noob after all
- PyTom
- Ren'Py Creator
- Posts: 16096
- 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:
Re: detect keyboard input?
We all were, once, in most things.D-R_aldi wrote:I'm still a noob after all
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom(When was the last time you backed up your game?)
Software > Drama • https://www.patreon.com/renpytom
Re: detect keyboard input?
I imagine this thread is fully dead, I don't know if something fundamental has changed in the last 3 years, but I get the following error:
As it stands, it exists in this code:
I'm trying to make it so that rather than having to press an on-screen button, the user can just hit enter/return when they're done. On the off chance anyone sees this, any advice is greatly appreciated. And if you can explain why that's even better. Trying to reduce the amount of blind copying I do.
Code: Select all
I'm sorry, but errors were detected in your script. Please correct the
errors listed below, and try again.
File "game/input.rpy", line 27: u'jump' is not a keyword argument or valid child for the key statement.
key 'K_RETURN' action jump("complete")
^
Ren'Py Version: Ren'Py 6.99.12.4.2187
As it stands, it exists in this code:
Code: Select all
screen text_input_screen():
default screenvar = True
imagemap:
ground "background.png"
idle "idle.png"
hover "hover.png"
selected_idle "hover.png"
hotspot (150,140,475,200) action SetScreenVariable("screenvar",True)
hotspot (625,140,110,100) action [Hide("text_input_screen"),Jump("complete")]
key 'K_RETURN' action jump("complete")
if screenvar == True:
input default firstname pos(200,165) changed name_func
Re: detect keyboard input?
You ought to write Jump with a capital J. Simple typing errors are the most common in Ren'py so I suggest you always give a lot of attention to the error message (in this case it straight up tells you 'jump' is not a function that exists) and always double check what you type.Kinross07 wrote: ↑Tue Aug 08, 2017 2:45 pm I imagine this thread is fully dead, I don't know if something fundamental has changed in the last 3 years, but I get the following error:
Code: Select all
File "game/input.rpy", line 27: u'jump' is not a keyword argument or valid child for the key statement. key 'K_RETURN' action jump("complete") ^
Re: detect keyboard input?
This is why it confused me, because when moving to labels and things, lower case jump is perfectly valid, so I didn't realise they were two separate things. Thank you though
Who is online
Users browsing this forum: Bing [Bot]