Is there a way to turn on a switch == to a variable? So say I set variable X to 5, I can then later reference that variable to turn on the switch equal to that variable, in this case, turning on switch 5.
MV Turning on a switch # == to a variable
Javascript/Plugin SupportWith a script call, you can.
Just replace
JavaScript:
$gameSwitches.setValue($gameVariables.value(variableId), true);
Just replace
variableId with the actual numerical ID of your variable.Ah sweet, this is exactly what I needed, thanks!
Oh, one more thing. What would be the syntax to change that variable to the # of the current map?. Also, where can I find all these things so I can sift through them without having to ask on here?
Do you mean that you want to store the map ID inside a variable? If so, then you could do it like this:
Replace
Or are you saying that you still want to do the switch thing, but instead of using the variable for the switch ID, you want to use the current map ID for the switch ID? If so, then it'd be like this:
You can find a lot of useful script calls, with explanations and usage examples, on this spreadsheet.
JavaScript:
$gameVariables.setValue(variableId, $gameMap.mapId());
variableId with the actual ID of the variable that you want to use.Or are you saying that you still want to do the switch thing, but instead of using the variable for the switch ID, you want to use the current map ID for the switch ID? If so, then it'd be like this:
JavaScript:
$gameSwitches.setValue($gameMap.mapId(), true);
You can find a lot of useful script calls, with explanations and usage examples, on this spreadsheet.
Ah this code works! Thanks for the spreadsheet, this will help a lot as I try to figure out all this stuff ><
Are you using MV? The thread is tagged with it, but you don't actually say on your profile.
If so, I find this to be an extremely useful resource:
If so, I find this to be an extremely useful resource:
also, while not directly related to the question, it is oftentimes a good idea to simply put "console.log(this)" into a script and then see what the console spits out, because that gives you a lot of information about the context that script call is operating in. 😛
Original thread: https://forums.rpgmakerweb.com/threads/turning-on-a-switch-to-a-variable.148737/