Switch flips if event variable is in array, but not if the player leaves the map and returns.

This.... has a lot of moving parts so in the interest of not having a million screenshots, I'll try and restrict it to the "important" stuff. However if you need additional info I'll provide it.

There are two plugins at play here.... Yanfly's Self Switches and Variables, and Galv's Event Spawner.

The scenario is I've spawned a torch event on a blank map, it defines an array in it's self variable 2 (Variable 26), then switches to a page that's reporting it's ID ($gameVariable(2)) and the Map ID($gameVariable(3)). When player makes a pathway, it runs screenshot 3... Then goes to a blank page set to action button. It's pretty much just reporting it's event ID, then running the common event "Path Locations Check" in screenshot 2. The plan is simply to push it onto the array in the torch's self variable 2 for later use. So far so good, this variable reports the array sets up perfectly and is still reported as the same when I return to the map.

Now we get to the problem, another event (screenshot 4) is created and checks for the space in front of it. If the eventID of that location isn't 0, then it report it's own eventID and runs the common event "Path Destroy Check" (Screenshot 1). This event flips a switch if the eventID is in the self variable array. If it flips the switch then both events are despawned, and the eventID is removed from the array. Up until this point, it all works....

But then if I leave the map and return, it no longer recognizes anything in the array that was placed there previously. The array still reports as having the IDs in there though. And any new IDs added to the array still trigger as normal.

Been puzzling over it for a few days, but since I'm pretty new to scripting, there's probably something silly I'm missing. Anybody have any ideas?

Edit: I moved the event holding the self variable to a non-spawned event, just to eliminate Galv's Event Spawner from the equation. The problem persists though.
Iam not sure but the Eventpage on Picture3 is on Autorun, that is used for Cutscenes so the Player cant move,
iam not sure but i believe other parallel Events wait until the autorun is finished(Not 100% sure, i dont have time to test it at the moment).
Try Parallel instead of Autorun.
Huh, I didn't even notice that thanks. I switched it, probably accounts for some other weird behavior the event was having. Sadly it didn't end up solving this problem though.

I tried another way of doing things, and it would work but then entering the map again would make it destroy all events. Then I started noticing a lot of other unexplained glitches like suddenly the player ignored tile passability, or entering rooms at odd locations. I think the game itself may have just become corrupted.... I've got backups, so before I pester people too much about this. I'm going to make certain that's not the problem. Also it could just be Yanfly's Self Variables.... it interacts weirdly with well, everything. ;_;

Edit: The instability was by playing with the interaction of commands executed after Transfer commands. As I was unable to get consist results with the system remembering arrays in Self Variables (sometimes it did, sometimes it didn't, sometimes it only remembered stuff added to it later), I created a work around using Galv's Puzzle functions and ditched the arrays entirely. Problem solved!
Thread closed IgnoreMe

Original thread: https://forums.rpgmakerweb.com/threads/switch-flips-if-event-variable-is-in-array-but-not-if-the-player-leaves-the-map-and-returns.113840/