moveStraight two times

Hello, could you please advise if there was an easy Javascript option to make an event move twice or more (without coordinates, or RPGMaker MV standard interface)?


A simple script executes the second line immediately (that is logically for JS): 


event1 = $gameMap.event(1);
event1.moveStraight(2);
event1.moveStraight(2);


I've already considered setTimeout or setInterval with if-s (presented below). It works, but I would like to learn a simpler option if there is any.


event1 = $gameMap.event(1);
event1.moveStraight(2);
var moveInterval;
moveInterval = setInterval(function()
    {
        if(event1.isMoving() == false)
        {
           event1.moveStraight(2);
           clearInterval(moveInterval);
        }
      }, 100
);


Many thanks in advance!
$gameMap.event(x).moveForward();
The way move routes work is that the next move will not be executed until the first move has finished.  You lose that when trying to execute the commands directly in script.  If you want to simulate a move route with multiple steps, the best/easiest way is to actually create a move route.  Give it the list of commands to run, then apply it to the target.
$gameMap.event(x).moveForward();

Unfortunately, this works the same as moveStraight. Moreover, unlike moveStraight, it does not work if I trigger the Action-Button event that I want to move, although it works for any other event, including Action-Button ones.

The way move routes work is that the next move will not be executed until the first move has finished.

Thank you for the insight, but (if I understood correctly what you mean by 'move routes') I want to avoid RPGMaker Event Commands for a case of multiple event moving simultaneously or with different timings. It is far convenient to use multiple plugin commands in 1 event than dealing with several event windows.
As far as making multiple events move, you can do that from a single event.  The Set Move Route command has a dropdown where you can select which event (or the player) you want to move.  You don't have to deal with several event windows, and we try to discourage that.


Can you explain what you are trying to achieve, and why you are doing it in script rather than events?  It may be that what you want to do can very easily be done with event commands, and if not, I'll at least have some background to be able to guide you further (ie - providing the logic to build a move route and apply it to one or more events, via script).
In fact, I completely forgot about the dropdown that selects an event/player!!! Of course, that is not what I planned, but may be a simpler solution.


In addition, as I see, I should also uncheck 'Wait for completion' if I want Event2 to move simultaneously with Event1.


Thank you very much for reminding!
Spot on!  Sometimes we can get so focussed on scripts that we forget, or don't discover, all the things the engine is quite capable of doing without them 🙂
Well, this method brought some issues with it.


I have several Plugin Commands in the Contents of the event,  something like:

Set Movement Route: This Event


                                    Move Down


Plugin Command: C1


Plugin Command: C2


Plugin Command: C3

If I set the 2nd movement route after these commands, the program does not wait for their execution, but moves the models immediately after the 1st route (actually, any inMaker command[balloons, choices, music, etc.] is executed immediately, despite Plugin Commands)


Is there a function to wait for command execution in the event Contents, other than looping a check of some permitting variable or placing 'wait' after each P-command?
Depends what your plugin commands are.  What the plugin is.  Whether it's set to do any waiting while the functions are running.  Can't really tell with what you've provided - if you need specific help you need to provide specific information, not something ambiguous like you have.  A screenshot of the event with those commands visible will be much more helpful.
Well, that's a bit complex to explain.


Sending the below commands into Contents result in sequential portions of text that appear after each other on clicking. The function simply aids in this.


The main reason for those commands is to have easy time with translation, i.e. use CAT-tools (e.g., SDL Studio) that are able to catch strings in a Javascript file.


So, if I send any in-Maker command after several plugin-commands, those additional commands are executed instantly during the first plugin-command in a list.
Just to resolve the above issue.


Execution of the Event Command that follow our Plugin Command can be stopped by simply setting Speed in "Set Movement Route" with Wait for Completion ticked.


E.g.: 

Spoiler
Plugin Command : nameOfOurCommand


Set Movement Route : Player (Wait)


        Speed : 4


Plugin Command : nameOfOurCommand2


Set Movement Route : Player (Wait)


        Speed : 4


Set Movement Route : Player (Wait)


        anythingElse

Original thread: https://forums.rpgmakerweb.com/threads/movestraight-two-times.64307/