Displaying conditional text when the variable is a string

Hello!

I have a variable in my game which is a string, and I’d like to have some conditional text based on that. The trouble is, Inform doesn’t recognise this.

Below is an example of the code.

The description of the photo is "[if var is 'Absolutely wonderful']some text here[end if]."

When I put quotation marks ("") around it, the first quotation mark closes off the string; when I put apostrophes instead, Inform gets stuck. Is there any way to work around this?

You could do something like this:

Test Chamber is a room.

Var is initially "Not bad".

After jumping:
	now var is "Absolutely wonderful";
	say "You jump around for a while and feel invigorated."
	
A photo is a thing in the Test Chamber.
The photo has a text called the desired var. The desired var of the photo is "Absolutely wonderful".
The description is "[if var is the desired var of the item described]This is an awesome photo of you![else]The photo's ok. You've taken better.[end if]".

Test me with "take photo / x photo / jump / x photo".

or, if you don’t want to give the photo an extra property, this:

Definition: a text is absolutely wonderful if it is "Absolutely wonderful".

A photo is a thing in the Test Chamber.
The description is "[if var is absolutely wonderful]This is an awesome photo of you![else]The photo's ok. You've taken better.[end if]".

Inform doesn’t allow quotation marks in bracketed text substitutions, as far as I know. Here’s a couple of alternate ways of handling it:

[code]The description of the photo is “[variable description][run paragraph on]”.

To say variable description:
if var is “Absolutely wonderful”:
say “This is an awesome photo of you!”;
otherwise:
say “The photo’s ok. You’ve taken better.”[/code]

or

[code]The description of the photo is “The photo’s ok. You’ve taken better.”

Carry out examining the photo when var is “Absolutely wonderful”:
say “This is an awesome photo of you!”;
rule succeeds.[/code]

Define a constant:

Abs-wonderful is always "Absolutely wonderful".
The description of the photo is "[if var is abs-wonderful]some text here[end if]."

I thought we weren’t allowed to have constants anymore? It seems to be something that has changed in newer releases.

Constant declarations are a new(-ish) feature.

Cool! Thanks for showing me so many different ways to do it :smiley: