Binding an action to a release of a button? SOLVED

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
tim640
Regular
Posts: 47
Joined: Wed May 23, 2018 4:47 pm
Contact:

Binding an action to a release of a button? SOLVED

#1 Post by tim640 »

Good evening all!
Been a while since i've posted. I realized something a bit weird while binding stuff to gamepad keys, that technically should work but doesn't for some reason
The concrete situation is this: i have a "SKIP" function on the left CTRL keyboard button. When i press it, SKIP happens, when i release it - it stops. So i want the same happening on the gamepad - in particular, i want to press the left trigger so the SKIP would start, and when the trigger is released, SKIP stops. So i added this in "options" to the list of my keymap:

Code: Select all

    config.pad_bindings["pad_lefttrigger_neg"].append("stop_skipping")
    config.pad_bindings["pad_lefttrigger_pos"].append("skip")
Which seems like the right thing as the manual here says at the end https://www.renpy.org/doc/html/keymap.html

However, it gives me an error on start:

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/options.rpy", line 165, in script
    init python:
  File "game/options.rpy", line 205, in <module>
    config.pad_bindings["pad_lefttrigger_neg"].append("stop_skipping")
KeyError: u'pad_lefttrigger_neg'
The trigger works well with SKIP, just doesn't stop when i release it, unlike CTRL
But trying to set the "releasing" of it leaves me with this error. Any ideas?.. Thank you in advance!!
Last edited by tim640 on Thu Nov 15, 2018 4:06 pm, edited 1 time in total.

User avatar
tim640
Regular
Posts: 47
Joined: Wed May 23, 2018 4:47 pm
Contact:

Re: Binding an action to a release of a button? Help needed

#2 Post by tim640 »

UPD: oops, solved it!

Turns out i had to create the event for the trigger release as well. Solution, for anyone wondering, was

Code: Select all

 config.pad_bindings["pad_lefttrigger_pos"].append("skip")
    if not 'pad_lefttrigger_zero' in config.pad_bindings:
        config.pad_bindings["pad_lefttrigger_zero"] = []
        config.pad_bindings["pad_lefttrigger_zero"].append("stop_skipping")

Post Reply

Who is online

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