wait for completion script?

Hey guys,

Ive noticed with scripts like: $gameMessage.add("text");, and $gameScreen.movePicture(1, 0, 5*48, 4*48, 50, 50, 255, 0, 16); that they dont wait for completion like the event commands option. Is there supposed to be some kind of general text you can add to the scripts to make them "wait for completion", because id like to know how, and i cant find it anywhere.
There is a function in rpg_objects inside MV's Game_Interpreter object. However, its implementation is only possible for small amount of cases, because this time we have Game_Interpreter, but we don't have any $gameInterpreter 😀
Anyway, event commands are called via Game_Interpreter prototype. So since this object also has a method called setWaitMode
Code:
Game_Interpreter.prototype.setWaitMode = function(waitMode) {
    this._waitMode = waitMode;
};
you can call this in a script field:
Code:
this.setWaitMode(waitMode);
The list of wait modes is hidden inside updateWaitMode.
Code:
Game_Interpreter.prototype.updateWaitMode = function() {
    var 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':
        waiting = this._character.isMoveRouteForcing();
        break;
    case 'animation':
        waiting = this._character.isAnimationPlaying();
        break;
    case 'balloon':
        waiting = this._character.isBalloonPlaying();
        break;
    case 'gather':
        waiting = $gamePlayer.areFollowersGathering();
        break;
    case 'action':
        waiting = BattleManager.isActionForced();
        break;
    case 'video':
        waiting = Graphics.isVideoPlaying();
        break;
    case 'image':
        waiting = !ImageManager.isReady();
        break;
    }
    if (!waiting) {
        this._waitMode = '';
    }
    return waiting;
};

For messages therefore the script command will be
this.setWaitMode('message');
I'm not sure if one of them is for image scrolling, since I don't use image scrolling at all. But if there is, you should be able to find it.
@Poryg Hmm, ''this.setWaitMode('hey');'' doesnt seem to bring in any results and if I do ''this.setWaitMode($gameMessage.add("text"))'', it doesnt do anything either, But that doesnt matter - I think i can probably find out the right solution with all the information youve given in your reply. if I cant manage to find out how to make it work after trying some options when i find time, ill post again.
this.setWaitMode('message');
@Poryg haha, i wasnt sure how to implement it properly, but its ''$gameMessage.add("text"); this.setWaitMode('message');'' doh. I thought i had to put it inside the brackets. Well that solves that
Sometimes happens, scripting is always trial and error 😀 And comparing how does an object look when it's occupied compared to when it's free.

Original thread: https://forums.rpgmakerweb.com/threads/wait-for-completion-script.94405/