How to call page using script in Set Move Route?

Here is what needs to happen: a character event keeps on running toward the right until he passes a "finish line", at which time something happens (He cheers or something. What he does is not important.)

I know in Movement->Set Move Route event there is a "Script" call. In the move route, I will have the event repeatedly move right and calling Script. My idea is that in the script it indicates if the event's x is greater than a certain number (the finish line x), then run the event's page of actions.

How can I write something like this? What do I write in the Script box?

Thanks!
You can add a second page with the commands you want to run and a self-switch A condition, then, in the move route of the first page, you add this script:

Code:
if self.x >= 10  $game_self_switches[[$game_map.map_id, @id, "A"]] = trueelse  move_straight(6)end
Change the number 10 by the X position where you want to trigger the commands.
Thanks! This helped a lot!

Original thread: https://forums.rpgmakerweb.com/threads/how-to-call-page-using-script-in-set-move-route.42444/