SDB is the correct sequence
twistedvoid.com/c3examples/KeySequencing
Download here:
twistedvoid.com/c3examples/KeySequencing.c3p
There's a timer. Each correct key adds 1 to the timer. Every tick the timer is reduced by the delta time. If it reaches 0, the sequence booleans are reset.
Here's the catch. You can do SDS. In which case, it looks at the second S as if you're restarting the sequence and resets the timer back to 1 second. Anything else is regarded as an invalid sequence.
Now, for just this one sequence, this will work fine. BUT, if you have a bunch of sequences, you'll need to play with array's.
And for those who just want to see the code:
| Global boolean SequenceCorrect1 = false
| Global number Countdown = 0
| Global boolean SequenceCorrect2 = false
+ Keyboard: On any key pressed
----+ System: Is SequenceCorrect2
--------+ Keyboard: B is down
---------> Text: Set text to "Correct Sequence"
--------+ System: Else
---------> System: Set SequenceCorrect1 to False
---------> System: Set SequenceCorrect2 to False
---------> Text: Set text to "Incorrect Sequence"
---------> System: Set Countdown to 0
----+ System: Is SequenceCorrect1
----+ System: [X] Is SequenceCorrect2
--------+ Keyboard: D is down
---------> System: Add 1 to Countdown
---------> System: Set SequenceCorrect2 to True
---------> Text: Set text to "Sequence 2 Completed"
--------+ System: Else
---------> System: Set SequenceCorrect1 to False
---------> Text: Set text to "Incorrect Sequence"
---------> System: Set Countdown to 0
----+ System: [X] Is SequenceCorrect1
----+ System: [X] Is SequenceCorrect2
--------+ Keyboard: S is down
---------> System: Set SequenceCorrect1 to True
---------> System: Set Countdown to 1
---------> Text: Set text to "Sequence 1 Completed"
--------+ System: Else
---------> System: Set SequenceCorrect1 to False
---------> Text: Set text to "Incorrect Sequence"
---------> System: Set Countdown to 0
+ System: Is SequenceCorrect1
-> System: Subtract dt from Countdown
----+ System: Countdown ≤ 0
-----> System: Set SequenceCorrect1 to False
-----> System: Set SequenceCorrect2 to False
-----> Text: Set text to "Incorrect Sequence"