Turning on switch based on variable

jlusco

Veteran
Veteran
Joined
May 29, 2016
Messages
33
Reaction score
62
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,226
Reaction score
1,633
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
62
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

I have no idea why some of the program "splash screen" always on top. E.g, RMMZ loading screen stuck on the top blocking anything I want to do until it fully loaded. What is even the purpose?
One of the secret places in the game.
Had a dream last night that I died -- what a way to start the weekend! :'D
For some reasons, my signature was replaced by god-knows-what, written in French. Had to re-replace it with my signature Nazeem-ish quote; not gonna remake my signature any time soon.
2021? I still wonder if people still doing MV than MZ more

Forum statistics

Threads
107,635
Messages
1,031,049
Members
139,754
Latest member
vituvitu
Top