Event Changing Direction after reaching X/Y

Let me explain first what I am trying to do; I am making a vehicle move in one direction across a road in a custom move route using a pixel-movement script, and change the direction of the vehicle when it reaches the point, I actually DID make it work using this script call in the move route: 

set_direction(6) if @x == 11 && @y == 32

HOWEVER because it is pixel movement, it moves forward one time and checks the script, repeating over and over so it moves like choppy/laggy because it stops to check the script.
Is there any way I can do this? Maybe there's a script call that doesn't stop the event? Really need this, thanks in advance!
This would probably work.

Spoiler
Capture.PNG



The 11 there is just the map x (or y) that you want the event to reach. The second page is set to 'Self Switch: A is ON' where whatever you want to happen happens after that point is reached.
Oh yeah that seems pretty good, but being a parallel process would probably make it laggy, wouldn't it? There will probably be around 3-4 vehicles roaming around which is why I went with the move route way, also if I make it parallel process I can't think of a way to make the event "kill" the player when it touches him, forgot about that too.
You could just have the move route of the vehicle go until it reaches the desired x and/or y. Set the priority as 'same as characters' and the trigger 'player touch', where the event page is the desired effect, such as a game over.
And how do I do that exactly?  Move forward if X =! 11 and Y =! 20? I mean how do I write that in the script? I'm not good at all at scripting
Spoiler
Capture.PNG
Yeah I know how to do that, but I want it to repeat move right until it reaches and X/Y (for example) like you did before (think like a conditional branch within the move route with a Script)
You didn't show us your original event or link the script you're using so there may be a lot of important details I'm missing here.


Anyway, try something like this within the event's Autonomous Movement.


Locate Script..., the last item on the last column, insert this into the box, and change/remove the coordinates as needed.


case [x, y] when [1,1] ; move_straight(6) when [14, 1] ; move_straight(2) when [14, 11] ; move_straight(4) when [1, 11] ; move_straight(8) else move_forward end


By default, the event should move in a square so long as you place it correctly.
THANK YOU Rinobi! That was it, works like a charm!! I really appreciate and will for sure credit you when I finish this.
Thanks to both of you.

One last thing though, what do I type in to activate a switch when it reaches a certain X/Y too? when [14,1] ; $game_switches(40) ? Something like that. (Or a self-switch for that matter)

(For example, a car reaches a stop sign and activates a switch, while on this switch you can interact with the car, I have something that accomplishes this task but sometimes events get on the way and it stops before it should)
You're close. The syntax for turning that global switch on would be:


when [14, 1] ; $game_switches[40] = true




As for self switches, it depends on if you're setting the switch within the event page, within the move route, or somewhere else.

Code:
$game_self_switches[[@map_id, @event_id, "A"]] = true # Turn self switch A on within an event's pages.

$game_self_switches[[$game_map.map_id, id, "A"]] = true # Turn self switch A on within an event's move route

$game_self_switches[[4, 8, "A"]] = true # Turn self switch A on for event 8 on map 4
Thank you so much. This can be closed now.

Original thread: https://forums.rpgmakerweb.com/threads/event-changing-direction-after-reaching-x-y.64549/