Turning on switch based on variable

jlusco

Veteran
Veteran
Joined
May 29, 2016
Messages
33
Reaction score
63
First Language
Eng
Primarily Uses
I am trying to find a way to turn on a switch with the same numerical id as a variable.
For example, I use an item with an ID of 151 to trigger a comment even. The comment event sets the variable to 151 (this part I have already got working) I then want it to turn on switch 151 or if the Item is 152 it turns on switch 152 and so on. I can't figure out how to get it to turn on a switch in this manner. I know it will require a script call but I just cannot figure it out.
 

Kuro DCupu

Trust me, I'm a veteran RMer
Veteran
Joined
Jul 6, 2014
Messages
480
Reaction score
1,470
First Language
Indonesia
Primarily Uses
RMMV
Dunno bout MZ.
In MV, it will be $gameSwitches.value(switchID, $gameVariables.value(varID) == switchID)
 

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
2,227
Reaction score
1,634
First Language
EN
Primarily Uses
RMMZ
:kaohi: Note: value is for getting a value; setValue is for setting a value.

This should turn on the switch with ID equal to the current value of game variable 123:
JavaScript:
$gameSwitches.setValue($gameVariables.value(123), true);
Replace 123 with the ID of your variable. If you want to turn a switch off, swap the true for false.

This applies to MV and MZ, they both use the same internal structure for switches & variables. :kaothx:
 

jlusco

Veteran
Veteran
Joined
May 29, 2016
Messages
33
Reaction score
63
First Language
Eng
Primarily Uses
:kaohi: Note: value is for getting a value; setValue is for setting a value.

This should turn on the switch with ID equal to the current value of game variable 123:
JavaScript:
$gameSwitches.setValue($gameVariables.value(123), true);
Replace 123 with the ID of your variable. If you want to turn a switch off, swap the true for false.

This applies to MV and MZ, they both use the same internal structure for switches & variables. :kaothx:
That worked perfectly thank you so much
 

Latest Threads

Latest Posts

Latest Profile Posts

"Man is made by his belief. As he believes, so he is."-Krishna
FastFood in my country is neither fast nor cheap like it's expected to be, but people still buy a lot of it. I don't want to imagine how much of it people would eat if it was.
Started finishing up my bosses and characters...I don't know how long...but its going to take long...

I ended up needing to do a chapter one world map remake. It's still WIP but coming along nicely. =D
Stream will be live shortly! I will be beginning a play-through of Resident Evil 4! Feel free to drop by!

Forum statistics

Threads
107,753
Messages
1,031,897
Members
139,896
Latest member
Maybeacat
Top