When you leave and re-enter a map, what event stuff saves?

Question as title, really.

When you leave a map and then later re-enter it, events move back to their initial position.

However, what else does and does not reset? For instance, I'm seeing what looks like event self-switches retaining their setting, is that right?
switches, self-switches and variables retain their values because they are stored outside the mapfile.
everything on the mapfile itself is reloaded on entering a map

to change that you'll need scripts or plugins.
switches, self-switches and variables retain their values because they are stored outside the mapfile.
everything on the mapfile itself is reloaded on entering a map

to change that you'll need scripts or plugins.

Thanks for explaining that.

That's interesting. Variables and switches I can understand, as I consider them global - but I find it strange that self-switches are saved when you leave and re-enter.
Things like screen tint and weather persist from one map to the next - if you make it rain on an outside map and then go to an inside map, it's still raining. So you need to add event commands to stop them.

But as far as events, anything in the Conditions panel is saved, so when you leave the map and return, the same event page will be active.

Self switches, even though they "belong" to an event, are not saved as part of the event data. They are completely outside of the event. If you've used the Outer Self Switches plugin or the script call to change a self switch, you'll know that you need to pass in the map id and the event id as well as the self switch id. All 3 are saved in a completely separate structure. You have $gameVariables, $gameSwitches and $gameSelfSwitches that are all outside of $gameMap and $dataMap, which is where the events are saved. The map/event info is reloaded from the file each time you enter, but the variables/switches/self switches persist throughout the game.
self-switches are dynamics that change while gaming, so they need to be saved into the savefile.
map files are static, they can't contain any values other than that what is set in the editor
Events that got deleted with the Eventcommand "Erase Event" will be Alive again after Map reload.

Self Switches are very important for different Mechanics, i also used plugin to have more self switches and also self variables for Events and on vx-ace even for Actors. If those would resett that would be plain torture.
Things like screen tint and weather persist from one map to the next - if you make it rain on an outside map and then go to an inside map, it's still raining. So you need to add event commands to stop them.

This is kinda related to what I'm struggling with.

I have a map. It normally has a BGM which is set in the map settings.

However, the first time you enter this map, the BGM doesn't play (the auto-run event has a "Play none" command), because the auto-run also kicks off a cutscene (state #1).

After the cutscene is over, the player is in state #2, which is a blank "player touch" page, where they can run around and explore; still there is no BGM.

When the player speaks to an NPC, they start state #3, which is another auto-run that plays another cutscene. The BGM starts. This takes the player onto states #4, #5...

The problem I'm having is that during state #2, the player could leave the map and re-enter it - and as #2 is a blank "player touch" page, the default map BGM will play. (I can't just remove the map default or I'll have the opposite problem later - the player leaves and re-enters in state #4 and the music will not play).

After #3 it's fine if the music plays every time. I just need it to not play in state #2, which is not an auto-run page.

The way I'm doing it right now is that I have a separate event with a parallel page, which has one page with a conditional IF. If the state is #2, it "plays none" in terms of BGM, then "Exit Event Process". This works, but it feels... Hacky? This parallel event will be used for all the things where I need to be able to set the "on-entering-the-room" stuff.

Is there a right way to do this?
Think of it like this: Standard switches are accessed using a ID number. So an ID of 5 will access switch 5, and so on--easy stuff, right? With self switches, instead of a number, that ID is a string of comma-separated values consisting of a map id, event id, and the self switch in question (A, B, C, D, etc) So "12,5,A" is the the ID for a self switch on map 12, event 5, switch A. Other than that, they behave just like normal switches, which are also not connected to any particular event, map, etc.

That's why something like Erase Event will only remove an event until you re-enter the map, while setting a treasure box's self switch persists between map changes.
I'd do it a bit differently to what you've got.

I'd remove the BGM from the map properties altogether, so you don't have to turn it off with an autorun event (in this case, I'm wondering if you hear the BGM playing for a very brief moment before it gets turned off?)

Then have a single event JUST for the BGM that has ONE page, set to parallel process, that does a Play BGM followed by an Erase Event, and the event is conditioned by a switch. In the second cutscene, at the point you want the BGM to start playing, turn on that switch.

That's all you need to do.

The event will sit there doing absolutely nothing until the second cutscene plays and turns on the switch. Then the BGM will start playing. Every time after that the player leaves the map and returns, that event will be reloaded and executed, and the BGM will play again.

This has nothing to do with what "event stuff" gets saved, as BGM is not "event stuff".


You would have got an answer on that more quickly if you'd said in your first post what it is you were having troubles with 😉

Original thread: https://forums.rpgmakerweb.com/threads/when-you-leave-and-re-enter-a-map-what-event-stuff-saves.105060/