On/Off switch lever

I am having difficulty trying to figure out how to make a switch lever that can open and close a door as many times as the players wants to flip it. They basically can flip it left or right/on or off. Can anyone help with this problem?


Thanks
So the door should just be a transfer event and no opening/closing animation?


Make the door with 2 pages.  Page 1 will have the closed sprite, page 2 will have the open sprite and the transfer command.  Page 2 will also be conditioned by a switch (no conditions for page 1).


Make the lever event with 2 pages.  Page 1 will have the lever 'off' sprite, page 2 will have the lever 'on' sprite.  Page 2 will also be conditioned by the same switch as page 2 of the door.


Check the Direction Fix box on both pages of both events.


On your lever event, put the following commands on page 1:


Set Move Route (this event): Direction Fix OFF, Turn Left, Wait 3 Frames, Turn Right, Wait 3 Frames, Turn Up, Direction Fix ON


Set Move Route (door event, wait for completion): Direction Fix OFF, Turn Left, Wait 3 Frames, Turn Right, Wait 3 Frames, Turn Up, Direction Fix ON


Control Switches: switch used as a condition on page 2 of the events = ON


Add whatever sound effects you want for the lever and the door opening.  Also check what images are on the lever event - you might not need the last Wait 3 Frames and Turn Up commands - I don't recall whether there are 3 or 4 rows of sprites for those.


On your lever event, put the following commands on page 2:


Set Move Route (this event): Direction Fix OFF, Turn Right, Wait 3 Frames, Turn Left, Wait 3 Frames, Turn Down, Direction Fix ON


Set Move Route (door event, wait for completion): Direction Fix OFF, Turn Right, Wait 3 Frames, Turn Left, Wait 3 Frames, Turn Down, Direction Fix ON


Control Switches: switch used as a condition on page 2 of the events = OFF
Basically two event pages, first one containing a command "control door switch = ON and the second one containing a command "control door switch = OFF",


The second page needs to havve the sprite/tile of the lever in the other direction and be conditioned to exactly that switch (which also controls the door).


Finished - two event pages with a single command in it is all you use, and the door event needs to be conditioned to exactly the same switch.
oh yeah - you only need to do it the way I said if the lever and door can both be seen at the same time.  If they can't, the move routes aren't required at all (at least the ones for the door)
Thanks so much guys. I apologize for asking such a basic question but I searched all day on google and youtube and couldn't find exactly what I was doing. I think the direction fix was tripping me up.
oh yeah - you only need to do it the way I said if the lever and door can both be seen at the same time. If they can't, the move routes aren't required at all (at least the ones for the door)

Shaz, I'm very grateful to your write up here. I'm going through the on-board tutorial, but like to try something fancy upon completing a chapter to really test what I've learned. In this case, having the door animation play, instead of the basic on/off, and open and close the door using the physical switch.

My mistake came from attributing all the animation/activity of the door to the door event, instead of activating it within the lever event. It's honestly something I didn't think of, I just figured all action based around an event must sit inside said event. I was driving myself mad, as I had the control switches and movement routes down, but I couldn't get the door to close back to save my life. Thanks again.
Being able to add a Set Move Route command in one event, but apply it to another event, is awesome! 'Distributed' processing (where you turn on a switch and have multiple other events set to autorun/parallel process to react to that switch) is a nightmare to troubleshoot.

Original thread: https://forums.rpgmakerweb.com/threads/on-off-switch-lever.73708/