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 Profile Posts

My computer broke yesterday, so no RPG maker for at least a week until I can get it repaired. :(
Just wanted to share how my game won 1st place in a game jam for itch.io. Everyone else used Unreal, Unity, GMS2, Godot, etc but I used RPG Maker 2003 :guffaw: It just shows that you can create a good game and it doesn't matter which engine you use
Working on cutscenes~

if your game is the first (or ONLY) in a series and still has a colon in its title, you are a bad person and I hate you...... jk.

who could ever hate BETWEEN: TWO SOULS?

Forum statistics

Threads
107,404
Messages
1,029,443
Members
139,503
Latest member
cheesepot
Top