Move route script to check if a switch is true?

Is something like this possible?
MOVE ROUTE:
if ($gameSwitches.value[209] === true) { this.requestBalloon(304); }

@Shaz I tried to take the region id script you gave me and do something else with it.

This time I want a balloon to pop up over event head with 300 wait.

I do want to do this check in the move route, but Im wondering if we can check switches and do if else in Moveroute?
possible, but not advisable..... it can get messy.
if you need a complex check for whatever reason, you can create a new object containing all your procedures, and then call them and send parameters to them via the move route.

instead of
if ($gameSwitches.value(209) === true) { this.requestBalloon(304); }

you can put that under Game_Character as
Code:
Game_CharacterBase.prototype.updateLocalBalloon = function() {
if ($gameSwitches.value(209) === true) { this.requestBalloon(304); }
};

and just call "updateLocalBalloon" from the move route.
as long as you wrap the check under a new procedure and make it a single call, it'll work.
You can leave out the === true
you can put that under Game_Character as
Code:
Game_CharacterBase.prototype.updateLocalBalloon = function() {
if ($gameSwitches.value(209) === true) { this.requestBalloon(304); }
};

Never done that before. Just paste this in the bottom of the file?



EDIT: changed to if ($gameSwitches.value(209)) { this.requestBalloon(1);}
And it now does what I wanted.

instead of if ($gameSwitches.value[209]) { this.requestBalloon(1);}

It sometimes confuses me that it needs to be like that. () instead of [] maybe food for a new topic but I sometimes wondering why
Because $gameSwitches.value is a function, not an array. In previous versions of the engine, you could just do $game_switches[id] because $game_switches, the class, had a method called [] which you could call directly, as if it were an array. MV does not.

Original thread: https://forums.rpgmakerweb.com/threads/move-route-script-to-check-if-a-switch-is-true.117265/