Text101 Adventure

Hi,

I used the script provided from the Udemy lesson, and adapted it for my own adventiure, however UNITY is throwing up these console errors:

Assets/TMOWM/Scripts/TextController.cs(51,0): error CS1010: Newline in constant

on a number of lines, and:

Assets/TMOWM/Scripts/TextController.cs(51,7): error CS1525: Unexpected symbol `You’

Assets/TMOWM/Scripts/TextController.cs(125,26): error CS1525: Unexpected symbol `Frantically’

many times too.

I have compared code and cannot see why MonoDevlop dislikes my code, yet dreamweaver shows no red text?

Please review code below and help!

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

public class TextController : MonoBehaviour {

public Text text;

private enum States {
	land, mirror, walkon, turnaround, run, closer_mirror, picnic, north, east, forward, examine_ropebridge,
	charge, rope, burst, jump, left, door, right, reach_rope, slat, go, quit
};
private States myState;

// Use this for initialization
void Start () {
	myState = States.land;
}

// Update is called once per frame
void Update () {
	print (myState);
	if 	(myState == States.land) 				{land();}
	else if (myState == States.turnaround) 		{turnaround();}
	else if (myState == States.picnic) 			{picnic();}
	else if (myState == States.run) 			{run();}
	else if (myState == States.north) 			{north();}
	else if (myState == States.mirror) 			{mirror();}
	else if (myState == States.closer_mirror) 	{closer_mirror();}
	else if (myState == States.east) 			{east();}
	else if (myState == States.forward) 		{forward();}
	else if (myState == States.examine_ropebridge) 	{examine_ropebridge();}
	else if (myState == States.charge) 			{charge();}
	else if (myState == States.rope) 			{rope();}
	else if (myState == States.burst) 			{burst();}
	else if (myState == States.jump) 			{jump();}
	else if (myState == States.left) 			{left();}
	else if (myState == States.right) 			{right();}
	else if (myState == States.door) 			{door();}
	else if (myState == States.walkon) 			{walkon();}
	else if (myState == States.reach_rope) 		{reach_rope();}
	else if (myState == States.slat) 			{slat();}
	else if (myState == States.go) 				{go();}
	else if (myState == States.quit) 			{quit();}
}

void door() {
	text.text = "The door opens with a creak, and tiny flecks of dust fall into " +
		"the air as the decrepit wood opens, revealing a dark " +
		"void. You hear a soft wailing sound coming from deep inside.” +
		"You walk into the gaping chasm. Sudden Brightness fills your vision " +
		"and a loud scream pierces your eardrums. Your eyes adjust to the light " +
		"and you see that you are still in the forest, but it is now becoming dusk. ” + 
		"A half eaten picnic is laid out in front of you. \n\n" +
		"Press P to inspect the Picnic, D to go back through the door " +
		"Or W to walk on”;
		if 		(Input.GetKeyDown(KeyCode.P)) 	{myState = States.picnic;}
		else if (Input.GetKeyDown(KeyCode.D)) 	{myState = States.door;}
		else if (Input.GetKeyDown(KeyCode.W)) 	{myState = States.walkon;}
		}

void picnic() {
	text.text = "You bend down onto one knee to get a better view of the discarded picnic " +
		"The sight before your eyes makes you hold your mouth to stifle vomit. " +
		"Wine glasses full of dark, thick black liquid stand on a blanket baked in " +
		"squished bugs and maggots. Rotting chicken and hunks of cheese move and roll " +
		"under the hoard of spiders and worms that delight in the dying, fleshy mass. " +
		"You fall back in disgust onto the forest floor. As you begin to scramble to your feet, " +
		"you hear a word whispered into your ear, as if someone, or something, is standing behind you. " +
		"‘Dream or Nightmare?’ the emotionless voice asks. \n\n" +
		"Press T to Turnaround and face the whisperer or R to RUN forwards";
	if (Input.GetKeyDown(KeyCode.R)) 		{myState = States.run;}
	else if (Input.GetKeyDown(KeyCode.T)) 	{myState = States.turnaround;}

}

void turnaround() {
	text.text = "As fear fills your lungs, and panic fills your mind, you slowly turn your head, toward the mysterious " +
		"voice. Time seems to trickle past like syrup from a spoon, until finally your gaze rests " +
		"on the perpetrator. A suited man, with white gloves and a porcelain mask with the biggest nose " +
		"perturbing towards your face greets your vision. And it is the last thing you see as a vile " +
		"black sticky liquid shoots from the hooter, covering your face, sliding and relieving you " +
		"of breath and life. You are dead. \n\n" +
		"Press S to start again" ;
	if 		(Input.GetKeyDown(KeyCode.S)) 	{myState = States.land;}		
}

void run() {
	text.text = "You lunge forward, hands falling into the spider and maggot goo in front of you, black ooze " +
		"covers your hands and shirt. But you do not care, for sheer instinct helps you clamber " +
		"to your feet and quickly fall into a sprint. You pound your feet one after the other " +
		"in front of you, and you don’t stop until you feel that suitable distance is between you " +
		"and whatever it was that spoke into your ear. You stop, hands on knees, hunched over " +
		"catching your breath. Minutes pass, and once breathing becomes easy again, you look around " +
		"to find that you are now deep into the forest. Branches arch close above your head " +
		"and sharp claw like twigs seem to grab at you in the near darkness. " +
		"There seems to be a path through the trees to the North and a dirtied thin stone path to the East. \n\n" +
		"Press N to go North, and E to go East.";
	if 		(Input.GetKeyDown(KeyCode.N)) 	{myState = States.North;}
	else if (Input.GetKeyDown(KeyCode.E)) 	{myState = States.East;}
}

void north() {
	text.text = "You head North, clambering through the undergrowth, pushing and moving sharp branches and twigs from " +
		"above and beside you. Suddenly, hundreds of rustling sounds fill the silence as your arms " +
		"are pulled tight to your sides and your legs clamped together. The trees have come alive and are ” +
		"tearing at your skin and tightening around you. Within seconds you are mummified by bark, and " +
		"launched into the air to become one with the forest for eternity. You are dead. \n\n" +
			"Press S to start again" ;
		if 		(Input.GetKeyDown(KeyCode.S)) 	{myState = States.land;}	
}

void east () {
	text.text = "You quickly make your way down the thin stone path, marvelling at how quickly the forest opens up to reveal " +
		"a vast cavern, topped with a thin rope bridge that offers safety across. Another strange " +
		"wooden door waits ajar on the other side, anticipating your arrival. As you begin to approach the bridge" +
	"a loud laugh punctures the air, as the suited big nosed nightmare shuffles into view. He raises " +
	"a hand and beckons you forward. \n\n" +
	"Press F to walk Forward, or E to Examine the ropebridge.” ;
	if 		(Input.GetKeyDown(KeyCode.F)) 	{myState = States.forward;}
	else if (Input.GetKeyDown(KeyCode.E)) 	{myState = examine_ropebridge;}
}	

void examine_ropebridge () {
	text.text = "Frantically looking left and right for options, you notice that the ropebridge is loosely tied together, " +
		"and a stray piece of rope hangs free. As this information registers in your brain, you here " +
		"footsteps creaking on the wooden slats of the bridge. The beast is coming. \n\n" +
		"Press R to pull the Rope, or C to Charge” ;
		if 		(Input.GetKeyDown(KeyCode.R)) 		{myState = States.rope;}
		else if (Input.GetKeyDown(KeyCode.C)) 	{myState = States.charge;}

		}	

void charge () {
	text.text = "You take a deep breath and charge towards the abomination. The suited nightmare tilts its head back, " +
		"it’s nose towering above it’s cold porcelain mask into the night air. A roar from its throat " +
		"fills your ears. It breaks into a run. You freeze, all your bravery disintegrates into a shroud of fear " +
		"Before you have a chance to turn and run, the monster pierces your chest with its vast nose, " +
		"breaking flesh and bone. Your eyes glaze over as life leaves your body. You are dead. \n\n" +
		"Press S to start again" ;
	if 		(Input.GetKeyDown(KeyCode.S)) 	{myState = States.land;}
}

void forward () {
	text.text = "You begin your approach warily, one foot in front of the other. The creature leans its porcelain mask to the side, " +
		"as if regarding your bravery as curious. You continue to approach the creature, but with no actual plan " +
		"as to what to do when you get close enough to the creature. As this thought goes through your mind, " +
		"so does a long, white gloved finger from the beasts hand. It is your final thought, as blood trickles " +
		"the back of your head, where the finger has burst through your skull. You are dead. \n\n" +
		"Press S to start again" ;
	if 		(Input.GetKeyDown(KeyCode.S)) 	{myState = States.land;}
}

void rope() {
	text.text = "You quickly reach for the rope, time is of the essence as the porcelain masked monster makes his way " +
		"toward you with haste. You tug at the rope. With the first pull the bridge drops a foot, " +
		"throwing the monster off guard momentarily. There is only two yards between you and it now.
		"You tug again. The rope unravels and the bridge falls eight feet downwards. The creature falls " +
		"onto its back, scrambling to grab the side of the bridge. Realising that you’re only exit " +
		"is the strange door across the bridge, you recognise you have one chance to get across " +
		"the slowly falling bridge. \n\n" +
		"Press J to Jump onto the bridge, or B to start Burst into tears";
	if 		(Input.GetKeyDown(KeyCode.J)) 		{myState = States.jump;}
	else if (Input.GetKeyDown(KeyCode.B)) 	{myState = States.burst;}
}

void land () {
	text.text = "You wake up in the Land Of Dreams. Where nothing " +
		"is how it seems. The trees are blue and the sky is green. " +
		"You see a door in front of you and a mirror floating in the air.\n\n" +
		"Press D to go through the door and M to view Mirror" ;
	if 		(Input.GetKeyDown(KeyCode.D)) 	{myState = States.door;}
	else if (Input.GetKeyDown(KeyCode.M)) 	{myState = States.mirror;}

}

void mirror() {
	text.text = "You look in the mirror but you see no reflection, " +
		"although the woodland behind you is visible. As you peer closer ” +					
		"you see a movement in the reflection of the trees… \n\n" +
		"Press L to Look closer into the mirror, or D to go through the door" ;
	if 		(Input.GetKeyDown(KeyCode.L)) 	{myState = States.closer_mirror;}
	else if (Input.GetKeyDown(KeyCode.D)) 	{myState = States.cell;}
}

void closer_mirror() {
	text.text = "You peer forward, squinting ever so to make sense of the movement in the trees. " +
		"maybe it was just a figment of your imagination? You think. " +
		"To your shock and horror, a horrific face bursts into view, "
		"a face that is like a porcelain mask, with a huge protruding nose " +
		"that somehow manages to burst through the mirror frame and into your mouth! " +
		"As you manage to look deep into the souls eyes of the mask wearing, suited " +
		"monster, a hot black liquid shoots from it’s nose, and burns out your insides.” +
		"You are dead. \n\n" +
		"Press S to start again" ;
	if 		(Input.GetKeyDown(KeyCode.S)) 	{myState = States.land;}

}

void burst () {
	text.text = "You fall to your knees and let the tears come. You have given up, this is all to much. ” +
		"You rest your head on your knees and let the end come swiftly and and as painless as possible. " +
		"Neither are rewarded to you, as the diabolical masked thing, kills you slowly and in the most " +
		"twisted way imaginable. You are dead. \n\n" +
		"Press S to start again" ;
	if 		(Input.GetKeyDown(KeyCode.S)) 	{myState = States.land;}
}


void jump() {
	text.text = "You leap forwards, throwing your arm out to grab onto the falling bridge before it is out of reach. Luck is " +
		"on your side this time and you catch onto the second to last wooden slate, that saves you from " +
		"the bottomless pit beneath you. You look above you and see the suited monster hanging three yards above you. " +
		"It is staring straight at you. But suddenly turns its attention to the top of the rope bridge " +
		"and begins to climb. It is now a race to the top. As you both begin your ascent, you notice that " +
		"the creature has caught itself in a piece of looping rope that falls all the way down beside you. " +
		"However, it is slightly obscured by another rope. Which one will you pull? \n\n" +
		"Press L to pull the Left rope, or R to pull the Right rope." ;
	if 		(Input.GetKeyDown(KeyCode.L)) 	{myState = States.left;}
	else if (Input.GetKeyDown(KeyCode.R)) 	{myState = States.right;}
}

void left() {
	text.text = "You reach to grab the rope on your left with all your might, and in doing so, pull on the leg of the " +
		"ascending suited oddity. It turns to look at what is stopping its ascension and begins to raise " +
		"it’s arm to unleash some fury at you. You pull again, this time letting go of the wooden slat and " +
		"allowing all your weight to pull on the beasts leg. With a roar, the suited monster loses it’s grip
		"on the slats, and begins to fall. This means that you are now free falling to your death too.\n\n " +
		"Press S to reach for the wooden Slat, or R to Reach for the rope" ;
	if 		(Input.GetKeyDown(KeyCode.S)) 	{myState = States.slat;}
	else if (Input.GetKeyDown(KeyCode.R)) 	{myState = States.reach_rope;}
}

void right() {
	text.text = "You reach to grab the rope on your left with all your might, and in doing so, pull the rope that ties the ” +
		"rope bridge to the other side of the chasm. The knot unravels and falls away. Your eyes widen with ” +
		"shock as the whole rope bridge creaks and ten falls away, almost in slow motion, bringing you and " +
		"the giant nosed monster with it. You eventually die of hunger as you fall forever. \n\n" +
		"Press S to start again" ;
	if 		(Input.GetKeyDown(KeyCode.S)) 	{myState = States.land;}


}
void reach_rope() {
	text.text = "As you feel gravity turn against you and begin to fall, you reach for the rope that seems attached to the " +
		"ropebridge. Unfortunately, it is not attached to the ropebridge, and is just a loose piece. " +
		"You begin to fall to your death, but rather than falling forever down a bottomless chasm, " +
		"the masked monster grabs you and ensures your life is snuffed out in a short but painful " +
		"manner, by sucking your brains out though your ear as you both fall and fall. You are dead. \n\n" +
		"Press S to start again" ;
	if 		(Input.GetKeyDown(KeyCode.S)) 	{myState = States.land;}
}
void slat() {
	text.text = "As you feel gravity turn against you and begin to fall, you reach for the last slat, and grab on with four nimble " +
		"fingers. You swing, but keep your momentum, clutching on with only two fingers. The masked monster falls " +
		"past you, clouded by a scream. You swing your other arm up and grab on to the second slat, and keep " +
		"pulling your self up and up, slat by slat, higher and higher, as the scream slowly fades away." +
		"with your last ounce of effort, you pull yourself back onto ground, panting and broken. " +
		"Moments pass, and you finally pull yourself up into a standing position in front of the door that stands ajar. \n\n" +
		"G to Go through the door";
	if 		(Input.GetKeyDown(KeyCode.G)) 	{myState = States.go;}

}
void go() {
	text.text = "You slowly push the door open and walk through. It is dark, but your eyes soon adjust. You seem to be in a Submarine’s Hold of " +
		"some kind. There are boxes of records, a huge crate with the words Console 5000 printed on its side and " +
		"a ladder that lead up to to another room where light pours through. But most strange of all, " +
		"is a stone statue that reminds you of a robot you once knew. Suddenly, a stone disc opens in the lower structure " +
		"of the statue, snapping you out of your thoughts. You bend closer to look inside. You can make out an " +
		"object of some kind, you peer in and grab it. It is a rectangular and covered in dust. " +
		"You blow the dust away. It is a vinyl record of Land Of Dreams. How strange that this has been hidden in here? " +
		"What secrets could this reveal? I guess there is only one way to find out… \n\n" +
		"Well done, you have completed Land Of Dreams. Press Q to Quit.";
	if 		(Input.GetKeyDown(KeyCode.Q)) 	{myState = States.quit;}

}

}

It looks to me you have a few quotation marks that are incorrect. See screenshot below. Find those and correct and see what happens.

1 Like

Thanks! Sorted and now works like a charm!

1 Like