Pure javascript event movement control question

I would like to control the movement of an event purely through javascript. Using Yanfly's movement plugin (YEP 124) I have the script command this.moveToPoint(x, y) seems like what I want but I get odd results because I don't know how to pass control back to the game's scene manager.

For example, I tried to do something like the following code:

Code:
    for (;;) {  // I want event to move until it reaches destination
      if (myEvent.x === destX && myEvent.y === destY) {
        break  // exit loop since destination reached
      }
      myEvent.moveToPoint(destX, destY, true) // step toward destination
      $gameMap._interpreter.wait(20) // let display catch-up
    }
but instead of seeing the event move smoothly towards the destination it looks like it teleports most of the way there and walks the last few steps. I think this is because the RMMV scene manager needs to take control to update the event location but of course my loop has control.

I know I can achieve the desired effect using event pages, self switches, and custom move route but I would like to know how to do this in pure javascript. Do I need to setup some kind of asynchronous function or something else?

Thanks.
Explanation
The interpreter handles every event command as a single entity. Script calls are passed whole into an eval, so the interpreter wait call does not get a chance to be applied until the for-loop is broken. Movements work by updating the character's integer tile coordinate to match the destination; the sprite position is then updated to reflect the appropriate position between tiles. This means you'll only see the sprite moving smoothly between tiles on the final step, when no other move commands are being prematurely applied.

Suggested Fix
Rather than try to work around the existing interpreter/move route system, it's probably easier to work with it. Try a script call along these lines:
Code:
var mx = 5, my = 8;  // target tile coordinates
var scr = 'if (!this.pos(' + mx + ',' + my + ')) this.moveToPoint(' + mx + ',' + my + '); else this._moveRoute.repeat = false;';
var lst = [{ code: Game_Character.ROUTE_SCRIPT, parameters: [scr] }, { code: Game_Character.ROUTE_END }];
var route = { list: lst, repeat: true, skippable: false, wait: false };
this.character(0).forceMoveRoute(route);
Basically, this gives the current event a repeating move route with a single line of script. The script checks whether it's at the destination: if not, it moves towards the destination, if it's there already then it tells the move route to stop repeating. The standard move route update stuff takes care of everything else~ 🙏
Thanks! That works perfectly.

Original thread: https://forums.rpgmakerweb.com/threads/pure-javascript-event-movement-control-question.107054/