global variable alternative? also gamepad use

I've written a plugin that allows the player to toggle whether or not the message window is shown, but I have a few concerns about it as it stands.


It has a plugin command so that the game can set the message windows to display again regardless. However, I've used a (semi-)global variable to do this, and I suspect there is a better way that I missed.


Also, I don't have a gamepad, so I'm unsure if my gamepad compatibility is really working.


Feedback on the plugin in general welcome also.


Code in spoiler:

Spoiler
Code:
//=============================================================================
// MessageHide.js                                                             
//=============================================================================
 
/*:
@plugindesc v0.1.0 Define a key the player can press to toggle whether the message window is shown.
@author Jatopian

@param key
@desc Key that toggles message window visibility when pressed. See help for list.
@default ctrl

@help
Message window visibility is reset to 'on' by bringing up the menu 
or resetting the game, 
as well as by pressing the key a second time.

"key" parameter takes values 0-9, a-z, or any of these: 
tab
enter
shift
ctrl
alt
space
semicolon
comma
period
quote
pageup
pagedown
Or any of these, for gamepad compatibility:
ok
cancel
shift
menu
pageup
pagedown
up
down
left
right

Terms of Use:
- Free for commercial and non-commercial use.
- Please give credit in a trivially accessible place.
- OK to modify, but if you redistribute the modified version, 
  please make clear that you modified it, and how. 
- If you add features that could be useful to others, 
  please at least consider sharing them with me and the community.
*/

(function() {
  var params = PluginManager.parameters("MessageHide");
  var pKey = String(params["key"]).toLowerCase();
  
  var key_ids = {
    "tab":9,"enter":13,"shift":16,"ctrl":17,"alt":18,"space":32,
    "0":48,"1":49,"2":50,"3":51,"4":52,"5":53,"6":54,"7":55,"8":56,"9":57,
    "a":65,"b":66,"c":67,"d":68,"e":69,"f":70,"g":71,"h":72,"i":73,"j":74,"k":75,"l":76,"m":77,
    "n":78,"o":79,"p":80,"q":81,"r":82,"s":83,"t":84,"u":85,"v":86,"w":87,"x":88,"y":89,"z":90,
    "semicolon":186,"comma":188,"period":190,"quote":222,
  };
  
  Input.keyMapper[key_ids[pKey]] = "messageHide";
  
  messageWindowForceShow = false;
  
  //=============================================================================
  // Window Message
  //=============================================================================
  
  var alias_wm_ud = Window_Message.prototype.update;
  Window_Message.prototype.update = function() {
    alias_wm_ud.call(this);
    if (Input.isTriggered("messageHide") === true) {
      this.visible = !this.visible;
    }
    if (messageWindowForceShow === true){
      this.visible = true;
      messageWindowForceShow = false;
    }
  }
  
  //=============================================================================
  // Game Interpreter
  //=============================================================================
  
  var alias_Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
  Game_Interpreter.prototype.pluginCommand = function(command, args) {
      alias_Game_Interpreter_pluginCommand.call(this, command, args);
      if (command === "ShowMessageWindow") {
        messageWindowForceShow = true;
      }
  }
  
})();
This looks like a plugin release, not even one in development.  Could you confirm that this is indeed a release?
This looks like a plugin release, not even one in development.  Could you confirm that this is indeed a release?

While I could perhaps release it in this state, I would like to address or at least have someone look at the issues I mentioned before I declare it a release and repost it to the JS Plugin Releases board. My understanding is that if I want Javascript help I should post here. I apologize if I've misunderstood something.
No, you're fine.  It's just that a report was received that this was maybe in the wrong place and before acting on it, I wanted to check what it was you had in mind.  I think what may have caused the query was the way you phrased the last sentence i.e.


" Feedback welcome also ".  That might lead some to think that feedback is an optional extra, whereas from what you say now it is integral to your reasons for posting.

Original thread: https://forums.rpgmakerweb.com/threads/global-variable-alternative-also-gamepad-use.70727/