For things to work on button press but...

So here's the idea: I want a script to run every time a button is hit, but ONLY as it's first hit. I don't want holding it to spam the script. Any ideas?
You could exit the event after you do whatever you want in the button press conditional or add a moveroute: wait to just delay it? Not sure if that gets at what you're asking, but I hope it helps anyway.
Could you turn on a switch when it's pressed, then check for when the button is released/not pressed anymore to turn the switch off again, and then require that switch to be off in order for the event/script to trigger again?

So maybe like:

Code:
if (Input.isPressed('button')) {
    if ($gameSwitches.value(switchId) == false) {
        $gameSwitches.setValue(switchId, true);
        [THE REST OF YOUR SCRIPT];
    }
} else {
    $gameSwitches.setValue(switchId, false);
}

EDIT: Whoops, sorry mods for forgetting to add this as an edit to my original reply 😩

EDIT 2: But have you tried just using Input.isTriggered yet? Because I think it's supposed to only return true if the button is being pressed during this frame and wasn't being pressed during the last frame?

EDIT 3: Thanks mods for merging my posts <3
So I think I phrased it wrong, and was thinking about it the wrong way
this is a parallels process for game-wide button hitting. the problem is that when the button is held down it runs the script over and over and interrupting itself. I need to make it run when pressed, not run when running.
Also, having it wait wouldn't work because the player could hold the button for any amount of time.
-recap-
the script must go:
is key pressing?
script
STOP
wait until key is unpressed
THEN repeat is key pressing?
you could just use two parallels:

first one:
If button <whatever> is being pressed
{
turn on the switch to activate the script
turn off the switch for this process
}

second one:
{whatever the script you're running is
turn the 'button press' switch back on when it's over.}

Or do you need the script to run only while the button is being held?
the problem is that when the button is held down it runs the script over and over and interrupting itself. I need to make it run when pressed, not run when running.
Also, having it wait wouldn't work because the player could hold the button for any amount of time.
-recap-
the script must go:
is key pressing?
script
STOP
wait until key is unpressed
THEN repeat is key pressing?
What I suggested should do exactly this. Have you tried it?
What I suggested should do exactly this. Have you tried it?
yes, it spammed the event for as long as the button was held
like I said <:/
yes, it spammed the event for as long as the button was held
like I said <:/
Hmm... Can you show me exactly what you did (like with screenshots)? Because I just tried it and it works as intended:

picture.png


With this parallel event running, whenever I press the 'ok' button, it moves my character down a tile - but it only moves them once and then stops, even if I'm holding the button down, and only moves them again if I release the button and then press it again.

There must be either something wrong with how you typed or set this up, or something about the particular event you're triggering that would make it independently keep repeating regardless of how you set up its button trigger.
@Ratatattat From what I remember there's different variants for button presses, at least in VX Ace.

Ruby:
Input.trigger?(:A)
Input.repeat?(:A)
Input.press?(:A)

Press is if you have it held down while repeat means jamming the same input over and over, etc.

Maybe the mystery can be solved by figuring how they work in MV.
Like @Ratatattat said, Input.isTriggered('ok') should work in Conditional Branch -> Script to check if the button was up last frame but down this frame. Alternatively the pure-event solution shown in their screenshot should also work.
wuuuuu.png
oh man
got it I needed to use Input.isTriggered rather than pressed as @Ratatattat said
oh man
got it I needed to use Input.isTriggered rather than pressed as @Ratatattat said
I'm glad you got it working :LZScheeze:

Original thread: https://forums.rpgmakerweb.com/threads/for-things-to-work-on-button-press-but.147350/