MV How to make a script pause ?

I have a problem. I rewrote the gameMessage.setNumberInput function and it now works as I want it to work (instead of taking the number of digits you want, it takes the max number you're authorized to input.) Unfortunately, the script keeps moving forward (or just executes everything simultaneously ?). I need it to pause until it the player actually inputs his number. For example, at the end of the event, I check if a variable (not a gameVariables) is set to 0, if not, it goes back to the first label. Unfortunately, instead of waiting for my variable to be changed after my setNumberInput function, it does the check immediately and of course, my variable can't reach 0 at this point. How can I make the script wait for the number input ?
Hello welcome!
Without seeing your modification, we have no way of knowing where the error is or what is the best method to avoid falling out of the pattern you want.
By default, Game_Interpreter will set the wait mode to "message" when you use an Input Number command.

When the wait mode is set to "message", it will use $gameMessage.isBusy() to check if it's still waiting. This in turn will call this.isNumberInput() among other things to tell the Game_Interpreter to wait.

My guess is that you broke the Game_Message.prototype.isNumberInput() function.

But without seeing your actual code, we can't say for certain if that's the problem or not.
I don't think the problem is from the changes I made in the code because the original function has the same issue (I just tested it on an other project).

For example for:
script :
$gameMessage.setNumberInput(1, 5);
$gameMessage.add($gameVariables.value(1));
myNumber -= $gameVariables.value(1);

If: Script: myNumber == 10;
Text: This is the text

The game will show the message with a 0 because it doesn't wait for the process to be completed to display $gameVariables.value(1) and then, after I input a number it will also enter into the condition, even though myNumber (that was set at 10 in a plugin) can't be equal to 10 anymore.

The only way I found to avoid that is a bit annoying. I have to put a Text just after $gameMessage.setNumberInput(1,5).
I don't think the problem is from the changes I made in the code because the original function has the same issue (I just tested it on an other project).

For example for:
script :
$gameMessage.setNumberInput(1, 5);
$gameMessage.add($gameVariables.value(1));
myNumber -= $gameVariables.value(1);

If: Script: myNumber == 10;
Text: This is the text

The game will show the message with a 0 because it doesn't wait for the process to be completed to display $gameVariables.value(1) and then, after I input a number it will also enter into the condition, even though myNumber (that was set at 10 in a plugin) can't be equal to 10 anymore.

The only way I found to avoid that is a bit annoying. I have to put a Text just after $gameMessage.setNumberInput(1,5).
The reason for this is that all setNumberInput does is set the internal _numInputVariableId and _numInputMaxDigits properties, so you're doing that and then immediately adding a message. Then, if you look at Window_Message's update function:

JavaScript:
Window_Message.prototype.update = function() {
    this.checkToNotClose();
    Window_Base.prototype.update.call(this);
    while (!this.isOpening() && !this.isClosing()) {
        if (this.updateWait()) {
            return;
        } else if (this.updateLoading()) {
            return;
        } else if (this.updateInput()) {
            return;
        } else if (this.updateMessage()) {
            return;
        } else if (this.canStart()) {
            this.startMessage();
        } else {
            this.startInput();
            return;
        }
    }
};

It calls startMessage before it'll call startInput, so your message ends up being displayed before it has a chance to show the number input.
So you're saying that instead of executing the script in the order I give him, he executes all at once and therefore the function that displays a message is executed before the one that handles input numbers ? Is there a way to make it understand in what order you want things to be executed ?
My main problem here isn't that it displays the message but that it enters the condition before I had the opportunity to change myNumber value. The whole point of the script being to be able to use the number the player inputs to check if I enter in the condition or not.

Original thread: https://forums.rpgmakerweb.com/threads/how-to-make-a-script-pause.142035/