Script call for wait command.

Hi! I was reviewing the script call list for the scriptcall wait.
It says $gameInterpreter.wait(frames); but when I use it, it comes with $gameInterpreter is not defined.

Am I missing something? this looked like one of the simplest things.

Thanks!
There is no $gameInterpreter. Names preceded by a $ are global variables, but Game_Interpreter is a class used to define a variable during an event command (not globally).

Wait is actually a pretty complicated command, since it involves multiple functions. Why are you trying to use a script call to create a wait command?
Im calling two animations from script, I need one to finish then start the other. Or is there a call like wait animation to finish?
I've been trying to figure this out for a while, but no luck yet. Would love to know if other people know the answer 🙂

My workaround is to call a common event and then include the animation with wait command in that.
Yeah, apparently is not that simple. Now, I cant call a common event because the animations are in battle, so i cant specify target or user as origin source. I might force a skill though, but it would be very usefull to know how to do "wait" via script. If anything, Ill let you know.

Cheers!
It is not simple because there is no wait command at all, the wait command works differently internally and is only called "wait" because that is how the effects looks to the player. Otherwise you wouldn't be able to use "wait" to reduced lag in parallel processes for example.

There is a game loop that is executed every frame. This loop contains every parallel process, every active event, every move route, every update function and so on as its elements.

What the wait command does is tell the game loop "skip processing this element for the next x loops". Or in case of the "wait for completion" options it tells "skip processing until that other element is completed".

As such the wait can never be a command, it is always a property of an element inside the game loop. If you have that element or object, you can set its property by script - but you need an object inside the game loop for that to work at all.
This is very old, but I'm answering because maybe someone is developing a game today and has a similar question.

I've dealt with the Game_Interpreter and it seems to have somewhat complex logic. It's easy to wait for a message, but not for an animation. So you have to implement this waiting yourself.

What I'm saying requires you to understand a little bit of JavaScript and create your own plugin, but don't be scared, in essence creating a plugin is just saving a JavaScript file (.js) in the plugins folder, activating it in RPG Maker and that's all, with that the code written in it will be executed.

All Game_Characers (events, the player, etc.) have an update function that is called 60 times per second (once per frame), and they also have the boolean operation isAnimationPlaying, which indicates whether that character is currently running an animation or not. You must override the update option so that when the animation in question is running, the other animation is not launched.

You can simply query isAnimationPlaying and when it returns false then you use requestAnimation on the event you want the next animation to play.

It could be optimized a little more, since adding it to update will cause the check to be done throughout the game, even when you are no longer interested in the matter, but it is a way.

In the following code I override the update operation of Game_Map instead of Game_Character. This is because the map will update 60 times per second, but if I were to override update in Game_Character, this would be done 60 times per second for each event existing on the map, and doing all this checking every time for each event is nonsense. Even this code could be improved further, but I tried to make it clear rather than optimal.

This must be tested in a .js file on plugin folder, not in a script call.

JavaScript:
//Reference to the original update function
var firstAnimationDone = false, secondAnimationDone = false;
var firstAnimationStart = false, secondAnimationStart = false;
var _Game_Map_update = Game_Map.prototype.update;
Game_Map.prototype.update = function(sceneActive) {
    //Call normal map update function
    _Game_Map_update.call(this,sceneAtive);
    
    //Check animation. In this example the animation is over the player ($gamePlayer).
    //We must to know the ID of animations to run, in this example the first animation
    //is the numnber 1 and the second is the number 2. The animation ID can be shown
    //in RPG Maker animations on Data Base.
    if(firstAnimationDone==false){
        $gamePlayer.requestAnimation(1); //Start first animation.
        firstAnimationStart = true;
    }
    
    //Check if first animation is done.
    if(!$gamePlayer.isAnimationPlaying() && firstAnimationStart){
        firstAnimationDone = true;
    }//Check if second animation is done.
    else if(!gamePlayer.isAnimationPlaying() && secondAnimationStart){
        secondAnimationDone = true;
    }
    
    //Check if first animation has done and if we must start the second.
    if(firstAnimationDone && !secondAnimationStart){
        $gamePlayer.requestAnimation(2); //Start second animation.
        secondAnimationStart;
    }
}

Original thread: https://forums.rpgmakerweb.com/threads/script-call-for-wait-command.89778/