Is there a way to check if a button was hit twice?

Evgenij

Veteran
Veteran
Joined
Aug 28, 2013
Messages
349
Reaction score
100
First Language
German
Primarily Uses
N/A
I want to make an event and if you stand in front of the event and hit a button twice the event will move away from you. (The buttons i want to use are the direction keys)

mfg.
 

AlphaSilvr

King of the Wolves
Veteran
Joined
Aug 7, 2013
Messages
63
Reaction score
8
First Language
English
Primarily Uses
Maybe something along the lines of:

Set the event to "Same as Players" Priority and "Player Touch" as the trigger.

Set a Variable that adds 1 every time the event is touched, followed by a Conditional Branch that checks if the Variable is equal to 2 and moves the event if it is.

EDIT: This should be in Event Support, not Scripting support for next time. :D
 
Last edited by a moderator:

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,365
Reaction score
7,674
First Language
German
Primarily Uses
RMMV
EDIT: This should be in Event Support, not Scripting support for next time. :D
Not neccessarily, because your description allows any time between the buttons pressed - pressing it once, moving away and then pressing it minutes later a second time will still trigger the double press reaction. So don't try to mod others ;-)

@OP:

If you want a time limit for the buttons, then it might be better to use a script - an event checking that will not only be complex, but need a minimum time to work correctly, and lag might break those limits.

There are a few scripts available for "combo attack" that check a sequence of directional keys to trigger special attacks during battle screen, but I don't know such a script for map actions. Please state if you need that or if it's sufficient to count the number of button presses - if neccessary, someone might be able to give you such a script.
 

Evgenij

Veteran
Veteran
Joined
Aug 28, 2013
Messages
349
Reaction score
100
First Language
German
Primarily Uses
N/A
nope, I know how it works with events. But It dont work the way i want it. I want that button to be hit successively and only then the condition start. How you describe it,the event would trigger, if I touched the event one time, move around and touch it another time. And If i post in the Script section I mean the script section. 

Its possible with events, what i described, but because im learning ruby I want to experiment with it.

sorry for my bad englisch
 
Last edited by a moderator:

AlphaSilvr

King of the Wolves
Veteran
Joined
Aug 7, 2013
Messages
63
Reaction score
8
First Language
English
Primarily Uses
Ah, didn't get that you wanted the timing. :p Sorry about that (and the edit post :p )
 

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,846
First Language
English
What is that timing that you want? For example, within a second, 5 seconds. etc?
 
Last edited by a moderator:

Evgenij

Veteran
Veteran
Joined
Aug 28, 2013
Messages
349
Reaction score
100
First Language
German
Primarily Uses
N/A
@Alpha

No problem, you dont need to excuse. But thanks for trying to help nonetheless.

@Tsukihime

The timing isnt important. Its just like if i touch a stone(e.g), nothing should happen, only if i stand next to it and then hit the direction in which the stone stands twice so the stone will move, and only if its twice.  I will look into some scripts with a combo system, maybe then I will understand how to script this.
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,003
First Language
Tagalog
Primarily Uses
RMVXA
so even if I pause in between presses, it's fine as long as don't move away from the stone?
 

Evgenij

Veteran
Veteran
Joined
Aug 28, 2013
Messages
349
Reaction score
100
First Language
German
Primarily Uses
N/A
No, i have used the wrong words. I didnt understand what he meant with timing at first, haha.

There should be a timing. Like 2 seconds. But I dont want a script or something. I will try to script it myself. 

I just thought that there is something like input_trigger? or input_repeat? or that this can be done without script something new. 
 
Last edited by a moderator:

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,846
First Language
English
You will need to do a Input.update script call to clear out the first button press, and check for another button press before the event terminates.


However I have not managed to figure out how to do it properly.
 
Last edited by a moderator:

Evgenij

Veteran
Veteran
Joined
Aug 28, 2013
Messages
349
Reaction score
100
First Language
German
Primarily Uses
N/A
If you dont figured out how to manage it than I wont either. I think I will wait some time, till i get more experience with Ruby and RGSS in general before I try it.

Thanks for your help. 
 

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,846
First Language
English
I was talking about an evented solution. I didn't look at a scripted solution.
 

Napoleon

Veteran
Veteran
Joined
Dec 29, 2012
Messages
869
Reaction score
97
First Language
Dutch
Primarily Uses
Some quick pseudo code:

TIMEOUT = 100 # framesif is_pressed?(x)? @buttons_pressed[x].timestamp = current_frame @buttons_pressed[x].count = 0 if @buttons_pressed[x].timestamp >= TIMEOUT @buttons_pressed[x].count += 1enddouble_tapped?(button) @buttons_pressed[button].timestamp < TIMEOUT && @buttons_pressed[button].count == 2endThere are better methods like stacks perhaps but more or less this is how it will work. Shouldn't be too hard to script but it will consume extra system resources for every key checked for every frame. You might want some enable/disable function on this as well. You can also add a line of code that will make sure that if you pressed "y" for example between the 2 "x" taps that the double tap get's cancelled.

IF however the sequence of keys would always be the same then there are even better and easier ways of implementing this. Like if you only need a sequence of 2x "x" or x,y,escape,enter, or etc.
 
Last edited by a moderator:

Aeri_Sicher

Rookie Programmer! >.
Veteran
Joined
Jun 3, 2013
Messages
74
Reaction score
10
First Language
English
Primarily Uses
We can actually do this entirely without the use of scripting, but if you think scripting would be easier.. than you could just do that instead =]
 
Anyways.. What you need:
 
- two events
- two switches called "start" and "reset"
- one variable called "count"
 
How to set it up:
 
step one - know where to place your two events:

step two - set up the first page of the interactive event with the following settings:
step three - set up the second page of the interactive event:
step four - set up the off-screen event with the following settings (this will activate the cycle on the interactive event):
 
Once you have everything set up properly, the event should take two fast clicks in order to push the block.. if you fail to click within the specified time limit, the event will reset the counter and go back the "Start". As for the timer on top.. with some modifications to the script you could remove that from the game. You can also change the counter if you want to 3 or 4, or even adjust the timer so that the players will have a longer time to push a certain amount of times before the reset.
Update Bug: If the player clicks really fast and achieves the limit before the timer runs out... the player can keep pushing the block for the remaining time he has left. I'll get around to looking for a fix.

Update Bug Fix: Sorry, I was rushing through when I made this... I will be more careful next time. Anyways, here is what you should add into page two in order to fix this bug:

 
I hope that this is what you were looking for, and glad to help in anyway =D
 
Last edited by a moderator:

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,862
Messages
1,017,049
Members
137,569
Latest member
Shtelsky
Top