How can I make the game wait?

I'm trying to make a plugin that requires the editor's wait command twice, one of them for a customized animation, Game_Interpreter.prototype.command230, that calls Game_Interpreter.prototype.wait. I read on that spreadsheet I could just use $gameInterpreter.wait(), but $gameInterpreter does not exist. I found out it's actually $gameMap._interpreter.
I tried to make in my plugin script:
Code:
var interpreter=new Game_Interpreter();
interpreter.wait(200);
Code:
var interpreter=new Game_Interpreter();
interpreter.command230(200);
Since the plugin is most likely triggered in (default) (side) battle, but I also tried from $gameMap._interpreter , and nothing happened. I also tried to combine them with "waitMode" function with the "animation" parameter, and all the combinations with those, even straight in console, with no plugins on, and it does nothing, not even show some error.
I also tried playing with the parameters in new Game_Interpreter();
I'm out of ideas on what to try, I know the native JS ones would freeze the game completely, so how can I emulate the "Wait" command from the editor in a plugin?
To pause the map's main interpreter for 200 frames:
Code:
$gameMap._interpreter.wait(200);
Note this won't affect parallel events (they each have their own interpreter). It adds 200 to the wait counter, which gets -1 per frame. When the wait counter reaches zero, the interpreter moves onto the next command in its list.

Since this is in Learning JS I'll add that command230 takes no inputs (source rpg_objects.js):
Code:
// Wait
Game_Interpreter.prototype.command230 = function() {
    this.wait(this._params[0]);
    return true;
};
To pause the map's main interpreter for 200 frames:
Code:
$gameMap._interpreter.wait(200);
Note this won't affect parallel events (they each have their own interpreter). It adds 200 to the wait counter, which gets -1 per frame. When the wait counter reaches zero, the interpreter moves onto the next command in its list.

Since this is in Learning JS I'll add that command230 takes no inputs (source rpg_objects.js):
Code:
// Wait
Game_Interpreter.prototype.command230 = function() {
    this.wait(this._params[0]);
    return true;
};
Yeah, I tried 230 out of despair of it not doing anything.

The plugin is about some notetag modified skill effects, which also have one animation. So far, the full skills and the animations work fine both inside battle and outside battle. Some of the animations include tainting the screen and the like, but I need it to wait until the end of the animation before continuing the battle (if in battle) or the movement (if on map). The only "new Game_Interpreter"s in project/js, are on Game_Event.prototype.setupPageSettings, Game_CommonEvent.prototype.refresh, Game_Map.prototype.initialize and Game_Troop.prototype.initialize.
The first one is for event runs, not for battles or skill use on map. The second one is for common events, the third is meant to be for the map, but nothing happens, and Game_Troop is pretty much the opponents in battle.
Which one should I use?
Should I add a interpreter on $gameActor instead or something? (I thought about it, but I still didn't try)
Yeah, I tried 230 out of despair of it not doing anything.

The plugin is about some notetag modified skill effects, which also have one animation. So far, the full skills and the animations work fine both inside battle and outside battle. Some of the animations include tainting the screen and the like, but I need it to wait until the end of the animation before continuing the battle (if in battle) or the movement (if on map). The only "new Game_Interpreter"s in project/js, are on Game_Event.prototype.setupPageSettings, Game_CommonEvent.prototype.refresh, Game_Map.prototype.initialize and Game_Troop.prototype.initialize.
The first one is for event runs, not for battles or skill use on map. The second one is for common events, the third is meant to be for the map, but nothing happens, and Game_Troop is pretty much the opponents in battle.
Which one should I use?
Should I add a interpreter on $gameActor instead or something? (I thought about it, but I still didn't try)
First, some clarifications about the different event command interpreters:
  • There is no skill use on the map by default, only through the pause menu which is a separate scene.
  • The Game_Event and Game_CommonEvent interpreters are both purely for parallel events, as I mentioned.
  • The Game_Map interpreter is the event queue for non-parallel map events.
  • The Game_Troop interpreter handles troop events.

For your implementation: one option is a delayed callback approach, e.g. Promise (ES6) or setTimeout. This is probably the easiest method and completely bypasses the whole command interpreter thing! After all, you just need it to work, right? 😮‍💨

Alternatively you could work to integrate your process more firmly with the existing procedures. While I don't think you'd gain any notable functionality doing things this way, I feel it's technically a better approach (in terms of compatibility, at least). I think it would involve making aliases of Sprite_Animation methods (sprites update each frame based on their parent object, one-way association). Maybe set a flag before starting the animation then checking that flag in an alias of the sprite's remove method? I haven't really played around much myself with sprite stuff, sorry. 😅

Also: battles are ultimately controlled by the BattleManager, which allows the troop interpreter to run whenever there's a free moment. If you're just making some follow-up skills or something, you may be better off calling the native forceAction methods rather than working around them. 😴

Original thread: https://forums.rpgmakerweb.com/threads/how-can-i-make-the-game-wait.108350/