Move route script to check if a switch is true?

Martin

Veteran
Veteran
Joined
Apr 8, 2015
Messages
162
Reaction score
34
First Language
swe
Primarily Uses
RMMV
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?
 

gstv87

Veteran
Veteran
Joined
Oct 20, 2015
Messages
1,893
Reaction score
893
First Language
Spanish
Primarily Uses
RMVXA
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.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
38,323
Reaction score
11,927
First Language
English
Primarily Uses
RMMV
You can leave out the === true
 

Martin

Veteran
Veteran
Joined
Apr 8, 2015
Messages
162
Reaction score
34
First Language
swe
Primarily Uses
RMMV
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
 
Last edited:

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
38,323
Reaction score
11,927
First Language
English
Primarily Uses
RMMV
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.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 3)

Latest Threads

Latest Posts

Latest Profile Posts

Oh, stop with the Melodrama...

...Listen to it instead!

anybody else like getting baked whilst coding?

When you go to the beach watch out for coconuts. Coconuts are more dangerous than sharks. Fact.
Try to get into pixelart again, so far its a sucess.
Also finally found a useful pixeltutorial which helps a lot.
♫ Anyone knows an ant can't move a rubber tree plant, but he's got high hopes, he's got high hopes, he's got high apple pie in the sky hopes ♫

Forum statistics

Threads
93,615
Messages
913,982
Members
123,180
Latest member
tdominach
Top