Timed Prevent Common Events on Button Press

oToToToToTo

Veteran
Veteran
Joined
Jul 13, 2015
Messages
46
Reaction score
9
First Language
English
Primarily Uses
Currently I have it set up for a common event to happen whenever a key/button is pressed. The only problem is that it is spammable. Initially I had set up a variable so that each time it was pressed it would add +5 to the variable (time) and every 5 seconds it would -1 to the variable the button could only be pressed if the variable was = 0. The variable "timer" was put in an if else so that if it was at 0 it would stop ticking down with -1.


It sort of looks like this:


If button is pressed down
If variable Timer = 0
common event


else


variable Timer -1


My question is: Is there an easier way to go about this? Without variables?
 

standardplayer

Keeper of Kitties
Veteran
Joined
Apr 6, 2016
Messages
698
Reaction score
3,450
First Language
English
Primarily Uses
N/A
Whatever is in your common event, you  could literally just add a wait code at the end of it, I do it all the time. Could you possibly describe what's happening when you press the button? Is the character jumping, a menu popping up, what's happening? That way it's easier to suggest changes, this doesn't sound undoable at all. 


Also, fyi, I don't know how to do this with anything other than the regular RPGmaker commands, but know that you can set conditions like this


Input.isPressed('shift') and this will occur when shift is pressed. That is the standard condition you can get from the last page of the Conditional Branch page. However, you can also, with those same commands, use a script call like the one I just showed, or like this:


Input.isTriggered('shift')   NOW, this is important because the isTriggered won't allow spamming. You must release the button and press it again for the event to repeat. This doesn't help with  say, Yanfly Button Common Events because the script call won't know what 'button' you're referring to if it isn't an inherent RPG Maker command, like Cancel, OK, Up, etc. 


Let me know if any of this helps, if not post more info and I'm sure I can help you, this is totally doable
 

oToToToToTo

Veteran
Veteran
Joined
Jul 13, 2015
Messages
46
Reaction score
9
First Language
English
Primarily Uses
Whatever is in your common event, you  could literally just add a wait code at the end of it, I do it all the time. Could you possibly describe what's happening when you press the button? Is the character jumping, a menu popping up, what's happening? That way it's easier to suggest changes, this doesn't sound undoable at all. 


Also, fyi, I don't know how to do this with anything other than the regular RPGmaker commands, but know that you can set conditions like this


Input.isPressed('shift') and this will occur when shift is pressed. That is the standard condition you can get from the last page of the Conditional Branch page. However, you can also, with those same commands, use a script call like the one I just showed, or like this:


Input.isTriggered('shift')   NOW, this is important because the isTriggered won't allow spamming. You must release the button and press it again for the event to repeat. This doesn't help with  say, Yanfly Button Common Events because the script call won't know what 'button' you're referring to if it isn't an inherent RPG Maker command, like Cancel, OK, Up, etc. 


Let me know if any of this helps, if not post more info and I'm sure I can help you, this is totally doable
The button press is activating Yanfly's "Stealth Even Chase" plugin that puts your character in stealth. Whenever a "wait code" is added at the end of the event the player is forced to sit still until the wait is over.
 

standardplayer

Keeper of Kitties
Veteran
Joined
Apr 6, 2016
Messages
698
Reaction score
3,450
First Language
English
Primarily Uses
N/A
Okay, I got it! Just tested it, I got it to wait however long I told it to after I used stealth and after it had run out before I could press it again. And my player was still allowed to move around the map while I waited to be able to activate stealth again, while the button activating it did nothing until the Wait was over.


So, first, you are using Button Common Events as well, right? If you are, this is how I did it. 


so I have a common event called stealth1 that activates under a condition, if a Switch called 'Wait' was off. This was with a conditional branch, not with the common event's conditions. If the Switch called Wait was off, it would turn the Switch on.


On a second common event, called stealth 2, I actually call the code to put you in stealth, call the Wait command (it should include how long the stealth is, as well ex: if you are in stealth for 60 frames and want to have to wait for 400 frames after it's over before you can do it again, wait 460 frames) and then turn the switch called Wait off.


Now for that common event (stealth 2) I use the common event's conditions to be a Parallel Process and to be bound to Switch 'Wait'. 


Let me know if you need to see my examples, I can take screenshots. Hopefully my explanation doesnt' suck. 


Oh and if you aren't using Button Common Events as well, let me know.
 
Last edited by a moderator:

oToToToToTo

Veteran
Veteran
Joined
Jul 13, 2015
Messages
46
Reaction score
9
First Language
English
Primarily Uses
Okay, I got it! Just tested it, I got it to wait however long I told it to after I used stealth and after it had run out before I could press it again.


So, first, you are using Button Common Events as well, right? If you are, this is how I did it. 


so I have a common event called stealth1 that activates under a condition, if a Switch called 'Wait' was off. This was with a conditional branch, not with the common event's conditions. If the Switch called Wait was off, it would turn the Switch on.


On a second common event, called stealth 2, I actually call the code to put you in stealth, call the Wait command (it should include how long the stealth is, as well ex: if you are in stealth for 60 frames and want to have to wait for 400 frames after it's over before you can do it again, wait 460 frames) and then turn the switch called Wait off.


Now for that common event (stealth 2) I use the common event's conditions to be a Parallel Process and to be bound to Switch 'Wait'. 


Let me know if you need to see my examples, I can take screenshots. Hopefully my explanation doesnt' suck. 


Oh and if you aren't using Button Common Events as well, let me know.
Ah, that seemed to do the trick, a bit more simple than variable countdowns, thank you!
 

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

Latest Threads

Latest Posts

Latest Profile Posts

How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c
So I was playing with filters and this looked interesting...

Versus the normal look...

Kind of gives a very different feel. :LZSexcite:
To whom ever person or persons who re-did the DS/DS+ asset packs for MV (as in, they are all 48x48, and not just x2 the pixel scale) .... THANK-YOU!!!!!!!!! XwwwwX

Forum statistics

Threads
105,849
Messages
1,016,977
Members
137,563
Latest member
cexojow
Top