[HELP] checking all the routes are explored

I am working on the Text101 exercise, I am trying to set it up so that you need to look through all the different options before you can continue. Is there a way I can have the code log each button pushed so once all three letters (for example: M for mirror, L for lock, and S for sheets) when all three of them letters are pushed in what ever order it sets a trigger to go to a different option. As it stands right now, my cell is the main room. I want the cell to stay the main room just with different text on it when all three letter are logged.

Here is a example of my Code:
Text 101 coding

what I want to do:
-Be able to log keys pressed so if 3 set keys are pressed
then a other script pops in and changes the text on the cell

It wouldn’t be the prettiest way but you could create a new string, routeTaken, and on each key press concatenate the key to the string. Then, check to see if routeTaken equals your specific sequence.


public class TextController : MonoBehaviour 
{

    private string routeTaken;
    private string magicSequence;

    // initialisation
    private void Start() 
    {
        // initialise variables
        routeTaken = "";
        magicSequence = "MSL";    // swap MSL with your required sequence
    }

    // update is called once every frame
    private void Update() 
    {
        // has sequence been performed correctly?
        if (routeTaken.ToUpper() == magicSequence.ToUpper())    // .ToUpper() uppercases the string variable(s) - so we don't need to worry about case when matching
        {
            // writing on the wall
            // set some flag or whatever you need to do
        }

        // existing state checking code

    }

    // you have existing State methods, this is just to demonstrate new lines of code
    private void StateMethodExample() 
    {
        text.text = "story blurb";

        if (Input.GetKeyDown(KeyCode.M)) 
        {
            // update the players route
            UpdatePlayersRoute();
        }
    }

    // update the route the player has taken
    private void UpdatePlayersRoute()
    {
        UpdateRouteTaken();
        TruncateRouteTaken();
    }

    // concatenates the players next step
    private void UpdateRouteTaken()
    {
        routeTaken += Input.inputString;
    }

    // truncates the route the player has taken to the length of magicSequence 
    private void TruncateRouteTaken()
    {
        routeTaken = routeTaken.Substring(Math.Max(0, routeTaken.Length - magicSequence.Length)); 
    }

}

See also;

One way of doing that is setting up key token variables; Essentially setting as many variables as possible the represent a key to a lock. In the case of this game, I would utilize a numeric value of 0 for locked and 1 for unlocked or use a bool variable for true and false instead.

I would set three variables for the first room as such:
Int lockCond1 = 0;
Int lockCond2 = 0;
Int lockCond3 = 0;

Then I would set an if statement for each key press sought:
if (Input.GetKeyDown(KeyCode.S)) {lockCond1 = 1;}
if (Input.GetKeyDown(KeyCode.M)) {lockCond2 = 1;}
if (Input.GetKeyDown(KeyCode.L)) {lockCond3 = 1;}

Then in one of the states add another if statement with the updated text
if ((lockCond1 == 1) && (lockCond2 == 1)&&(lockCond3 == 1)) {Updated text; new state call}
else {Original text}