I read the
MV / MZ Script Call List and got to know the setWaitMode thing. So I tried inserting the
in different ways. But it always doesn't work.
Did I do something wrong? /-;
Script call/evals process the entire chunk of code all at once. By putting a message below the .setWaitMode(), that message consequently also shows up in the same process along with the previous message.
Use a new script call after each .setWaitMode() function.
Script call 1:
JavaScript:
$gameMessage.add('Choose?');
// Set choices, no cancel
$gameMessage.setChoices(['Option 1', 'Option 2'], 0, -1);
// On choice, set variable #1 equal to the selected index
$gameMessage.setChoiceCallback(n => {
$gameVariables.setValue(1, n + 1);
});
// Wait for a choice to be selected
this.setWaitMode('message');
Script call 2:
JavaScript:
$gameMessage.add(`You chose Option ${$gameVariables.value(1)}.`);
this.setWaitMode('message');
Script call 3:
JavaScript:
$gameMessage.add('After waiting, this text will appear last.');
this.setWaitMode('message');
Overall, if you can use the event commands, it would be a lot more efficient and the timing is easier to grasp.
Wait commands just delay the specific interpreter and the code that follows it, giving the appearance of "waiting" for the player.
The command executes immediately and goes to the next line of event commands in the event (which is why you can throw a selfswitch early on in the code and if you do not provide a condition to avoid the rest of the code below it, it will still run everything in that event.) However with the event commands, it goes line by line. In a script call chunk, everything inside it executes at once (eval).
In the case of .setWaitMode('message'), what it does is check if $gameMessage is busy, if so, hang out for a bit until it isn't busy anymore. However, make sure you complete all your tasks in the call while you wait.
All wait-type commands in a script call need its own script call because of that (at the very least, make it the last command so you can see your workflow).