How would one do this in an efficient way?
I've got this, but
var key = [map id, event id, selfswitch];
$gameSelfSwitches.setValue(key, true);
Not sure how to apply ^ that on every event/self switch in map X.
Quick & dirty way
for (var i=0; i < Object.keys($gameSelfSwitches._data); i++) {if (Object.keys($gameSelfSwitches._data).match(/(\d+),/)[1] === YOUR_MAP_ID_HERE) {Object.keys($gameSelfSwitches._data) = false;}}
Thank you very much! Dirty works for me. 😉
Wouldn't that also reset all self switches belonging to events with the same id as that map, no matter on which map they are?
Also, i'm not sure why you're calling Object.keys() 3 times, when 1 would be enough and your last call is even wrong, because you are not resetting the switch value, but change the key it belongs to.
Thanks lavra for reminding me.
Stupidly, I tried to set switches keys rather than it's value to false. Moreover, after I take a look again, I see that setting self switches to false must be followed by refreshig the map
You might try to use lavra's snippet or use this. Call $gameSelfSwitches.clearMap(MAP_ID)
Game_SelfSwitches.prototype.clearMap = function(mapId) { var ary = Object.keys(this._data); for (var i = 0; i < ary.length; i++) { if (ary.match(/(\d+),/)[1] == mapId) { this.setValue([ary], false); } }}Pardon for my mistake XD