MZ Pause the Interpreter

Hi all!

I'm wondering if there is a way to hold the game interpreter until a plugin execution is finished.

For example in the sequence:
- Show Message
- Call plugin command
- Show message

The last Show Message shouldn't be called until the plugin command is fully executed

I tried to add a new wait mode to the Game Interpreter by modding this:

JavaScript:
Game_Interpreter.prototype.updateWaitMode = function() {
    let character = null;
    let waiting = false;
    switch (this._waitMode) {
        case "message":
            waiting = $gameMessage.isBusy();
            break;
        case "transfer":
            waiting = $gamePlayer.isTransferring();
            break;
        case "scroll":
            waiting = $gameMap.isScrolling();
            break;
        case "route":
            character = this.character(this._characterId);
            waiting = character && character.isMoveRouteForcing();
            break;
        case "animation":
            character = this.character(this._characterId);
            waiting = character && character.isAnimationPlaying();
            break;
        case "balloon":
            character = this.character(this._characterId);
            waiting = character && character.isBalloonPlaying();
            break;
        case "gather":
            waiting = $gamePlayer.areFollowersGathering();
            break;
        case "action":
            waiting = BattleManager.isActionForced();
            break;
        case "video":
            waiting = Video.isPlaying();
            break;
        case "image":
            waiting = !ImageManager.isReady();
            break;
    }
    if (!waiting) {
        this._waitMode = "";
    }
    return waiting;
};

by adding a new case "plugin" that would check on a plugin boolean.
On the plugin command it would be called the setWaitMode to "plugin" but it doesn't work
by adding a new case "plugin" that would check on a plugin boolean.
On the plugin command it would be called the setWaitMode to "plugin" but it doesn't work
It would help if you showed us exactly how did you try to do it, because it generally is the simplest way of doing that. Well, either that or adding a new "indefinite" mode that's always true, and setting wait mode to "" when you're done.
My bad, I was trying to set it from Game_Interpreter.setWaitingMode instead of $gameMap._interpreter.setWaitMode();

What caught me off guard is that I didn't get any error message from the plugin!
What caught me off guard is that I didn't get any error message
Welcome to JavaScript development 😛
"Wait, how did this not produce any errors?" is a question you'll be asking yourself quite often.
In a plugin command you can just use this for the current interpreter reference. That also solves problems related to using a plugin command in a Parallel event, because those don't run in the main interpreter.

Note that arrow functions do not have their own this value. You can declare your plugin command as a standard function if necessary.

Original thread: https://forums.rpgmakerweb.com/threads/pause-the-interpreter.169837/