Script for tracking button pushes?

I'm looking for a script that can track the number of times a certain button is pushed in a certain time frame.  I know I've played a game that has this feature - you push the space bar as many times as you can in one minute to try to pass the test or something.  I don't see a way to do it with events (though I could be wrong) and searching has not produced any results (though maybe I just don't know the right phrase to search).

Any help would be greatly appreciated.
This is kind of easy to do, with events actually. I'll use a treasure chest event as an example I just whipped up to test real quick

page 1(trigger:action button)

Text : PRess cx5 fast!

control Timer: Startup (0 min, 3 sec.

Control Self Switch: A=ON

Page 2🙁Trigger😛arallel process)

Conditional Branch The C button is being pressed

   Control Variables: [0024: f pressed] +=1

branch end

Conditional Branch: Variable [0024: f pressed} >=5

   Change Gold +555555

Text: You just got a lot of \G!

Control Timer: Stop

Control Self Switch: b =On

branch End

Conditional Branch: Timer 0 min 0 sec or less

Text: you really suck

Control Variables: [0024:f pressed] = 0

Control Timer: Stop

Control Self Switch: A = off

Branch End

Then just make sure page for self switch b exists and is blank, simple.
Button "is being pressed" will continue to trigger as long as you hold the button down. That will not count how many times you press the button - it will count how long you press it (in frames).
So then instead, have it condition check for pressing it, add the variable, and then a condition check for NOT pressing it, and repeat that 4 more times. (For the NOT you might need a scripted input trigger condition)
@Shaz... so it does, I didn't realize that... in that case mlogan just change everywhere in the example that says:

Conditional Branch: the c button is being pressed

to

Conditional Branch: Script: Input.trigger?(Input::C)

I tested it to be sure (because I kind of thought the script call did the same thing... only with more options) and with that it does not update continuously when held down, only when pressed repeatedly. That's what I get for trying to keep the event as simple as possible (why would you even need to know how many frames a button was held down for anyway?)
Thanks for the help.  I am working on getting it to work.  For some reason, even though I *think* I did exactly what you had, it's not working completely correctly.  But almost there.  I'm sure it's some stupid switch or something I've not got right.
Show us a screenshot of your event (the whole window, not just the command list), and we'll see if we can help sort it out.
Okay, after messing with it a bit, I figured out why it wasn't working exactly and cut down to this basic sample event that works.  (And if this needs to be moved to events, please do so.)  HOWEVER, despite the input button being C, it only works when I push the enter key.  Is that supposed to happen?  I thought it was literally supposed to be the C key, but maybe I missed some connection? And the 3rd page is just a text saying how many times the button was pushed.  If you need me to show that, I can, but it didn't seem necessary.

So with this exact event, pushing the enter key does get recorded into the variable.  However, not every push is recorded.  At best maybe half.  So if I push it 20 times (counting as I do so), it may show that I pushed it 10.  Is this because of it running through other stuff on the parallel process?  And if so, is there anything that can be done, or should I just adjust my stats keeping in mind the recorded pushes will be half?

screenforhelp.png

I hope all of this makes sense.  I am tired, so it may not.  😉
Input button C is the action button. Not the actual C button on the keyboard. So space and enter will both work.


To be honest, you probably WOULD be better off with a script, because all sorts of things happen in the background with the interpreter and map updating when it's just using events, so there COULD be frames where it's not registering the button press.
Try this:

Spoiler
# ------------------------------------------------------------------------------# Input Count v1.0# FenixFyreX# RPG Maker VxAce# ------------------------------------------------------------------------------# This script allows the user to check how many times a button is being triggered# at a time. Simply call# trigger_count(BUTTON)# where BUTTON can be any of the following:# :UP, 😀OWN, :LEFT, :RIGHT, :A, :B, :C, :L, :R, :CTRL, :ALT, :SHIFT, :F(5-9)# ------------------------------------------------------------------------------module Input # Higher value means longer the system waits to clear the number of presses # of each button. BtnDown = 16 # Set this to true if you want to see the script in action. Set to false to # erase this function. CheckIfCountWorks = true # ---------------------------------------------------------------------------- # DO NOT EDIT BELOW # ---------------------------------------------------------------------------- ALL = [:UP, 😀OWN, :LEFT, :RIGHT, :A, :B, :C, :L, :R, :CTRL, :ALT, :SHIFT] + (5..9).map {|i| "F#{i}".intern } class << self alias update_for_input_checks_fyx update def update(*argv, &argb) update_for_input_checks_fyx update_button_checks end def update_button_checks na = Array.new(ALL.size, 0) @halts ||= Hash[ALL.zip(na)] @counts ||= Hash[ALL.zip(na)] @ntriggers ||= Hash[ALL.zip(na)] @dcounts ||= Hash[ALL.zip(na)] ALL.each do |sym| if press?(sym) @halts[sym] = 0 @counts[sym] += 1 else @halts[sym] += 1 @counts[sym] = 0 end @counts[sym] = [[0, @counts[sym]].max, BtnDown].min @halts[sym] = [[0, @halts[sym]].max, BtnDown].min update_nclick(sym) end end def update_nclick(sym) if @counts[sym] == 1 @ntriggers[sym] += 1 @dcounts[sym] = 0 else @dcounts[sym] = [[0, @dcounts[sym] + 1].max, BtnDown].min @ntriggers[sym] = 0 if @dcounts[sym] == BtnDown end end def trigger_count(sym) @ntriggers[sym] end endendclass Game_Interpreter def trigger_count(sym) Input.trigger_count(sym) endendif Input::CheckIfCountWorks class Scene_Map alias start_fyx start def start start_fyx $sprt = Sprite.new $sprt.z = 99999 $sprt.bitmap = Bitmap.new(Graphics.width, 40) draw_sprt end def draw_sprt $sprt.bitmap.clear $sprt.bitmap.fill_rect($sprt.bitmap.rect, Color.new(0,0,0,100)) $sprt.bitmap.draw_text($sprt.bitmap.rect, "Input Count of C: #{Input.trigger_count🙂C)}",1) $sprt.update end alias update_fyx update def update update_fyx draw_sprt end alias terminate_fyx terminate def terminate $sprt.dispose terminate_fyx end endend# ------------------------------------------------------------------------------# END OF SCRIPT# ------------------------------------------------------------------------------
This should do the trick. Instructions and demo are included in the script itself 🙂
Hey FenixFyreX, thanks for the script.  Can you explain a bit more on how to use it?  I see the script call, but I have no idea how I would incorporate that into an event.  If it's something I need to go look up that's fine, I can. 
mlogan, sorry for the late response. Just use a conditional branch: script with this as the contents:

Code:
trigger_count(BUTTON) >= NUMBER_OF_TIMES

Original thread: https://forums.rpgmakerweb.com/threads/script-for-tracking-button-pushes.19427/