Is it possilbe to use a variable in a switch? (script)

I am creating a lot of custom items that do various effects, and check certain switches are on for them to work.
if i can do this it saves a lot of work.

Below is an example of what I'm trying to do.
--------------------------------------------------------
$gameSwitches.setValue([$gameVariables.value(10)], true);

Set Variable 10 to 14
Set switch [Variable #10] to ON
Set switch 14 to On.


Thanks
While not directly from the "control switches" command, you can do this with a script command. All it will take is this:

$gameSwitches.setValue($gameVariables.value(<ID GOES HERE>), true);Just replace "<ID GOES HERE>" with the variable ID you want to use. In your case, you want to use 10, to get the value of variable #10. This will set the switch (in this case 14), to ON, as is indicated by "true". If you wanted to turn the switch to OFF, replace the "true" with "false". Make sure to keep those lower case, as JavaScript is a case-sensitive language, and it will get very upset if you don't keep them lowercase!
You almost had it:

$gameSwitches.setValue($gameVariables.value(10), true);
Though you don't need to do this in a script call - the Control Switches command lets you use a variable to identify what switch you want to change.
Thank you very much Zalerinian, and Shaz

that wil save loads of time.

I am super rusty with JS haven't used it much since college a long time ago.
 now if i can figure out a way for it to call the items name from the same variable it will make the item creation easy.
 
What do you need to do with the item's name?


And what item? You're talking about switches and variables here, not items. If it's an unrelated question, please start a new thread for it.

Original thread: https://forums.rpgmakerweb.com/threads/is-it-possilbe-to-use-a-variable-in-a-switch-script.49140/