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?
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
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.