I'd appreciate any help in trying to figure out the easiest way to track whether all 8 of a particular set of switches are in the OFF position. Basically, I imagine I would need a parallel process watching for this by checking a variable (X) which is the sum of converting each OFF switch into a numeric value (1) and triggering if X ever equals 8. It seems like this should work but is there an easier way to accomplish what I need?
Easiest way to track 8 switches OFF scenario?
RPG Maker VXAce SupportYou don't need a parallel process. What turns the switches on/off? Just put the check in after the switches are changed. If that's in multiple events, then create a common event (don't set it to parallel OR autorun), and call the common event after the switches are modified.
In the common event, do a Conditional Branch, and in the Script box (bottom of tab 4 of the conditional branch box), put this:
Your condition will evaluate to true if all of those switches are off, or false if at least one of them is on. Change the numbers in [1,2,3,4,5,6,7,8] to use the correct switch ids that you're interested in.
In the common event, do a Conditional Branch, and in the Script box (bottom of tab 4 of the conditional branch box), put this:
Code:
!([1,2,3,4,5,6,7,8].any?(|sw| $game_switches[sw]))
Your condition will evaluate to true if all of those switches are off, or false if at least one of them is on. Change the numbers in [1,2,3,4,5,6,7,8] to use the correct switch ids that you're interested in.
The switches are changed in a couple different areas/events, but they only get turned off in one event where the player chooses certain actions so I think your suggestion should work fine for me, Shaz. That is certainly not something I would have ever figured out on my own. Thanks!
And thank you too Taarna23, your method would also work and I appreciate the assist.
[Edit]
After putting in the conditional branch (didn't need to make a common event) I am getting an error message that says,
Script 'Game_Interpreter' line450:SyntaxError occurred.
unexpected '|', expecting ')'
And thank you too Taarna23, your method would also work and I appreciate the assist.
[Edit]
After putting in the conditional branch (didn't need to make a common event) I am getting an error message that says,
Script 'Game_Interpreter' line450:SyntaxError occurred.
unexpected '|', expecting ')'
Sorry. Try this instead:
I used () instead of {}
Re your PM: we don't get notified when you edit your post, and it doesn't show up as a new post. If you want to make sure the person gets a notification, you can tag them like this: @Reepyr (and select their name from the list that appears).
Code:
!([1,2,3,4,5,6,7,8].any?{|sw| $game_switches[sw]})
I used () instead of {}
Re your PM: we don't get notified when you edit your post, and it doesn't show up as a new post. If you want to make sure the person gets a notification, you can tag them like this: @Reepyr (and select their name from the list that appears).
Just tested it and it works perfectly, thanks so much @Shaz! I knew there had to be an easier way... 😀
This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.
Original thread: https://forums.rpgmakerweb.com/threads/easiest-way-to-track-8-switches-off-scenario.71734/
