More SelfSwitches Plugin Bug fix please...

Spoiler
//=============================================================================
// More Self Switches
// Author gameus
// Version 1.0
//-----------------------------------------------------------------------------
// Intro:
// Allows you to use infinite self switches in any event.
//
// Instructions:
// Place in your plugins folder and save as 'MoreSelfSwitches.js'
//
// To create a custom self switch, you must first check the self switch box
// on any page. Then add a comment at the top of the page and follow the format
//
// switch:custom_switch_name
//
// After that, use the Plugin Command and call
//
// SelfSwitch custom_switch_name true/false
//
// Thus allowing as many self switches as you want, with whatever name!
//
// Credits:
// gameus ~ For creating it.
//=============================================================================

/*:
* @plugindesc Allows for infinite self switches in events.
* @author gameus
*
* @help
* Instructions:
* Place in your plugins folder and save as 'MoreSelfSwitches.js'
*
* To create a custom self switch, you must first check the self switch box
* on any page. Then add a comment at the top of the page and follow the format
*
* switch:custom_switch_name
*
* After that, use the Plugin Command and call
*
* SelfSwitch custom_switch_name true/false
*
* Thus allowing as many self switches as you want, with whatever name!
*/

var GameusScripts = GameusScripts || {};
GameusScripts['MoreSelfSwitches'] = 1.0;

(function() {

var gameus_SelfSwitch_initialize = Game_Event.prototype.initialize;
var gameus_SelfSwitch_plugin_command = Game_Interpreter.prototype.pluginCommand;

Game_Interpreter.prototype.pluginCommand = function(command, args) {
gameus_SelfSwitch_plugin_command.call(this, command, args);
if (command.toLowerCase() == "selfswitch") {
var _switch = args[0];
var _state = Boolean(args[1]);
var _key = [this._mapId, this._eventId, _switch];
$gameSelfSwitches.setValue(_key, _state);
}
};

Game_Event.prototype.initialize = function(mapId, eventId) {
gameus_SelfSwitch_initialize.call(this, mapId, eventId);
var pages = this.event().pages;
for (i = 0; i < pages.length; i += 1) {
var page = pages;
for (j = 0; j < page.list.length; j += 1) {
var command = page.list[j];
if (command.code === 408 || command.code === 108)
this.checkCustomSwitch(page, command.parameters[0]);
}
}
};

Game_Event.prototype.checkCustomSwitch = function(page, code) {
var args = code.split(":");
if (args[0] !== null && args[0].toLowerCase() == "switch" && args[1] !== null) {
page.conditions.selfSwitchCh = args[1];
page.conditions.selfSwitchValid = true;
}
};

})();






I'm not sure what the protocol is for this sort of thing, but since the original creator has be inactive for months I was wondering if someone else can fix this plugin.


This is the MoreSelfSwitches plugin by gameus...  For the most part it works exactly they way it's supposed to.  Perfectly.  But there is one instance that it doesn't.  When the player enter the menu the selfswitches reset themselves and all the work is erased.


Can someone make it so it doesn't do that?

Original thread: https://forums.rpgmakerweb.com/threads/more-selfswitches-plugin-bug-fix-please.63202/