Text Controller CS

Hello,
I’m having trouble playing the MonoDevelop code that I reluctantly saved and tried to play on Unity. Any help someone could give me would be much appreciated!
Thanks,
J

using UnityEngine;
using UnityEngine.UI;
using System.Collections;

public class TextController : MonoBehaviour {

	public Text text;
	
	private enum States {cell, mirror, sheets_0, lock_0, cell_mirror, sheets_1, lock_1, freedom};
	private States myState;
	
			// Use this for initialization
	void Start () {
		myState = States.cell;
	}
	
	// Update is called once per frame
	void Update () {
		print (myState);
		if (myState == States.cell) 				{state_cell();} 
		else if (myState == States.sheets_0) 		{state_sheets_0();} 
		else if (myState == States.sheets_1) 		{state_sheets_1();}	
		else if (myState == States.lock_0) 			{state_lock_0();} 
		else if (myState == States.lock_1) 			{state_lock_1();}	
		else if (myState == States.mirror) 			{state_mirror();} 
		else if (myState == States.cell_mirror) 	{state_cell_mirror();}	
		else if (myState == States.freedom)			{state_freedom();}	
	}
	
	
	void state_cell () {
		text.text = "You are in a prison cell and you want to escape. There are " + 
					"some dirty sheets on the bed, a mirror on the wall, and the door " + 
					"is locked from the outside.\n\n" +
					"Press S to view Sheets, M to view Mirror, and L to view Lock" ;
		if (Input.GetKeyDown(KeyCode.S)) 			{myState = States.sheets_0;
			else if (input.GetKeyDown(KeyCode.M))	{myState = States.mirror;
			else if (input.GetKeyDown(KeyCode.L))	{myState = States.lock_0_;
	}
	
	void state_mirror() {
		text.text = "It seems like you can easily rip it off of the wall. \n\n" +
					"press T to Take the mirror or R to Return to the cell."
		if (Input.GetKeyDown(KeyCode.T)) 			{myState = States.cell_mirror;}
		else if (Input.GetKeyDown(KeyCode.R)) 		{myState = States.cell;}	
		}	
	
	void cell_mirror() {
		text.text = "What are you waiting for? Now is the time to escape! \n\n" +
					"There are dirty sheets on the bed, a spot where the mirror was, " +
					"and that damn door is still locked!" n\n"
					"press T to Take the mirror or R to Return to the cell. " +
		if (Input.GetKeyDown(KeyCode.S)) 			{myState = States.sheets_1;}
		else if (Input.GetKeyDown(KeyCode.L)) 		{myState = States.lock_1;}	
	}	
	
	void state_sheets_0 () {
		text.text = "You can't believe you sleep in these filthy sheets every night. " + 
					"It has to be laundry day soon...you can't take prison life any longer. " + 
					"Time to get out of Dodge!\n\n" +
					"Press R to Return to roaming your cell" ;
		if (Input.GetKeyDown(KeyCode.R)) 			{myState = States.cell;
		}
	}
	
	
	void state_lock_0 () {
		text.text = "You try to jimmy the lock, but it's no use. Then you notice that there is a combination on the front, " + 
					"but you can't see the numbers. If only there was a way to show wehre the dirty fingerprints last touched " + 
					"You have to act quickly before a prison guard hears you.\n\n" +
					"Press R to Return to roaming your cell" ;
		if (Input.GetKeyDown(KeyCode.R)) 			{myState = States.cell;}
	}
	
	void state_lock_1 () {
		text.text = "You carefully stick the mirror through the bars and turn it around " + 
					"so you can see the numbers. You can barely make out the fingerprints around the buttons. " + 
					"You press the dirty buttons and hear a click!\n\n" +
					"Press O to Open or Press R to Return to roaming your cell" ;
		if (Input.GetKeyDown(KeyCode.O)) 			{myState = States.freedom;}
		else if (Input.GetKeyDown(KeyCode.R)) 		{myState = States.cell_mirror;}	
	}	

	void state_freedom () {
		text.text = "Congratulations, You are FREE!!!\n\n" +
					"Press P to play again" ;
		if (Input.GetKeyDown(KeyCode.p)) 			{myState = States.cell;}
		
	}

}

Missing the prefix state_ on this method name.

You need to ensure that the methods that you call in the if...else if... logic block within the Update() method actually exist. In this case, state_cell_mirror() didn’t exist.

MonoDevelop should underline this statement within the Update() to indicate it’s missing, the code should error when you try to run it.


	void state_mirror() {
		text.text = "It seems like you can easily rip it off of the wall. \n\n" +
					"press T to Take the mirror or R to Return to the cell."
		if (Input.GetKeyDown(KeyCode.T)) 			{myState = States.cell_mirror;}
		else if (Input.GetKeyDown(KeyCode.R)) 		{myState = States.cell;}	
	}

You are missing a semi-colon from the end of the text.text = "" statement, the code should error because of this.


	void cell_mirror() {
		text.text = "What are you waiting for? Now is the time to escape! \n\n" +
					"There are dirty sheets on the bed, a spot where the mirror was, " +
					"and that damn door is still locked!" n\n"
					"press T to Take the mirror or R to Return to the cell. " +
		if (Input.GetKeyDown(KeyCode.S)) 			{myState = States.sheets_1;}
		else if (Input.GetKeyDown(KeyCode.L)) 		{myState = States.lock_1;}	
	}

You are missing a semi-colon from the end of the text.text = "" statement, you also have an extra + there which is unnecessary. The code should error because of this.


Hope this helps.

Hi Rob,
Thanks a lot for responding to thread. I really appreciate your help, but I am still having trouble with a few sections of the

void cell_mirror() {

I hate being a bother at this point…I’m brand new to coding …

void state_mirror() {
			text.text = "It seems like you can easily rip it off of the wall. \n\n" +
						"press T to Take the mirror or R to Return to the cell." ;
			if (Input.GetKeyDown(KeyCode.T)) 		{myState = States.cell_mirror;}
			else if (Input.GetKeyDown(KeyCode.R)) 	{myState = States.cell;}	
		}	
	
				
	void state.cell_mirror() {
		text.text = "What are you waiting for? Now is the time to escape! \n\n" +
					"There are dirty sheets on the bed, a spot where the mirror was, " +
					"and that damn door is still locked!" n\n"
					"press T to Take the mirror or R to Return to the cell. " ;
		if (Input.GetKeyDown(KeyCode.S)) {myState = States.sheets_1;}
		else if (Input.GetKeyDown(KeyCode.L)) {myState = States.lock_1;}	
}
		
	void state_sheets_0() {
		text.text = "You can't believe you sleep in these filthy sheets every night. " + 
					"It has to be laundry day soon...you can't take prison life any longer. " + 
					"Time to get out of Dodge! \n\n" +
					"Press R to Return to roaming your cell" ;
		if (Input.GetKeyDown(KeyCode.R)) 			{myState = States.cell;}		
	}

Not sure if this will help, but here is the entire code:

using UnityEngine;
using UnityEngine.UI;
using System.Collections;

public class TextController : MonoBehaviour {

	public Text text;
	
	private enum States {cell, sheets_0, sheets_1, lock_0, lock_1, mirror, cell_mirror, freedom};
	private States myState;
	
			// Use this for initialization
	void Start () {
		myState = States.cell;
	}
	
	// Update is called once per frame
	void Update () {
		print (myState);
		
		if (myState == States.cell) 				{state_cell();}
		else if (myState == States.sheets_0) 		{state_sheets_0();}
		else if (myState == States.sheets_1) 		{state_sheets_1();}
		else if (myState == States.lock_0) 			{state_lock_0();}
		else if (myState == States.lock_1) 			{state_lock_1();}
		else if (myState == States.mirror) 			{state_mirror();}
		else if (myState == States.cell_mirror) 	{state_cell_mirror();}
		else if (myState == States.freedom) 		{state_freedom();}
		
	}
	
	
	void state_cell () {
		text.text = "You are in a prison cell and you want to escape. There are " + 
					"some dirty sheets on the bed, a mirror on the wall, and the door " + 
					"is locked from the outside.\n\n" +
					"Press S to view Sheets, M to view Mirror, and L to view Lock" ;
		if (Input.GetKeyDown(KeyCode.S)) 			{myState = States.sheets_0;
			else if (input.GetKeyDown(KeyCode.M))	{myState = States.mirror;
			else if (input.GetKeyDown(KeyCode.L))	{myState = States.lock_0_;
	}
	
	
	void state_mirror() {
			text.text = "It seems like you can easily rip it off of the wall. \n\n" +
						"press T to Take the mirror or R to Return to the cell." ;
			if (Input.GetKeyDown(KeyCode.T)) 		{myState = States.cell_mirror;}
			else if (Input.GetKeyDown(KeyCode.R)) 	{myState = States.cell;}	
		}	
	
				
	void state.cell_mirror() {
		text.text = "What are you waiting for? Now is the time to escape! \n\n" +
					"There are dirty sheets on the bed, a spot where the mirror was, " +
					"and that damn door is still locked!" n\n"
					"press T to Take the mirror or R to Return to the cell. " ;
		if (Input.GetKeyDown(KeyCode.S)) {myState = States.sheets_1;}
		else if (Input.GetKeyDown(KeyCode.L)) {myState = States.lock_1;}	
}
		
	void state_sheets_0() {
		text.text = "You can't believe you sleep in these filthy sheets every night. " + 
					"It has to be laundry day soon...you can't take prison life any longer. " + 
					"Time to get out of Dodge! \n\n" +
					"Press R to Return to roaming your cell" ;
		if (Input.GetKeyDown(KeyCode.R)) 			{myState = States.cell;}		
	}
	
	
	void state_lock_0 () {
		text.text = "You try to jimmy the lock, but it's no use. Then you notice that there is a combination on the front, " + 
					"but you can't see the numbers. If only there was a way to show wehre the dirty fingerprints last touched " + 
					"You have to act quickly before a prison guard hears you.\n\n" +
					"Press R to Return to roaming your cell" ;
		if (Input.GetKeyDown(KeyCode.R)) 			{myState = States.cell;}
	}
	
	void state_lock_1 () {
		text.text = "You carefully stick the mirror through the bars and turn it around " + 
					"so you can see the numbers. You can barely make out the fingerprints around the buttons. " + 
					"You press the dirty buttons and hear a click!\n\n" +
					"Press O to Open or Press R to Return to roaming your cell" ;
		if (Input.GetKeyDown(KeyCode.O)) 			{myState = States.freedom;}
		else if (Input.GetKeyDown(KeyCode.R)) 		{myState = States.cell_mirror;}	
	}	

	void state_freedom () {
		text.text = "Congratulations, You are FREE!!!\n\n" +
					"Press P to play again" ;
		if (Input.GetKeyDown(KeyCode.p)) 			{myState = States.cell;}
		
	}

}

Hello Jon,

Don’t worry, it really isn’t any bother at all, this is what the community is here for, to help and support each other.

Couple of things I’m noticing is that the issues you are having are typically the same each time, so, to recap before I go into details below. Where ever you have anything opening such as brackets, braces or quotations marks, you will invariably need the corresponding closing bracket, brace or quotation mark. e.g;

( )
{ }
" "

In the case of the braces, it is highly likely that these will not always be on the same line.

Where you start a code block with void these are what we refer to as methods. If you want to call a method you need to ensure that it’s name is spelt exactly the same in both the calling statement and the actual method name itself, e.g;

void Start() {
    RunMyAwesomeGame();
}

void RunMyAwsomeGame() {
    // do stuff
}

The above wouldn’t work because, if you look carefully you can see that I have mis-spelt the method name, as such the calling statement will be unable to find this method.

So let’s get to work and see what we need to change…


void state_cell () {
		text.text = "You are in a prison cell and you want to escape. There are " + 
					"some dirty sheets on the bed, a mirror on the wall, and the door " + 
					"is locked from the outside.\n\n" +
					"Press S to view Sheets, M to view Mirror, and L to view Lock" ;
		if (Input.GetKeyDown(KeyCode.S)) 			{myState = States.sheets_0;
			else if (input.GetKeyDown(KeyCode.M))	{myState = States.mirror;
			else if (input.GetKeyDown(KeyCode.L))	{myState = States.lock_0_;
	}

The text.text= statement is fine, there is a + on each line apart from the last one, so each of the previous lines are concatenated together. Each part of the text being concatenated is within both opening and closing quotation marks and there is a semi-colon to indicate the end of the statement - great!

In the if statement however there are some closing braces missing;

	if (Input.GetKeyDown(KeyCode.S)) 			{myState = States.sheets_0;   // missing a closing brace after the semi-colon
		else if (input.GetKeyDown(KeyCode.M))	{myState = States.mirror;    // missing a closing brace after the semi-colon
		else if (input.GetKeyDown(KeyCode.L))	{myState = States.lock_0_;    // missing a closing brace after the semi-colon and there's an extra underscore on the end

	void state.cell_mirror() {
		text.text = "What are you waiting for? Now is the time to escape! \n\n" +
					"There are dirty sheets on the bed, a spot where the mirror was, " +
					"and that damn door is still locked!" n\n"
					"press T to Take the mirror or R to Return to the cell. " ;
		if (Input.GetKeyDown(KeyCode.S)) {myState = States.sheets_1;}
		else if (Input.GetKeyDown(KeyCode.L)) {myState = States.lock_1;}	
}

The method name has a . in it instead of an _, it should read;

void state_cell_mirror() {

There is a missing + to concatenate the strings in the text below, along with an extra " mark before the n\n which should be \n\n;

		text.text = "What are you waiting for? Now is the time to escape! \n\n" +
					"There are dirty sheets on the bed, a spot where the mirror was, " +
					"and that damn door is still locked!" n\n"    // missing a `+` on the end of this line, extra `"`, should be `\n\n`
					"press T to Take the mirror or R to Return to the cell. " ;

Also, if you look at your story text in this code block, and your if statement logic. You are telling the player to press T to Take the mirror or R to Return to the cell, but then you are checking for a keypress of S or L. This has probably come from copying and pasting blocks of the code around.


In the following text you have a lower case p in the if statement where you are checking for the keypress, this needs to be capitalised.

void state_freedom () {
	text.text = "Congratulations, You are FREE!!!\n\n" +
				"Press P to play again" ;
	if (Input.GetKeyDown(KeyCode.p)) 			{myState = States.cell;}    // capitalise the `p` - KeyCode.P etc
	
}

Try making the changes above and then see if things are working more smoothly.

Hope this helps.

Hi Rob,
Thanks again for your correction suggestions. I feel like I’ve made all of the changes that you pointed out, but for some reason, I’m still getting a compiler error message. I’ve posted the latest code changes below.

using UnityEngine;
using UnityEngine.UI;
using System.Collections;

public class TextController : MonoBehaviour {

	public Text text;
	
	private enum States {cell, sheets_0, sheets_1, lock_0, lock_1, mirror, cell_mirror, freedom};
	private States myState;
	
			// Use this for initialization
	void Start () {
		myState = States.cell;
	}
	
	// Update is called once per frame
	void Update () {
		print (myState);
		
		if (myState == States.cell) 				{state_cell();}
		else if (myState == States.sheets_0) 		{state_sheets_0();}
		else if (myState == States.sheets_1) 		{state_sheets_1();}
		else if (myState == States.lock_0) 			{state_lock_0();}
		else if (myState == States.lock_1) 			{state_lock_1();}
		else if (myState == States.mirror) 			{state_mirror();}
		else if (myState == States.cell_mirror) 	{state_cell_mirror();}
		else if (myState == States.freedom) 		{state_freedom();}
		
	}
	
	
	void state_cell () {
		text.text = "You are in a prison cell and you want to escape. There are " + 
					"some dirty sheets on the bed, a mirror on the wall, and the door " + 
					"is locked from the outside.\n\n" +
					"Press S to view Sheets, M to view Mirror, and L to view Lock" ;
			if (Input.GetKeyDown(KeyCode.S)) 		{myState = States.sheets_0;}
			else if (input.GetKeyDown(KeyCode.M))	{myState = States.mirror;}
			else if (input.GetKeyDown(KeyCode.L))	{myState = States.lock_0_;}
	}
	
	
	void state_mirror() {
		text.text = "It seems like you can easily rip it off of the wall. \n\n" +
					"press T to Take the mirror or R to Return to the cell." ;
			if (Input.GetKeyDown(KeyCode.T)) 		{myState = States.cell_mirror;}
			else if (Input.GetKeyDown(KeyCode.R)) 	{myState = States.cell;}	
	}	
	
				
	void state_cell_mirror() {
		text.text = "What are you waiting for? Now is the time to escape! " +
					"There are dirty sheets on the bed, a spot where the mirror was, " +
					"and that damn door is still locked! \n\n" +
					"press T to Take the mirror or R to Return to the cell." ;
		
			if (Input.GetKeyDown(KeyCode.T)) 		{myState = States.cell_mirror;}
			else if (Input.GetKeyDown(KeyCode.R)) 	{myState = States.cell;}
	}
		
	void state_sheets_0() {
		text.text = "You can't believe you sleep in these filthy sheets every night. " + 
					"It has to be laundry day soon...you can't take prison life any longer. " + 
					"Time to get out of Dodge! \n\n" +
					"Press R to Return to roaming your cell" ;
			if (Input.GetKeyDown(KeyCode.R)) 		{myState = States.cell;}		
	}
	
	
	void state_lock_0 () {
		text.text = "You try to jimmy the lock, but it's no use. Then you notice that there is a combination on the front, " + 
					"but you can't see the numbers. If only there was a way to show wehre the dirty fingerprints last touched " + 
					"You have to act quickly before a prison guard hears you. \n\n" +
					"Press R to Return to roaming your cell" ;
			if (Input.GetKeyDown(KeyCode.R)) 		{myState = States.cell;}
	}
	
	void state_lock_1 () {
		text.text = "You carefully stick the mirror through the bars and turn it around " + 
					"so you can see the numbers. You can barely make out the fingerprints around the buttons. " + 
					"You press the dirty buttons and hear a click! \n\n" +
					"Press O to Open or Press R to Return to roaming your cell" ;
			if (Input.GetKeyDown(KeyCode.O)) 		{myState = States.freedom;}
			else if (Input.GetKeyDown(KeyCode.R)) 	{myState = States.cell_mirror;}	
	}	

	void state_freedom () {
		text.text = "Congratulations, You are FREE!!! \n\n" +
					"Press P to play again" ;
			if (Input.GetKeyDown(KeyCode.P)) 		{myState = States.cell;}
		
	}

}
void state_cell () {
		text.text = "You are in a prison cell and you want to escape. There are " + 
					"some dirty sheets on the bed, a mirror on the wall, and the door " + 
					"is locked from the outside.\n\n" +
					"Press S to view Sheets, M to view Mirror, and L to view Lock" ;
			if (Input.GetKeyDown(KeyCode.S)) 		{myState = States.sheets_0;}
			else if (input.GetKeyDown(KeyCode.M))	{myState = States.mirror;}
			else if (input.GetKeyDown(KeyCode.L))	{myState = States.lock_0_;}
	}

You still have that renegade _ at the end of that last line… States.lock_0_

:slight_smile:

Hi Rob,
Thanks for the quick reply! I changed the {States.lock_0_;}

but I am still getting a compiler error:

using UnityEngine;
using UnityEngine.UI;
using System.Collections;

public class TextController : MonoBehaviour {

	public Text text;
	
	private enum States {cell, sheets_0, sheets_1, lock_0, lock_1, mirror, cell_mirror, freedom};
	private States myState;
	
			// Use this for initialization
	void Start () {
		myState = States.cell;
	}
	
	// Update is called once per frame
	void Update () {
		print (myState);
		
		if (myState == States.cell) 				{state_cell();}
		else if (myState == States.sheets_0) 		{state_sheets_0();}
		else if (myState == States.sheets_1) 		{state_sheets_1();}
		else if (myState == States.lock_0) 			{state_lock_0();}
		else if (myState == States.lock_1) 			{state_lock_1();}
		else if (myState == States.mirror) 			{state_mirror();}
		else if (myState == States.cell_mirror) 	{state_cell_mirror();}
		else if (myState == States.freedom) 		{state_freedom();}
		
	}
	
	
	void state_cell () {
		text.text = "You are in a prison cell and you want to escape. There are " + 
					"some dirty sheets on the bed, a mirror on the wall, and the door " + 
					"is locked from the outside.\n\n" +
					"Press S to view Sheets, M to view Mirror, and L to view Lock" ;
			if (Input.GetKeyDown(KeyCode.S)) 		{myState = States.sheets_0;}
			else if (input.GetKeyDown(KeyCode.M))	{myState = States.mirror;}
			else if (input.GetKeyDown(KeyCode.L))	{myState = States.lock_0;}
	}
	
	
	void state_mirror() {
		text.text = "It seems like you can easily rip it off of the wall. \n\n" +
					"press T to Take the mirror or R to Return to the cell." ;
			if (Input.GetKeyDown(KeyCode.T)) 		{myState = States.cell_mirror;}
			else if (Input.GetKeyDown(KeyCode.R)) 	{myState = States.cell;}	
	}	
	
				
	void state_cell_mirror() {
		text.text = "What are you waiting for? Now is the time to escape! " +
					"There are dirty sheets on the bed, a spot where the mirror was, " +
					"and that damn door is still locked! \n\n" +
					"press T to Take the mirror or R to Return to the cell." ;
		
			if (Input.GetKeyDown(KeyCode.T)) 		{myState = States.cell_mirror;}
			else if (Input.GetKeyDown(KeyCode.R)) 	{myState = States.cell;}
	}
		
	void state_sheets_0() {
		text.text = "You can't believe you sleep in these filthy sheets every night. " + 
					"It has to be laundry day soon...you can't take prison life any longer. " + 
					"Time to get out of Dodge! \n\n" +
					"Press R to Return to roaming your cell" ;
			if (Input.GetKeyDown(KeyCode.R)) 		{myState = States.cell;}		
	}
	
	
	void state_lock_0 () {
		text.text = "You try to jimmy the lock, but it's no use. Then you notice that there is a combination on the front, " + 
					"but you can't see the numbers. If only there was a way to show wehre the dirty fingerprints last touched " + 
					"You have to act quickly before a prison guard hears you. \n\n" +
					"Press R to Return to roaming your cell" ;
			if (Input.GetKeyDown(KeyCode.R)) 		{myState = States.cell;}
	}
	
	void state_lock_1 () {
		text.text = "You carefully stick the mirror through the bars and turn it around " + 
					"so you can see the numbers. You can barely make out the fingerprints around the buttons. " + 
					"You press the dirty buttons and hear a click! \n\n" +
					"Press O to Open or Press R to Return to roaming your cell" ;
			if (Input.GetKeyDown(KeyCode.O)) 		{myState = States.freedom;}
			else if (Input.GetKeyDown(KeyCode.R)) 	{myState = States.cell_mirror;}	
	}	

	void state_freedom () {
		text.text = "Congratulations, You are FREE!!! \n\n" +
					"Press P to play again" ;
			if (Input.GetKeyDown(KeyCode.P)) 		{myState = States.cell;}
		
	}

}

Hi Jon,

[S]Can you give me the details of the error or a screenshot please.[/S]


Updated Thu Feb 16 2017 00:55

You are missing a method.

You dont appear to have the state_sheets_1() method, but are calling it from within the Update() method.

Hi Rob,

OK, I updated the state_sheets_1( ) method, but it appears that I am having a problem with the “input”

I’ve attached the most recent code along with a screenshot the compiler error message.

using UnityEngine;
using UnityEngine.UI;
using System.Collections;

public class TextController : MonoBehaviour {

	public Text text;
	
	private enum States {cell, sheets_0, sheets_1, lock_0, lock_1, mirror, cell_mirror, freedom};
	private States myState;
	
			// Use this for initialization
	void Start () {
		myState = States.cell;
	}
	
	// Update is called once per frame
	void Update () {
		print (myState);
		
		if (myState == States.cell) 				{state_cell();}
		else if (myState == States.sheets_0) 		{state_sheets_0();}
		else if (myState == States.sheets_1) 		{state_sheets_1();}
		else if (myState == States.lock_0) 			{state_lock_0();}
		else if (myState == States.lock_1) 			{state_lock_1();}
		else if (myState == States.mirror) 			{state_mirror();}
		else if (myState == States.cell_mirror) 	{state_cell_mirror();}
		else if (myState == States.freedom) 		{state_freedom();}
		
	}
	
	
	void state_cell () {
		text.text = "You are in a prison cell and you want to escape. There are " + 
					"some dirty sheets on the bed, a mirror on the wall, and the door " + 
					"is locked from the outside.\n\n" +
					"Press S to view Sheets, M to view Mirror, and L to view Lock" ;
			if (Input.GetKeyDown(KeyCode.S)) 		{myState = States.sheets_0;}
			else if (input.GetKeyDown(KeyCode.M))	{myState = States.mirror;}
			else if (input.GetKeyDown(KeyCode.L))	{myState = States.lock_0;}
	}
	
	
	void state_mirror() {
		text.text = "It seems like you can easily rip it off of the wall. \n\n" +
					"press T to Take the mirror or R to Return to the cell." ;
			if (Input.GetKeyDown(KeyCode.T)) 		{myState = States.cell_mirror;}
			else if (Input.GetKeyDown(KeyCode.R)) 	{myState = States.cell;}	
	}	
	
				
	void state_cell_mirror() {
		text.text = "What are you waiting for? Now is the time to escape! " +
					"There are dirty sheets on the bed, a spot where the mirror was, " +
					"and that damn door is still locked! \n\n" +
					"press T to Take the mirror or R to Return to the cell." ;
		
			if (Input.GetKeyDown(KeyCode.T)) 		{myState = States.cell_mirror;}
			else if (Input.GetKeyDown(KeyCode.R)) 	{myState = States.cell;}
	}
		
	void state_sheets_0() {
		text.text = "You can't believe you sleep in these filthy sheets every night. " + 
					"It has to be laundry day soon...you can't take prison life any longer. " + 
					"Time to get out of Dodge! \n\n" +
					"Press R to Return to roaming your cell" ;
			if (Input.GetKeyDown(KeyCode.R)) 		{myState = States.cell;}		
	}
	
	void state_sheets_1() {
		text.text = "What are you doing just standing there holding a mirror? Hurry up " +
					"and get out of this cell! \n\n" +
					"Press R to Return to roaming your cell" ;
			if (Input.GetKeyDown(KeyCode.R)) {myState = States.cell_mirror;}
	}
	
	void state_lock_0 () {
		text.text = "You try to jimmy the lock, but it's no use. Then you notice that there is a combination on the front, " + 
					"but you can't see the numbers. If only there was a way to show wehre the dirty fingerprints last touched " + 
					"You have to act quickly before a prison guard hears you. \n\n" +
					"Press R to Return to roaming your cell" ;
			if (Input.GetKeyDown(KeyCode.R)) 		{myState = States.cell;}
	}
	
	void state_lock_1 () {
		text.text = "You carefully stick the mirror through the bars and turn it around " + 
					"so you can see the numbers. You can barely make out the fingerprints around the buttons. " + 
					"You press the dirty buttons and hear a click! \n\n" +
					"Press O to Open or Press R to Return to roaming your cell" ;
			if (Input.GetKeyDown(KeyCode.O)) 		{myState = States.freedom;}
			else if (Input.GetKeyDown(KeyCode.R)) 	{myState = States.cell_mirror;}	
	}	

	void state_freedom () {
		text.text = "Congratulations, You are FREE!!! \n\n" +
					"Press P to play again" ;
			if (Input.GetKeyDown(KeyCode.P)) 		{myState = States.cell;}
		
	}

}

Your void state_cell() has two lines where Input has a lower case i. The C# syntax is case-sensitive. Change these to upper case i.

That “aha” moment when everything runs properly…Thank you so much for your help on this topic!
-Jon

1 Like

Hi Jon, you are more than welcome. Glad to have helped :slight_smile:

1 Like