following a set way to activate a switch, how?

I want to create a path to activate a switch that deactivate a trap. So if the player start at 1 he have to walk the red line to get to the next point 2 and then he walks to point 3 and if he followed the lines exactly, a switch should go on to deactivate a trap. I want to reset the way if he goes a other way then the set way, but i don't know how to do it or if it's possible. I also looked for a plugin but i didn't know how to call it.

My Problem: I don't know how to do a event that get triggered when the player follows a set way and if the player leave this way then the progress will deleted and he can start new

There are definitely more elegant solutions for this with plugins/scripting, but you can do this using just the core engine as well by making use of regions.

Here's a picture example to give you the basic idea:
PathwaySwitch.png


You need a parallel event checking the player's region. Then some sort of condition that flips switches off, if the player moves from the region after flipping the switch. The switches themselves are pretty basic, but just need to update as each new switch is flipped following the path.

Hopefully this helps you get it working.

Edit: also, you don't actually need there to be 2 different regions. All of that could just be region 3, and it would work as well.
Edit 2: Also this RMW blog post might be helpful as it covers many of the same concepts: http://blog.rpgmakerweb.com/tutorials/tutorial-using-regionid-in-events/
Thanks for you help it works with the first button but i've some problems with the others, because if i want to set yellow button and Green button i can go directly to the green button and it's active, or no button works instead of red . I'll try to find out for myself how to make the buttons work, but if it does not bother you, I'd be happy for your answer
You could use this, with some adjustments:

https://forums.rpgmakerweb.com/inde...-press-buttons-in-correct-order-puzzle.70966/

Instead of switches that have to be pressed, the 'triggers' will be Player Touch events set to Below Characters.
Instead of calling the common event when each 'trigger' is activated, remove that from the individual events, and put it on the actual switch you want the player to activate.
You'll also need a way to allow them to go back to the start and reset the puzzle, in case they walk over the switches again on the way back.

Although, thinking about it, this would not force them to follow the path, moving between the arrows in a direct line. They could walk all over the place, as long as they touched the arrow tiles in the correct order. So maybe not what you were after ...
@Skydorm You should use the same set up for each switch in the sequence that I have above, with some slight tweaks.

E.g. For the second switch. It should have a page where it is blank/unactivated. A page when switch one is turned on, with a command to turn on switch 2 when the player touches it, a page with switch 2 on (and nothing happens -- since the parallel process is determining whether or not the switch should be flipped off), and a page with the Switch 3 on, which makes it so it won't reset after the player reaches the end.
Thank you guys for taking your time to help me, it works now! Just had to put the " If Switch 2" into "If Switch 1".

Original thread: https://forums.rpgmakerweb.com/threads/following-a-set-way-to-activate-a-switch-how.92759/