Scripted event movement route teleports instead of moving

I'm scripting a movement route for a series of events in a cutscene. The cutscene needs to be able to switch out different events for the "actors" in the cutscene, and so I need to use a script to run it instead of setting a movement route the way I normally do. However, when I try to run the scene, the moving event only appears for the last movement route set, although it does teleport in the proper place. Can someone advise on how to keep the event visible for the entirety of the movement route? Here is the code governing the movement of one of the actors: it should move the event as follows:

Left 2, Up 1, Left 2, Up 1, Left 1, Up 1, Left 1, Up 1, Left 1, Up 2, Left 1

Code:
$gameMap.event($gameVariables.value($gameVariables.value(31)) [1]-2).moveStraight(4);
$gameMap.event($gameVariables.value($gameVariables.value(31)) [1]-2).moveStraight(4);
$gameMap.event($gameVariables.value($gameVariables.value(31)) [1]-2).moveStraight(8);
$gameMap.event($gameVariables.value($gameVariables.value(31)) [1]-2).moveStraight(4);
$gameMap.event($gameVariables.value($gameVariables.value(31)) [1]-2).moveStraight(4);
$gameMap.event($gameVariables.value($gameVariables.value(31)) [1]-2).moveStraight(8);
$gameMap.event($gameVariables.value($gameVariables.value(31)) [1]-2).moveStraight(4);
$gameMap.event($gameVariables.value($gameVariables.value(31)) [1]-2).moveStraight(8);
$gameMap.event($gameVariables.value($gameVariables.value(31)) [1]-2).moveStraight(4);
$gameMap.event($gameVariables.value($gameVariables.value(31)) [1]-2).moveStraight(8);
$gameMap.event($gameVariables.value($gameVariables.value(31)) [1]-2).moveStraight(4);
$gameMap.event($gameVariables.value($gameVariables.value(31)) [1]-2).moveStraight(8);
$gameMap.event($gameVariables.value($gameVariables.value(31)) [1]-2).moveStraight(8);
$gameMap.event($gameVariables.value($gameVariables.value(31)) [1]-2).moveStraight(4);

Thank you!
The issue you are having is that the script call is evaluated and tries to run everything within it all at once without waiting, making it look like it is teleported.

You need to use separate event commands or find a way to work with it since you are not using a move route (which normally completes one move at a time before going to the next command).

You could create a loop that might work. This is one way to do it - I still recommend a move route if that is possible.

I'll type it out to look like the editor's event commands since I am not at a computer:
JavaScript:
◇Script : $gameTemp._tempArr = [4, 4, 8, 4, 4, 8, 4, 8, 4, 8, 4, 8, 8, 4];
:       : $gameTemp._count = 0;
◇Loop
  ◇Script : const v = $gameVariables;
  :       : const t = $gameTemp;
  :       : const e = $gameMap.event(v.value(v.value(31))[1] - 2);
  :       : e.moveStraight(t._tempArr[t._count]);
  :       : t._count++;
  :       : this.wait(2 ** (8 - e.moveSpeed()));
  ◇If : Script : $gameTemp._count === $gameTemp._tempArr.length
    ◇Break Loop
    ◇
  : End
  ◇
: Repeat Above
◇
Here are the script calls separated for your convenience:
JavaScript:
// First Script
$gameTemp._tempArr = [4, 4, 8, 4, 4, 8, 4, 8, 4, 8, 4, 8, 8, 4];
$gameTemp._count = 0;

// Loop Script
const v = $gameVariables;
const t = $gameTemp;
const e = $gameMap.event(v.value(v.value(31))[1] - 2);
e.moveStraight(t._tempArr[t._count]);
t._count++;
this.wait(2 ** (8 - e.moveSpeed()));

// If Script
$gameTemp._count === $gameTemp._tempArr.length - 1
Please test since this was done on a phone lol... as with a lot of my code, I am not usually home or on the laptop/computer.
Thank you for your response. I was able to put the commands into a movement route, which separates them so each step is sequential as described in your script. However, they still execute insanely fast, and adjusting the move speed/frequency does not change it.
Thank you for your response. I was able to put the commands into a movement route, which separates them so each step is sequential as described in your script. However, they still execute insanely fast, and adjusting the move speed/frequency does not change it.
Can you show me a screenshot of what you did? Please make sure you are using the correct event commands as shown above rather than putting everything into one script call. (The bottom script call was for copying convenience only)
It's a little difficult since it's such a wide script. But here it is:

1737851916906.png
1737851968131.png


I've also tried adding
Code:
$gameMap.event($gameVariables.value($gameVariables.value(31))[0] - 2)._waitCount = 2 ** (8 - $gameMap.event($gameVariables.value($gameVariables.value(31))[0] - 2).moveSpeed())
between the movement commands, which should cause it to pause between movement, but it hasn't helped.
It's a little difficult since it's such a wide script. But here it is:

View attachment 329825View attachment 329826

I've also tried adding
Code:
$gameMap.event($gameVariables.value($gameVariables.value(31))[0] - 2)._waitCount = 2 ** (8 - $gameMap.event($gameVariables.value($gameVariables.value(31))[0] - 2).moveSpeed())
between the movement commands, which should cause it to pause between movement, but it hasn't helped.
Have you tried the code I gave you? That should work the way you are wanting, I believe.
That does work. Thank you!

Just so I know for the future, how would you recommend using that base to run simultaneous action/waiting for completion? Would it be best to make multiple _temparrays?
That does work. Thank you!

Just so I know for the future, how would you recommend using that base to run simultaneous action/waiting for completion? Would it be best to make multiple _temparrays?
I can't say for sure since every situation is different. You don't always have to make arrays/objects - I like using them because they make more sense to me and cleans up a lot of the code for my move routes.

$gameTemp properties don't get saved, you can re-use temp arrays as much as you want. Feel free to use game variables if you like using event commands as well.

I usually have one or two to use for when I need them temporarily across different lines of code. When you are done, you can empty it out with = [] or = null and just reassign as needed.

If you find yourself using it a lot, I recommend putting it in a common event.

So long as it works the way you want, I say go for it.
Much appreciated. Thank you!

Original thread: https://forums.rpgmakerweb.com/threads/scripted-event-movement-route-teleports-instead-of-moving.174948/