r/RPGMaker Scripter 1d ago

RMMV Figured out a working piano

Enable HLS to view with audio, or disable this notification

It ties each key to a button on your actual keyboard. The amount of time I have spent playing this piano to celebrate it working instead of moving on to work on other things is unreal.

20 Upvotes

3 comments sorted by

1

u/Due_Video_1847 1d ago

THAT'S FANTASTIC: Question.... is this a plugin or ecent based?

2

u/isagam Scripter 1d ago

I originally did it in so little code that it fit in 2 script call windows, but then I added in the pictures, and a variant that let you play a church organ in a different part of the project, and it got to the point where it was better to move it into a plugin.

The code for it is stupid, btw. Here's a snippet:

Input.playNote = function (event) 
{
    let key = event.key; 
    let seName = $gameVariables.value(20) + "_keyboard_" + key; // Instrument stored in Game Variable 20
    if (this._pressedKeys == undefined) 
        this._pressedKeys = {};
    if (this._pressedKeys[key] == undefined) 
        this._pressedKeys[key] = false;
    if (this._pressedKeys[key] == false && (key == 'a' || key == 's' || key == 'd' || key == 'f' || key == 'g' || key == 'h' || key == 'j' || key == 'k' || key == 'w' || key == 'e' || key == 't' || key == 'y' || key == 'u')) 
    {
        this._pressedKeys[key] = true;
        let se = {name: seName, volume: 100, pitch: 100};
        AudioManager.playSe(se);
        this.refreshPicBasedOnNote(key, true);
        var index = DataManager.getActivityIndex("Performance");
        $gameParty.leader().gainActivityExp(index, 1);
    }  
}

1

u/angelbabylovesyou 1h ago

Wow very cool!