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,221
Reaction score
1,629
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
 

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

Latest Threads

Latest Posts

Latest Profile Posts

rux
MUCLSES!!! :epicface: :epicface:
I have trauma after accidentally stumbling upon vore CYOA on text adventures and then reading the description "unwilling and willing" "one half lives inside other half" Oh my.... And peoples comments... "please add pregnant" "very good" "the best vore CYOA ive ever seen"...what...I wanna vomit, seriously. Its horrible.
If you're reviewing someone else's game, don't focus only on the negative and criticize them. Use positive constructive feedback. As game developers, we need to empower one another; not put each other down.
just posted a song I made for my game a while back... I sampled the HEY from Earthworm Jim's Snot a problem levels lol...
Based on this screenshot alone, which one would you sell, and which to equip?

Forum statistics

Threads
107,484
Messages
1,030,014
Members
139,613
Latest member
jackkhan
Top