Wait Command

So, I am designing a plugin, but I ran into a problem.  Is there any way to simulate the Wait command or at least wait for a picture to finish moving?

I understand that this command does not simulate it:

Game_Interpreter.prototype.wait(60);At the moment, what I have is this (imagine everything was already declared and set):

for(var i = 0; i < coordArray.length; i++){ $gameScreen.movePicture(id, origin, x, y, 100, 100, opacity, 0, 15); Game_Interpreter.prototype.wait(15);} I am all ears/eyes for information to fix my problem wait problem (as it isn't waiting for the image movement to finish).  This is the main thing stopping me from finishing my plugin.

P.S. I am still quite new to programming for RPG Maker MV, so I am probably making many mistakes (I have to familiarize myself with prototype, for example).
var i = 15;
if (i > 0) {


i++;


//waiting


} else {


//done waiting


}

Edit : var i outside for.
That isn't as easy as you think - because the wait is only called "wait" because that is the visible effect to a player (and sometimes to a developer if limited to eventing), but it is NOT what technically happens inside the game engine.

Everything inside the game is processed in the game loop, which runs once per frame for the entire game.

The wait command simply tells the engine "skip processing this event/sequence until x frames have passed" - it does not wait the computer at all.

That is why there is less lag if you wait on a parallel process event - without wait it will processed every frame, with wait it will skip frames in processing.

And any "wait for something" means that the engine is waiting for that something to remove the wait from the process that is being skipped - but a skipping process can't remove itself, because it isn't even processed during the skip.

If you loop or wait a process yourself, you'll wait the entire game loop - including display updates, pause animations and so on.

Doing that may even stop the move of the picture if you aren't carefull...
That isn't as easy as you think - because the wait is only called "wait" because that is the visible effect to a player (and sometimes to a developer if limited to eventing), but it is NOT what technically happens inside the game engine.

Everything inside the game is processed in the game loop, which runs once per frame for the entire game.

The wait command simply tells the engine "skip processing this event/sequence until x frames have passed" - it does not wait the computer at all.

That is why there is less lag if you wait on a parallel process event - without wait it will processed every frame, with wait it will skip frames in processing.

And any "wait for something" means that the engine is waiting for that something to remove the wait from the process that is being skipped - but a skipping process can't remove itself, because it isn't even processed during the skip.

If you loop or wait a process yourself, you'll wait the entire game loop - including display updates, pause animations and so on.

Doing that may even stop the move of the picture if you aren't carefull...
Thank you for that useful information.  I guess this proposes another question: knowing the wait problem, how does someone do menu animations or, for example, Yanfly's animations in his battle core?  Is there some other way to wait for the animation to complete, or is it simpler than that?
Just like andar said, all scripts are executed per frame using loop. The way the engine loop things on this case is using update method on each scene. For example, on Scene_Map and Scene_Battle, you can see a function call to update $gameScreen (which later will call a function to update every single instance of Game_Picture each frame). You might try to learn more about this update logic.

My advice is to set a counter variable to a specific value, attach your own update method to reduce that counter on each frame, and have a conditional to check wether your counter is already reach zero before doing your next routines.
 

for(var i = 0; i < coordArray.length; i++){ $gameScreen.movePicture(id, origin, x, y, 100, 100, opacity, 0, 15); Game_Interpreter.prototype.wait(15);} P.S. I am still quite new to programming for RPG Maker MV, so I am probably making many mistakes (I have to familiarize myself with prototype, for example).

A little bit about prototype. Most of the time, you don't call prototype directly. See yourself that you called $gameScreen.movePicture(args) instead of Game_Screen.prototype.movePicture(args).

Hope this could help.
Thank you for that useful information.  I guess this proposes another question: knowing the wait problem, how does someone do menu animations or, for example, Yanfly's animations in his battle core?  Is there some other way to wait for the animation to complete, or is it simpler than that?
You could make your update method check if an animation is playing, if yes you'd skip the parts which advance the flow of your scene. How to actually do it depends on which scene you want to do it for.


For the battle scene for example, if an animation is still playing you'd skip all parts of the update process which involves moving forward of the battle flow (dealing damage, picking next battler etc).
Ahh, thank you for your help everyone!  I only have two questions left:

1. Any tips on where the best location for studying the update methods?

2. I copied my log that was from my plugin: http://i.imgur.com/1rfPtkP.png

Unless I only need to study up on update methods, the update checks are hitting, but the picture is only instantly teleporting to the end point rather than transitioning.
transitioning needs the picture to be placed on every position between start and finish, distributed over the frames.


If you move the picture yourself, you need to calculate all those steps between and place the picture there manually - there is no automatic movement unless you program it.


That is what the game loop does - changing everything in tiny steps per frame.


(that also is why most people prefer to call the existing functions, those already have the step calculation programmed into the game loop)
To make it easier to calculate these steps and give alternatives besides "move at the same speed from a to b", you can use one of these easing functions: http://pastebin.com/Y6kMyksm
ninja'ed by two post, lol

anyway, you can look at rpg_objects.js line 1069 to see how Game_Picture algorithm update itself PER FRAME based on duration, target x, and target y.

@iavra: awesome! This would save a lot of my time since I'm kinda stupid with mathematical function!
transitioning needs the picture to be placed on every position between start and finish, distributed over the frames.

If you move the picture yourself, you need to calculate all those steps between and place the picture there manually - there is no automatic movement unless you program it.

That is what the game loop does - changing everything in tiny steps per frame.

(that also is why most people prefer to call the existing functions, those already have the step calculation programmed into the game loop)
Ahh!  I think I get it now!  So, the movePicture method doesn't actually test if the wait is complete, thus I would have to go by it frame by frame?

Original thread: https://forums.rpgmakerweb.com/threads/wait-command.54065/