Change object description depending on its state

Hi,

Taking my first steps with Inform 7 after a couple of years of using Quest.

How do I return one description of an object if X is true and another if X is false?

I.E. if oject is open/worn/turned on etc.

Thank you.

You can embed conditions into a description.

The description of the wardrobe is "A big wardrobe of the old sort, with a looking-glass in the door[if the wardrobe is open]. The door is open, 
revealing several coats hanging up - mostly long fur coats[otherwise]. The door is closed[end if]."

(I’ve taken care to have the final . outside the condition. It looks slightly weird, but it helps Inform to get the spacing right if the description ends in . or !)

Inform doesn’t like text subsitutions embedded in one another. If your description is going to be complicated, then it can work better to farm the whole thing out into a “to say” rule:

The description of the wardrobe is "[wardrobe_description]".

To say wardrobe_description:
      if the wardrobe is open:
           say "(whatever)";
      otherwise:
           say "(whatever else)".

Thanks so much, that’s just the help I needed.