How do I event this puzzle?

Dear forum,

I finally gave up trying to come up with a solution myself. I'm trying to create a puzzle in which you have a lever and 4 crystals of different colours (lets say red, blue, yellow and green). You pull the lever and a lightning strikes one of the crystals. Which one is determined by rng. The player has to remember which crystal was struck and has to walk up to it and press enter. If the player chose the correct crystal, again a lightning will strike the crystal. But if the player chose the wrong crystal the lightning will strike the player instead and the puzzle will reset. After choosing the correct crystal, the player has to pull the lever again. This time 2 crystals will be struck by lightning. The player has to walk up to them again and choose the right ones but in the correct order. Whenever the player fails, the puzzle completely resets and only 1 lightning appears because he's back to level 1. Each time the player succeeds in remembering the order, there will be 1 more lightning to remember for the next level. The puzzle should go on like this until the player has beaten level 8 in which he had to remember the order of 8 lightnings. Please if someone could tell me how to event this, maybe I'm just to tired right now to think of it myself but as of now I just don't know how to do it efficiently.

Big thanks in advance for anyone with a solution!
I haven't gotten around to implementing something like this myself yet but basically, would I be correct in reading that the things need to be triggered in a specific order. This would just be a matter of switches, variables and conditional branches then. How about adding one to a specific variable each time something is done correctly and then setting conditional branches to the crystal and lever events so that unless the event is triggered at the correct variable count(s), the else happens which resets the variable back to 0 and also strikes the player instead of the event? Do you understand what I mean?
@Vincent Chu I've tried pretty much that but just ended up confusing myself with what I was doing, maybe it was because I was so tired. I will try again now.

Edit: I figured it out for 2 lightnings now so 2 levels now I have to scale it up to 8 and I see myself doing 100 mistakes during that process, I'm not sure if there's an easier solution to what I'm trying to do.
How about drawing a lever/switch and four rough circles on a piece of paper to represent it all first. Start counting the lever from 0 and then write down the numbers in order of what needs to be triggered until the puzzle is completed. Then you can have conditional branches saying if the variable is equal to the correct numbers, set the variable equal to the number above (or add one) and then the else to punish the player and reset the puzzle.
Driftwood Gaming has a tutorial on how to do this.
I don't think Drifty's tutorial applies here, there is no RNG and no "levels". The headache came with the 8 different levels my puzzle has. I managed to finish it earlier today and it works perfectly, but the event pages are very long and probably there would have been a more elegant solution. The animations, the lever and sounds are basically just placeholders but the puzzle works from a technical perspective, for anyone interested I made a recording of it:

Original thread: https://forums.rpgmakerweb.com/threads/how-do-i-event-this-puzzle.91887/