Basically I wanted to put in a script command where if the user presses a key once (trigger) one action is performed, but if they hold the key (press), a different action is performed. When I attempted this, however, the "input.press?" option always took priority over the "input.trigger?" action, no matter how quickly I was pressing the key. Is there a way I can check if the player is pressing the key for say, 1-3 seconds, and then triggering the action if this condition is met?
How to check for input.press? for a period of time? (holds a key)
Learning Ruby and RGSSxyou can put the seconds into a variable and make the
wait for 60 frames
add +1 variable,
Conditional brance : script: key press here
(condition brance) if variable is >= 3
do stuff
else
reset variable = 0
end
around this can work out in a common event if you call it
wait for 60 frames
add +1 variable,
Conditional brance : script: key press here
(condition brance) if variable is >= 3
do stuff
else
reset variable = 0
end
around this can work out in a common event if you call it
Is there a direct way to script it? I suppose I could try to work it into a common event, but the problem I see with this is that even if I set a common event to be a parallel process, it wouldn't behave in such a way if it were called outside of setting the switch on. ...Although maybe I can quickly set the switch on and off in the script...
Shadow Dragon posted a good Idea, but it seems not fluid enough with a 60 Frames wait.
Maybe you could try another solution without the long wait.
I made one in MV but it works in VX-Ace, you just need someone who makes a Script out of it, because its Evented with standard Editor.
Event on Paralell with Eventcode:
If you keep holding the Button, a Variable will be increased until you release the Button, than the value is checked with conditional branches which than execute the wanted behavior. (If variable = 60 than you pressed the Button 1 Second)
Edit: If you need additional behaviors implemented into this, let us know.
Also this Thread is helpful with Script Calls for use inside Eventcommmands:
https://forums.rpgmakerweb.com/index.php?threads/script-call-collection-for-vxace.25759/
If you need a Script for Scripteditor, sorry i cant Script, maybe one of the Scripters drops by.
Maybe you could try another solution without the long wait.
I made one in MV but it works in VX-Ace, you just need someone who makes a Script out of it, because its Evented with standard Editor.
Event on Paralell with Eventcode:
Code:
◆If:Button [Pageup] is pressed down
◆Control Variables:#0010 press down time = 0
◆Loop
◆If:Button [Pageup] is pressed down
◆Control Variables:#0010 press down time += 1
◆Wait:1 frame
◆
:Else
◆Break Loop
◆
:End
◆
:Repeat Above
◆If:press down time ≥ 0
◆If:press down time ≤ 49
◆Text:None, Window, Bottom
:Text:Normal Swordslash...
◆
:End
◆
:End
◆If:press down time ≥ 50
◆Text:None, Window, Bottom
:Text:Powerattack! ...
◆
:End
◆
:End
Edit: If you need additional behaviors implemented into this, let us know.
Also this Thread is helpful with Script Calls for use inside Eventcommmands:
https://forums.rpgmakerweb.com/index.php?threads/script-call-collection-for-vxace.25759/
If you need a Script for Scripteditor, sorry i cant Script, maybe one of the Scripters drops by.
It's the wait part that stumps me. I mean if I do that in a script, I'd get the error "can't yield from root fiber".
Maybe i got another Solution without wait.
The following solution doesn't use extra wait, so it should not interrupt your script loop.
I hope the code is self explanatory, else just ask.
Edit:
Here a version without Switch with only 1 Variable.
This is no ready scriptcode, this is copy pasted eventcode from mv.
The following solution doesn't use extra wait, so it should not interrupt your script loop.
I hope the code is self explanatory, else just ask.
Code:
◆If:Button [Pageup] is pressed down
◆Control Switches:#0001 Push Recogniced = ON
◆Control Variables:#0010 press down time += 1
◆
:Else
◆If:Push Recogniced is ON
◆If:press down time ≥ 0
◆If:press down time ≤ 49
◆Text:None, Window, Bottom
: :Normal Swordslash...
◆
:End
◆
:End
◆If:press down time ≥ 50
◆Text:None, Window, Bottom
: :Powerattack! ...
◆
:End
◆Control Variables:#0010 press down time = 0
◆Control Switches:#0001 Push Recogniced = OFF
◆
:End
◆
:End
Edit:
Here a version without Switch with only 1 Variable.
Code:
◆If:Button [Pageup] is pressed down
◆Control Variables:#0010 press down time += 1
◆
:Else
◆If:press down time ≥ 1
◆Comment:---------------------------------
◆If:press down time ≤ 49
◆Text:None, Window, Bottom
: :Normal Swordslash...
◆
:End
◆If:press down time ≥ 50
◆Text:None, Window, Bottom
: :Powerattack! ...
◆
:End
◆Control Variables:#0010 press down time = 0
◆
:End
◆
:End
This is no ready scriptcode, this is copy pasted eventcode from mv.
Hey, it works! ...And yes, as you correctly predicted, this is for a charge attack. I should add an animation when it's fully charged, but I think I can do that on my own. Thanks!
@Bex i didn't know you can do things without the wait, i know its mostly include to make it smoother.
@KingHazeel im happy you found a way that works, if its solved, report your own post and mark it solved, so the moderator
can close it due solved ^^
@KingHazeel im happy you found a way that works, if its solved, report your own post and mark it solved, so the moderator
can close it due solved ^^
This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.
Original thread: https://forums.rpgmakerweb.com/threads/how-to-check-for-input-press-for-a-period-of-time-holds-a-key.109934/