MV How to create a Button combination-lock?

To keep it simple, I am trying to make a puzzle in my game where you activate different coloured switches in one specific order to progress. Parts of the answer is scattered around the area and if you answer incorrectly, the player gets shocked and loses 20% of their hp as to not brute force their way through.

I have looked up stuff online and couldn't find any thing specifically about a button combination, but rather only a certain amount of buttons or a number-input combination lock. I want the player to push the buttons Blue -> Green -> Yellow -> Red in that order and after they've pushed every button in the wrong order, they get punished. My current system is to have a variable increase by one after every right button press and when it's equal to 4, the door opens. I however can't come up with a way to make the incorrect way work, which I tried to have a seperate line of control-switches activate and the variable being set to 0.

Are there any tutorials out there I may have missed in my search or is there a simple solution to this problem I've been having?
I don't know how you have this set up since you didn't share your Events, but I would think you could just add another Variable for total button pushes.

It starts are zero and you increment it by 1 for every button push. With each button push, after incrementing, you check to see if it is a 4. If so, and if the other variable you are using isn't at 4 because of the correct sequence, then you do the punishment, you reset the switches, and you reset the button push variable to 0.

That way you are tracking how many buttons they are pressed and adjudicating the results after 4 button presses, whether they got it right or wrong.

I don't see why that wouldn't work unless you are setting up your Events in an unexpected way. But I might be misunderstanding what you are trying to do.

I hope that helps.

Good luck on your project!
I'd just use switches. You'd put conditional branches for each corresponding switch on every button except for blue. Blue will turn on switch "Blue PRESSED", then second event page so it can't be pushed twice.

On the green switch You simply put a conditional branch checking whether or not "Blue PRESSED" is on. If yes, turn on switch "Green PRESSED", else shock player. (Additionally you can turn off all the switches for all the buttons here so they reset.)

After that you rinse and repeat pretty much. For yellow you then put a nested conditional branch:
If switch "Blue PRESSED" is on, else shock player / reset. Inside that condition you put if switch "Green PRESSED" is on, else shock player / reset. What this does is that it will shock the player unless both blue and green pressed is ON.

Repeat the same thing for red, but with an additional nested branch for yellow.
I recently released a plugin to make order switches plain simple [here].
as the switches turn automatically OFF if the order is wrong.

and easy to set in the database to avoid nested condition or pages to 1 page only.

Original thread: https://forums.rpgmakerweb.com/threads/how-to-create-a-button-combination-lock.181145/