- Joined
- Jul 5, 2015
- Messages
- 53
- Reaction score
- 15
- First Language
- English
- Primarily Uses
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 is.
I've attempted to let the developer set a "key" for the command that works with a gamepad. However, I don't have a gamepad, so I'm unsure if gamepad compatibility is really working.
Also, it has a plugin command so that the game can set the message windows to display again regardless. I've used a (semi-)global variable to do this, and I suspect there is a better way that I missed. I don't think it'll actually cause a problem ever, but no one was able to speak to this on the Learning Javascript board, so I thought I'd mention it here.
General feedback also welcome, of course.
I've attempted to let the developer set a "key" for the command that works with a gamepad. However, I don't have a gamepad, so I'm unsure if gamepad compatibility is really working.
Also, it has a plugin command so that the game can set the message windows to display again regardless. I've used a (semi-)global variable to do this, and I suspect there is a better way that I missed. I don't think it'll actually cause a problem ever, but no one was able to speak to this on the Learning Javascript board, so I thought I'd mention it here.
General feedback also welcome, of course.
Code:
//=============================================================================
// MessageHide.js
//=============================================================================
/*:
@plugindesc v0.1.1 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";
MessageHide_messageWindowForceShow = false; //global variable!
//=============================================================================
// 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 (MessageHide_messageWindowForceShow === true){
this.visible = true;
MessageHide_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") {
MessageHide_messageWindowForceShow = true;
}
}
})();

