So my game has this section in it with a piano. What I want to do is make it so when the piano is activated the player has piano keys that appear on the screen (or some other buttons). By clicking on them, or tapping (important as this will also be an app), they play sounds like a piano; but if a certain pattern is played it opens up a secret door. Currently I have it set up as a regular press enter -> switch flips -> door opens kind of event. Every attempt I have made to make this work with a mini-game has failed...
Anyone able to explain to me how to do such a thing, or help me figure it out? 🙂
Helpful! Thank you! I don't have a sound puzzle but now I have a reference for making a unlock loop puzzle of any kind. For folks that are new to eventing this is great to see.
I don't know about the clicking/tapping (you might need a plugin that lets you click on pictures), but for the basic unlocking mechanic I would push the keys into an array and then compare it with the sequence you want to unlock the door. It involves some simple scripting, but nothing that needs a plugin on its own. I only really know how to do events, not scripting, so there may be even better ways to do this, but this is how I would do it...
If it's a sequence of 7 notes, you could set up 2 arrays plus a regular variable like this:
var sequence = ["a","b","c","d","e","f","g"];
var playedkeys = []; //empty array
$gameVariables.setValue(1, sequence); // store the sequence in Variable 1
$gameVariables.setValue(2, playedkeys); // store the played keys in Variable 2
$gameVariables.setValue(3, 0); // counts the number of correct keys played (optional)
Every time you touch a key, it does this (for example, the C key)
var playedkeys = $gameVariables.value(2); // retrieve the played keys array
playedkeys.push("c");
$gameVariables.setValue(2, playedkeys); // updates the played keys array
// everything below this is optional
var check = $gameVariables.value(3); // time to check if the key played is the right one.
var sequence = $gameVariables.value(1); // need to load the sequence again
if (playedkeys[check] == sequence[check]) {
check += 1;
$gameVariables.setValue(3, check); // update correct keys variables
} else {
check = 0;
playedkeys = [];
$gameVariables.setValue(3, check);
$gameVariables.setValue(2, playedkeys); // boo, pressed the wrong key. start over.
}
// everything above this is optional
var is_same = (playedkeys.length == sequence.length) && playedkeys.every(function(element, index) {
return element === sequence[index]; }); //check and see if the played sequence matches with the lock sequence
if (is_same == true){
$gameSwitches.value(1) == true; // unlock the door
}
^ the way this one works is that it will reset back to 0 as soon as you press the wrong key. It would actually be simpler to do it so that it just checks every 7 key presses (you could take out everything marked optional) but it could be a little more frustrating for the player (and you also have to make sure to reset the playedkeys array if is_same turns up false)