A question about switches...I think.

I am a beginner. I apologize if this has been asked before. I have been looking around for an answer before coming here.


I want to create an autorun event that happens every time the player enters the map. I want to enter an elevator, shake the screen and rumble a bit, play a ding, end the event and walk out. I see how to do this much with switches. But I want this to happen every time I enter that elevator.

autoruntest01.png
Good try, but not quite right.


Using switches or self switches to active a new event page is a permanent thing.  It doesn't get reset when you re-enter the map, but only when you deliberately change the switch or self switch again.


To have something run every time you enter a map, you simply use an Erase Event command.  That removes the event for the remainder of the time you're on the map, but when the map is next loaded, that event will be loaded again too.


Also, unless this is something that takes some time to run and you don't want the player to be able to move while it's happening, I suggest you change it to parallel process trigger instead of autorun.  Autoruns remove control from the player, and if you have several, only one of them will run at a time (and I'm not sure if they will queue up, but if they do, you have no control over the order).  Parallel process events will all run at the same time, and will allow the player to keep doing stuff as well.


So to fix your event, remove any references to self switches and remove the second page, and add Erase Event as the last command.
Assuming that the Map on which this Event is placed is the inside of this Elevator itself, remove the Self Switch and Page 2, replace the Self Switch with Erase Event. The Event will run, as before, automatically, then erase itself until the next time that the Map is entered.


The Self Switch is inappropriate as, once triggered, it remains triggered. Re-entering the Map does not reset the Self Switch.


Try it..?
Well in fact you COULD reset a self switch by calling:


$gameSelfSwitches.setValue([mapId, eventId, 'A'], false);


But in this case it would just be unproper coding 😉
Well in fact you COULD reset a self switch by calling:



$gameSelfSwitches.setValue([mapId, eventId, 'A'], false);


But in this case it would just be unproper coding 😉

Why?
Because they don't need to reset the switch at all. If it is supposed to happen every time, there is no purpose to turning the switch on then back off. What would be better is to either do erase event (so it is there next time), or do what Shaz suggested.
Thanks everyone! You are awesome, all of you! It works perfectly!
R91KekF.gif
If you want a more realistic tutorial, here's the link:
https://forums.rpgmakerweb.com/index.php?threads/creating-an-elevator-event.60254/
Credit to ByBibo for the tutorial.👍

Liftyfied, please refrain from necro-posting in a thread. Necro-posting is posting in a thread that has not had posting activity in over 30 days. You can review our forum rules here. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/a-question-about-switches-i-think.69001/