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,469
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,219
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



A recent screenshot that I also shared on Reddit and the likes, links in my signature if you want to follow :)


I am starting to get a hang of this parallaxing mapping business. Still inexperienced, but at least I can be a lot more creative now :)
Catching up on some anime I never finished . . . "This Day × And × This Moment" . . . first time I shed a tear watching something.
oh frisk i wont be able to jog for at least 2 weeks ;-; its like a nightmare
It was my birthday yesterday woooo /) ~ 3 ~)/)~~

Forum statistics

Threads
107,415
Messages
1,029,526
Members
139,539
Latest member
Sylphia
Top