MZ Javascript for Set Movement Route (wait) in MZ

I'm probably missing something obvious to a person experienced with Javascript, but I'm having trouble getting the script for Set Movement Route (Wait) from the "RPG MAKER MV / MZ Script Calls" database to work.

Basically in the long run I want to be able to do a Movement route for an event that is referenced by an in game variable. To start, I'm just trying to get event 2 in my debug map to take a step away from my player. This is the code I have so far in a script:
Code:
const self = interpreter;
const char = self.character(self._characterId = 2);
var list = [];
list.push({ code: Game_Character.ROUTE_MOVE_AWAY });
list.push({ code: Game_Character.ROUTE_END });
var route = {list:list, repeat:false, skippable:false};
char.forceMoveRoute(route);
this.setWaitMode('route');

I can of course get the event to move away without waiting using
Code:
$gameMap.event(2).moveAwayFromPlayer();

However, I'd like to know how to properly do a javascript movement route with wait.
Thanks for your time.
For what do you want to wait? If there is nothing to wait for, then nothing will happen.

In the RM-Engine, Wait is NOT a time-based function.

Example: If you have a parallel process map event, then a wait inside that PP is basically telling the engine "skip processing this event in the main game loop for x loops/frames", which is why waits in the parallel processes reduce lag and they only look like pauses if used in action button events.

The wait mode in a set move route command basically makes the calling event wait for the signal that the move route created is complete, and that signal is what you activate with the wait mode.
But you need something to wait for that signal to have any effect.

Unfortunately I can't tell you how it is done correctly - I never used MZand steered away from that level of scripting in the older makers, exactly because I know how complex the timing in the main game loop can get...
For what do you want to wait? If there is nothing to wait for, then nothing will happen.
sorry for hijacking this thread a lil, but that came at me a lil different meta way ha ha ha
Assume the command is the same as in MV:
{code: Game_Character.ROUTE_WAIT, parameters: [35]}
Hmmm, if you just follow the script call list instructions, it worked for me:

const self = this;
const char = self.character(self._characterId = 2);
let list = [];
const moveAway = Game_Character.ROUTE_MOVE_AWAY;
list.push({ code: moveAway });
list.push({ code: Game_Character.ROUTE_END });
const route = { list: list, repeat: false, skippable: false };
char.forceMoveRoute(route);
self.setWaitMode('route');
Hmmm, if you just follow the script call list instructions, it worked for me:

const self = this;
const char = self.character(self._characterId = 2);
let list = [];
const moveAway = Game_Character.ROUTE_MOVE_AWAY;
list.push({ code: moveAway });
list.push({ code: Game_Character.ROUTE_END });
const route = { list: list, repeat: false, skippable: false };
char.forceMoveRoute(route);
self.setWaitMode('route');

So I now see it was this line I somehow misunderstood from the example.
Code:
const self = interpreter

...and that I misread this line in the RPG Maker Script Calls Document.
Code:
Game_Interpreter interpreter
  • Interpreter to pause (this in a Script command)

It's working now.
Thank you for your help, rpgLord69, appreciate it!

Andar and utunnels, thank you for taking the time to respond.

​

Original thread: https://forums.rpgmakerweb.com/threads/javascript-for-set-movement-route-wait-in-mz.177756/