Hey guys. So I am working on a few of my own plugins that involve player and event movement and the Game_Player.prototype.triggerButtonAction function. I am having an issue where the player can spam the trigger button and I want to prevent that with a wait command. Essentially what I want is for the player to input the trigger button, then the wait command waits for a certain amount of frames so the player can't move or input the trigger button again until the statement is done. I tried using interpreter.wait(frames); from the MZ Script Calls in my code but was getting errors (I'm sure I was using it wrong). Was wondering if anyone could help with this. I've posted a snippet of the code for reference.
Thanks!
if ($gamePlayer.direction() === 2) {
this.wait(60);
event1.setDirection(2);
$gamePlayer.setThrough(true);
event1.moveStraight(2);
event1.moveStraight(2);
event1.moveStraight(2);
event1.moveStraight(2);
event1.moveStraight(2);
for (const postEventId in postEvents) {
const postEvent = postEvents[postEventId];
if (postEvent.event().name === postName) {
const postEventX = postEvent.x;
const postEventY = postEvent.y;
if (event1X === postEventX && event1Y === postEventY) {
$gamePlayer.moveStraight(2);
$gamePlayer.moveStraight(2);
$gamePlayer.moveStraight(2);
$gamePlayer.moveStraight(2);
}
}
}
$gamePlayer.setThrough(false);
Thanks!