Help for button mash minigame!

Hello! So I have a minigame I'm working on that involves a character getting dragged under the ocean and they need to mash a certain button a number of times to escape. I have all the variables laid out and everything seems to be in order, except the button/key I have linked to adding to the mash variable isn't working! Is there a way to configure another key on the keyboard so I can have a button specifically for this escape minigame, or would that need a script? If it needs a script, does anyone know of any that could help? Thank you!

I have a picture of my variable event attatched.
You see, pressing a button means you don't stop pushing it down. IMHO, this might be a problem because you want them to keep pushing it like crazy, not just pressing it and keep it down for a few seconds to set the character free. So the press? method doesn't really help you. Instead you'd need the trigger? method to be able to push it n times and be able to run away from that terrible threat.

You might prefer to use my LoopUpdateCmd ACE script to be able to check if it's triggering the button instead of just pressing it. That's how I'd deal with this issue.
Ohhhhh! I see! I didn't know that's how it worked! How does the script work? Could I use it?
Well, you can find the explanation and a screenshot right here.
Once you create the corresponding Input.trigger? condition, you only need to use a variable to keep track of how many times the player pushed that button. B cancels, C stands for OK.
Is the "Right here" supposed to be a link? I can't see any screenshots...
I forgot to add the link, he, he. Now it's available.
Hey! So I tried it out, but I'm only getting an error message when the script is called. I'm not sure what I did wrong...
Why did you add another loop in the Else branch?
It doesn't seem to be necessary.
Why did you add another loop in the Else branch?
It doesn't seem to be necessary.
I only put that so that the player could mash two different buttons to escape, so It's not really necessary. I also put it so that if the player doesn't do anything then the variables decrease by 5 every 60 frames or so.
Why don't you remove that extra loop and simply add its contents to the else branch?
It might work without that second loop.
Why don't you remove that extra loop and simply add its contents to the else branch?
It might work without that second loop.
Still getting the same error, I took out the loops in the "else" part and made it its own conditional branch. I think it's hanging up at the "loop_update" script.
Well, there's no updated screenshot so I've got to suggest something based on the last one.
The condition checking if the variable has reached or exceeded a certain value is OUTSIDE the loop.
That doesn't help. It should be inside.

By the way, can you post a new screenshot that includes the changes you've made.
Oh yeah! Sorry about that, I didn't think to do that! Here:
What I don't get is why did you keep the other conditions outside the loop with the script call to loop_update. All those checks belong to a single loop.
I just didn't know what I was supposed to do! the only instruction I saw was to add the loop_update script thing and add the (input_::?). I'm very new to scripting and I just wanted to ask for some help. I'm trying as best as I can but with little to no explanation I don't know what to do. I'm sorry, but was just trying to work with what I have. I may have missed something, I'm not afraid to admit that, but I just need some help to know how to make what I want to happen happen.
Err. that part is not really about scripting but eventing, from your viewport as an average game developer at least.

Let me see if I can explain it so you can understand how it should work.

Without any loops, you can throw as many conditions one after another and nothing weird would happen. When working with loops, that changes quite a bit.

All loops need a call to a loop, a bunch of commands, and finally a break loop command at some point before Repeat Above ends that loop's list of commands. That break can be inside a conditional branch, like one checking if you pressed or triggered any given button.

Here's an idea of how a simplified version of it should look like:

Code:
Loop
  Script: loop_update
  Conditional Branch: Script: Input.trigger?(:C)
    Control Variables [0070:Mash] += 10
    Conditional Branch: Variable [0070:Mash] >= 30
      Break Loop
    Branch End
  Branch End
Repeat Above
Control Variables [0070:Mash] = 0

As you may have noticed by now, the only thing that's outside that loop is the command to reset the variable to 0.
Ohhh, okay, I see. But how would I make it so that if the player does nothing, the variables go down? Does that need to be in the loop or in a different thing?
Err. that part is not really about scripting but eventing, from your viewport as an average game developer at least.

Let me see if I can explain it so you can understand how it should work.

Without any loops, you can throw as many conditions one after another and nothing weird would happen. When working with loops, that changes quite a bit.

All loops need a call to a loop, a bunch of commands, and finally a break loop command at some point before Repeat Above ends that loop's list of commands. That break can be inside a conditional branch, like one checking if you pressed or triggered any given button.

Here's an idea of how a simplified version of it should look like:

Code:
Loop
  Script: loop_update
  Conditional Branch: Script: Input.trigger?(:C)
    Control Variables [0070:Mash] += 10
    Conditional Branch: Variable [0070:Mash] >= 30
      Break Loop
    Branch End
  Branch End
Repeat Above
Control Variables [0070:Mash] = 0

As you may have noticed by now, the only thing that's outside that loop is the command to reset the variable to 0.
Hey! Okay, so I updated the event to what you wrote, but I'm still getting the error. (I did add a stop SE but that's for the background sound.)
Just a simple question... does the same happen in a brand new project as well?
I simply wanna discard any possible side effects of other scripts currently running in your project.

IMPORTANT EDIT

The only way I could reproduce your error message was if line 17
Ruby:
$game_map.update

...had been replaced with
Ruby:
$game_map.update(true)

Otherwise, it should be impossible to get to that point at all.
There was a good reason why I never passed that true value to the update method.
To prove it I created a new test project.

Spoiler: New Screenshot
loopupdatecmd_ace02.PNG

Now I seriously suspect that either you forgot to remove that (true) custom part from my script or there's another script call it and passing true as its only argument.
Just a simple question... does the same happen in a brand new project as well?
I simply wanna discard any possible side effects of other scripts currently running in your project.

IMPORTANT EDIT

The only way I could reproduce your error message was if line 17
Ruby:
$game_map.update

...had been replaced with
Ruby:
$game_map.update(true)

Otherwise, it should be impossible to get to that point at all.
There was a good reason why I never passed that true value to the update method.
To prove it I created a new test project.

Spoiler: New Screenshot

Now I seriously suspect that either you forgot to remove that (true) custom part from my script or there's another script call it and passing true as its only argument.
Ahh, okay. I'll try that. I didn't edit the script at all, as I don't know anything about scripting and worry about breaking a script if I do. I'll try this out! Thank you!

Original thread: https://forums.rpgmakerweb.com/threads/help-for-button-mash-minigame.167106/