Change all Self Switches in the entire game.

I'm trying to, with a script/plugin call, adjust all Self Switches of a given letter over the entire game.

For example, the ability to turn off Self Switch "D" on every event in the game, without touching Self Switches "A", "B", and "C". I've seen plugins do this on the current map, as well as a plugin to simply clear all Self Switches. But what I'm looking for is the ability to modify only one Self Switch letter, for every event over every map.

So, Turn all "A"s on, or Turn all "C"s off. That's what I'm looking for.

Thank you for your time!
Code:
for (var i in $gameSelfSwitches._data) if (i.contains("A")) $gameSelfSwitches._data[i] = false;
You cannot turn on self switches from maps where they are turned off (well, you can, but it's tedious and probably will lag your game for some time), but you can turn all of them off.
Thank you! Seems to be working fine!

While being able to turn on the self switches would be nice, all I really need is to turn them off.
Turning them on would involve loading every map file, crawling through every event and turning their selvf switches on., Which is pretty okay in small projects, but when your project reaches like 200 maps, it can get tedious, considering how many times you use events that don't get influenced by self switches and henceforth turning them on for them would be impractical and unnecessary.
I don't think you need to load all the maps. Just go iterate from 1 to 999 or whatever the number you want. Then turn em all 😛 no need to load maps
You're right 😀 Although you can definitely flood the RAM with that...
You can also change the default value to true and change all currently known self-switches to true.
Although you can definitely flood the RAM with that...

I was curious, so I snapshotted the heap before and after allocating 200 maps of 500 events for each of the 4 self switches --> roughly 26MB increase of memory use on the heap.
If my math is correct, that's:
Code:
( 26 * 1024 * 1024 ) / (4 * 200 * 500) = ~68 bytes per self switch
Does seem like a lot of memory for a boolean, but I ran the test again with the same result.


Probably want to delete the object property, as the MV code does, instead of setting it to false if RAM is a concern.

Original thread: https://forums.rpgmakerweb.com/threads/change-all-self-switches-in-the-entire-game.105152/