To say with a text variable

I’ve been working on making a dialogue system and wanted to use To Say rules in order to choose the continue dialogue after something is said. However when trying to implement this I noticed that the To Say rules won’t just take text, it seems it will only accept a variable holding a text. Here is an example, the commented out line leads to a compile error:

"To say with a text variable"

Laboratory is a room.

X is a text that varies. X is "Weather".
Z is a number that varies. Z is 1.

To say next topic (Y - a text):
	say Y.

To say next number (Z - a number):
	say Z.

instead of jumping:
	say "[next topic X]";
	say line break;
	say "[next number Z]".

instead of waving hands:
	[say "[next topic 'Weather']";]
	say "[next number 1]".

I found this especially odd since, as shown in this example, this is not the case for numbers where literal numbers can be given. I saw someone else had asked a similar question but the proposed solutions were to either define constant strings which would mean I’d have many statements like Weather is always “Weather”, or to use numbers which I don’t think would really work for me.

Are there any other ways to work around this?

You can’t have string literals within brackets within a double-quoted string, i.e., 'Weather' in single quotes won’t work, as you’ve already seen, and neither will anything else.

But the good news is that when there’s a to say X: phrase, you need to use brackets within a double-quoted string to create a text value to assign it to a variable, e.g.,

let T be "[X]";

but you don’t need the quotes and brackets to just say it:

say next topic "Weather";
1 Like