Check multiple switches

Hi, is there a way to do something only if multiple switches are on?
For example if Switch 1 and Switch 2 and Switch 3 and Switch 4 are all on, then do something.
Else do something else.
If: ($gameSwitches.value(1) && $gameSwitches.value(2) && $gameSwitches.value(3))
if you want to do it with events alone, you could use nested conditional branches.

for a larger number of consecutive switches, a looped script might be an alternative as well.

but on the deepest logic level all switches need to be checked one after another, you sometimes just automate that in a loop or array construct instead of manually checking each single switch.
If: ($gameSwitches.value(1) && $gameSwitches.value(2) && $gameSwitches.value(3))
Thank you so much! It worked!
if you want to do it with events alone, you could use nested conditional branches.

for a larger number of consecutive switches, a looped script might be an alternative as well.

but on the deepest logic level all switches need to be checked one after another, you sometimes just automate that in a loop or array construct instead of manually checking each single switch.

What is a looped script?

What is an array construct?
Loop and array are terms from logic/programming.
If you don't know enough about programming to recognize them, then don't bother trying to use them until you have much more experience in that area.
In case you need to test a lot of switches, you can also put this in an if:
Code:
[1, 2, 3, 4].every(x => $gameSwitches.value(x))
Feel free to add as many numbers as needed, separated by commas. As a bonus, you can replace every with some to test if at least one switch from the group is true.
In case you need to test a lot of switches, you can also put this in an if:
Code:
[1, 2, 3, 4].every(x => $gameSwitches.value(x))
Feel free to add as many numbers as needed, separated by commas. As a bonus, you can replace every with some to test if at least one switch from the group is true.

So would this do the stuff in the if branch only when switches 1, 2, 3 and 4 are all turned on?
Yes, that's what you asked for in your first post. 😛
Yes, that's what you asked for in your first post. 😛

I know what I asked for. I'm just clarifying exactly what the code does because I don't understand it. It could print out a list of switches saying if they are on or off for all I know. A previous time I used code from a post, it didn't mean what I thought and I ended up with errors.
...yes, the code Mac provided is the code you asked for.

It would presumably have taken less time to paste it into your project and test than to go through two posts back and forth waiting for responses 😛
I know what I asked for. I'm just clarifying exactly what the code does because I don't understand it. It could print out a list of switches saying if they are on or off for all I know. A previous time I used code from a post, it didn't mean what I thought and I ended up with errors.
And how would you know if you will get an error without actually testing it?

Original thread: https://forums.rpgmakerweb.com/threads/check-multiple-switches.160997/