PDA

View Full Version : Press and Release keys



beefster09
12-04-2006, 04:16 PM
I know it can already be faked, but ZScript needs "Press(Input*)" And "Release(Input*)"

Pretty much they're just functions that return a bool when the input is true then not true and vice-versa.

You would need this if you wanted to make a playable ocarina, or even most custom items.

Saffith
12-04-2006, 04:30 PM
I'm not sure I see how this would be different from what we already have. Do you mean to write event-driven scripts?

By the way, use [/color] instead of [color=Black]. It's white for some of us, remember.

beefster09
12-04-2006, 05:13 PM
By the way, use [/color] instead of [color=Black]. It's white for some of us, remember.

Sorry, I use the WYSIWYG text editor.

Well, normally, the keypress events return true every frame, this way, they only return true once. (when the button just gets pushed or released)

eXodus
12-08-2006, 08:16 PM
While Press* and Release* would indeed be helpful, it can be somewhat faked right now. Take a look at this part of my Fixed Direction script:

http://www.armageddongames.net/showthread.php?t=94457

if (!Link->InputL && !Link->InputR) {
turned = false;
}
if (Link->InputL) {
Link->InputL = false;
if (!turned) turn(false);
}
if (Link->InputR) {
Link->InputR = false;
if (!turned) turn(true);
}


In case it isn't obvious from the snippet, that turn() function is setting turned to true. See how I just prevented the code from firing again as long as the button is still held down? You could hook a function to either side of the logic to emulate the two functions. Of course, you'd need a separate loop and boolean for each key/combination you want to check for...