Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

repeated button press

Hello, I've been using Zeriab's "reintroducing the button input process known from RMXP" script found here:
http://www.rmxp.org/forums/index.php?topic=45057.0

I can't seem to make the system read if the player is repeatedly pressing a button or not, it seems to just read if the player has the button pressed (or held). I guess what I'm asking is, is there a way to modify the script so that it reads if the button is being depressed and then pressed again? Maybe even add an option to read if the button is not being pressed.

Also, there are these three options which ask for the player to press a certain button:
button_trigger(14)                   
button_press(14)
button_repeat(14)

They all seem to do the same thing, if there is a difference can someone point it out?
 

Zeriab

Sponsor

The trigger, press and repeat does the same as the similarly named methods for the Input module:
Manual entry on the Input module":2d3ozk65 said:
Input.press?(num)
Determines whether the button num is currently being pressed.
If the button is being pressed, returns TRUE. If not, returns FALSE.
Code:
if Input.press?(Input::C)
  do_something
end

Input.trigger?(num)
Determines whether the button num is being pressed again.
"Pressed again" is seen as time having passed between the button being not pressed and being pressed.
If the button is being pressed, returns TRUE. If not, returns FALSE.

Input.repeat?(num)
Determines whether the button num is being pressed again.
Unlike trigger?, takes into account the repeat input of a button being held down continuously.
If the button is being pressed, returns TRUE. If not, returns FALSE.

Which of the methods is the one you seek?  :wink:

In which context are you using the script call?
Can you show us a picture of the event?

*hugs*
- Zeriab
 
Ok, I'll show you how I am using it. Here's the event that I was calling:
http://i231.photobucket.com/albums/ee29 ... data-2.png[/img]

First, background information:
1) variable [20] kept count of how many frames/ button presses the button I specified held.
2) variable [19] kept track of how many frames had passed by. It refers to a timer I created in the common events that ran on a parallel process when switch [8] was turned on. What it would do is call a wait command for 1 frame and then after that wait, it would add 1 to variable [19].

I made this separate timer so that the player would not see the timer and because when the timer function in RMVX reaches 0, if you are in a battle, the battle ends. This function is going to be used in battles, so I needed a timer that would not instantly stop the battle if the player lets it run to 0.

Anyway, I'll explain what this event was going to do:
The event was to start the timer and then it would run through that loop process. It would then see how many times you hit the specified button until the variable hit 180 (3 secs pass). Each time the button is pressed, it would add 1 to variable 20. After 3 secs have passed, then the event would tell you how many times it was pressed.

The problem is that I can also just hold down the button and the event would count each frame that you held down the button and add that to the variable. As in, if I kept the button depressed, let go after a short time, then pressed the button again (I pressed the button twice) the command in the end would tell me that I pressed the button 35 times when really, I only pressed it twice.
 

Zeriab

Sponsor

The button_repeat checks for repeats. Consider it just like when you hold down a key and there comes several of the letterssssssssssss.
Just look at how the menu works. When you press a key down it moves one, a small pause, repeats.

For your problem you should use button_trigger.
It requires a trigger of the key. (Trigger = the act of pressing the key down, not holding it down)


On a side note notice that after 180 frames has passed the user must press the x button once more before the loop is broken and the times pressed message is shown. The player could theoretically wait hours.
This may not be wrong, it's something to keep in mind ^^

*hugs*
- Zeriab
 
hmmm, what you say makes sense. Going to test it now.
...
..
.
IT WORKS! IT WORKS! :lol:
gah, I really should of tried trigger out too instead of just assuming it'd cause the same problems. Oh well...

Thank you very much, Zeriab. :thumb:
*hugs*
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top