Heyo! I'm putting together a simple plugin to let me map keyboard input to common events, but I'm struggling:
1. How do I call a common event from inside js? I know this is super basic, but I'm way rusty.
2. How do I find other ascii codes for keyboard input? the rpg_core.js stuff is pretty limited. I'm trying to map WASD and SHIFT + WASD
Thanks!
Does appear to quite work. I'll keep fidding for now and come back if I can't figure it out. Currently, my code look like this:
]
* @static
* @property keyMapper
* @type Object
Input.keyMapper = {
199: 'slashUp', // lower w
97: 'slashLeft', // lower a
115: 'slashDown', // lower s
100: 'slashRight', // lower d
87: 'blockUp', // upper w
65: 'blockLeft', // upper a
83: 'blockDown', // upper s
68: 'blockRight', // upper d
};
if (Input.isPressed('slashLeft')) {
$gameTemp.reserveCommonEvent(15);
};
EDIT: The plugin is enabled and I did include all the other Input.keyMapper lines from rpg_core.js. All the native common work fine, but the new lines don't seem to do anything.
that if isn't executing all the time, it runs once the plugin is loaded and thats it.
If you want the game to constantly verify if that input is pressed, you need to either place it inside a setInterval or make an alias to the scene_map update function and add your code there. Like this:
var keyconfig_alias = Scene_Map.prototype.updateScene;
Scene_Map.prototype.updateScene = function() {
keyconfig_alias.call(this);
if (Input.isPressed('slashLeft')) {
$gameTemp.reserveCommonEvent(15);
};
}
Thanks! Sadly, this still isn't working. Here are screenshots of what I have. The plugin is active, but does nothing. It also isn't breaking anything.
When I triggered the common event 'slashLeft' by interacting with an enemy, it worked just fine. I fwas triggering the common event by flipping a switch called 'SlashingLeft.'
Instead of updateScene use just update. updateScene is only executed, if a scene change is requested.
It still isn't working. I wonder if the problem is with the core engine. I can't even get the console to open, for some reason. (I tried all the F keys, and '\' just in case, but no dice)
EDIT:
This works when 'ok' is triggered, but not when 'slashLeft' is triggered.
var keyconfig_alias = Scene_Map.prototype.update;
Scene_Map.prototype.update = function() {
keyconfig_alias.call(this);
if (Input.isTriggered('slashLeft')) {
SoundManager.playCursor();
$gameMessage.add("Hello World");
$gameTemp.reserveCommonEvent(15);
};
}
Strange, when I use the 'blockLeft' condition it works, even without Shift or Capslock.
The Shift pressed condition has to be part of the code due to Capslock.