Conditional text concatenate

Hi,
I would like to create text that is dependent on some variables, for example:

void tower ()
{
text.text = “You are in a tower. There is a chest here.” +
if (sword == 0) { “In the chest you see a sword”}
else if (sword == 1) {“The chest is empty” };
}

however I keep getting errors - depending on where I put the semicolon. What syntax shell I use?

Darek

I would make something like this:

void tower()
{
string increment;

if (sword == 0) {increment = "In the chest you see a sword";}
else if (sword == 1) {increment = "The chest is empty";}

text.text = "You are in a tower. There is a chest here." + increment;
}

Great idea, Thank you!
Darek

1 Like

Privacy & Terms