Hello, I want to make a piano interface in RPGMaker, by making it run a common event in parralel, triggered by a switch. The second keyboard row (ASDF) is used for the piano, and the cancel logical event is just routine code to return back to the player's position.
This is my current code:
const keyMap = {
'A': 0, 'S': 1, 'D': 2, 'F': 3, 'G': 4,
'H': 5, 'J': 6, 'K': 7, 'L': 8, ';': 9, "'": 10
};
for (const key in keyMap) {
if (Input.isTriggered(key.toLowerCase())) {
const n = keyMap[key];
$gameVariables.setValue(51, n);
AudioManager.playSe({name: `hurazom_piano_note_${n}`, volume:90, pitch:100, pan:0});
}
}
if (Input.isTriggered('cancel')) {
$gameScreen.clearPictures();
$gameScreen.startTint([0, 0, 0, 0], 60);
$gameSwitches.setValue(43, false);
$gamePlayer.reserveTransfer(
$gameVariables.value(54),
$gameVariables.value(55),
$gameVariables.value(56),
$gameVariables.value(53),
2
);
}
It doesn't seem to work for me. Does anyone know how I can fix this?
Update: I manage to fix it. In the rpg_core.js, I updated Input.keyMapper to include definitions for the keys: F - L and ; as such:
70: 'f',
71: 'g',
72: 'h',
73: 'i',
74: 'j',
75: 'k',
76: 'l',
186: ';'
This is my current code:
const keyMap = {
'A': 0, 'S': 1, 'D': 2, 'F': 3, 'G': 4,
'H': 5, 'J': 6, 'K': 7, 'L': 8, ';': 9, "'": 10
};
for (const key in keyMap) {
if (Input.isTriggered(key.toLowerCase())) {
const n = keyMap[key];
$gameVariables.setValue(51, n);
AudioManager.playSe({name: `hurazom_piano_note_${n}`, volume:90, pitch:100, pan:0});
}
}
if (Input.isTriggered('cancel')) {
$gameScreen.clearPictures();
$gameScreen.startTint([0, 0, 0, 0], 60);
$gameSwitches.setValue(43, false);
$gamePlayer.reserveTransfer(
$gameVariables.value(54),
$gameVariables.value(55),
$gameVariables.value(56),
$gameVariables.value(53),
2
);
}
It doesn't seem to work for me. Does anyone know how I can fix this?
Update: I manage to fix it. In the rpg_core.js, I updated Input.keyMapper to include definitions for the keys: F - L and ; as such:
70: 'f',
71: 'g',
72: 'h',
73: 'i',
74: 'j',
75: 'k',
76: 'l',
186: ';'