Help with rock and switch puzzle

So I just took a year off RPG Maker, and Im paying for it lol
Normally I'd be able to tell just by looking at it what is messed up here.. but for some reason its lost on me.
When I put the boulder on the switch, it just loops over and over again making the bridge appear.
Same when I step on the switch.
What im trying to do is make it so if you step off the switch, it goes back to how it was and the bridge disappears.
help event.png

help event 2.png
Well... I'm not a RMMV user, however....

If it were in the RM2k3 I would do 5 events:
  • 1 is the Ground Switch - it's activated when player/boulder touches it, Switch ON.
  • 4 are around the Ground Switch - they are also activated with player/boulder touch, Switch OFF
Thats one method, but im trying to use variables to control it using X and Y.
That would work in a sinch though for sure.
But there has to be away to do this using variables, also I dont think that method would work for the boulders X and Y, only the players.
Well, based on my past programming knowledge...

If player.x == x && player.y == y
Switch = ON
Variable += 1​
else
Variable -= 1​

If boulder.x == x && boulder.y == y
Switch = ON
Variable += 1​
else
Variable -= 1
​
If Variable == 0
Switch = OFF​

This won't work in parallel process, because you will be adding/subtracting the variables constantly, you will have to do it with player and event touch to work.
The player and the boulder cannot both be on the switch. So you move the boulder on, and page 2 becomes active. Because the player is not standing on the switch, page 1 becomes active. Because the boulder is on the switch, page 2 becomes active. Because the player is not on the switch, page 1 becomes active.

If you want the player OR the boulder on the switch to activate it, do this ...

Remove all the event commands from your event, and change the pages back to Action Button. Condition page 2 by the Bridge switch being ON.
Use the Region layer to draw on the switch with a region id (I'll use 18 as an example - use whatever you want, then use that number in the commands below)
I assume you've got commands on your boulder to set its x and y position. Remove them. Your boulder will just move and not do any other checking

Add another event with no sprite, put it out of the way somewhere, and set it to parallel process. Add the following commands:

Code:
Wait 4 Frames
Control Variables: x = boulder's X position
Control Variables: y = boulder's Y position
Get Location Info: Region ID of x, y into Region variable
Conditional Branch: Variable Region variable = 18
  Bridge Switch = ON
Else
  Control Variables: x = player's X position
  Control Variables: y = player's Y position
  Get Location Info: Region ID of x, y into Region variable
  Conditional Branch: Variable Region variable = 18
    Bridge Switch = ON
  Else
    Bridge Switch = OFF
  End
End
Shaz to the rescue once again 😀
Feel free to say "for shame mr skunk, you should know better" lol
Thanks Shaz 🙂

Original thread: https://forums.rpgmakerweb.com/threads/help-with-rock-and-switch-puzzle.81318/