Different descriptions depending on whether something is being worn or carried

I feel like there’s a simple solution to this, but I’m drawing a blank.

A helmet has a description that acknowledges the view from inside, but this description no longer makes sense once you take it off. I’d really like the description of the helmet to change once it changes from being worn to being carried.

Just a bug a beta-tester found and I don’t know how to fix it.

Thanks,
-Pinkunz

Try:


the description of the helmet is "[if the player wears the helmet]It's rather hard to make out much about this helmet at the moment inasmuch as you're wearing it[otherwise]Rather spiffing helmet, that[end if]."

2 Likes

Thank you @DeusIrae ! I knew it would be something simple like that, but I’ve been staring at this code so long that I’m starting to see double.

I appreciate your help!

1 Like

You can also do this by using if statements outside the description, which is necessary if you plan to create nesting if statements.

Starting with this:


The description of the helmet is "It's a helmet."

After examining the helmet:
	if the player is wearing the helmet:
		say "You're wearing it.";
	if the player is not wearing the helmet:
		say "You're not wearing it."

Then, if you want to make three variations on the text instead of two:

The description of the helmet is "It's a helmet."

After examining the helmet:
	if the player is wearing the helmet:
		say "You're wearing it.";
	if the player is not wearing the helmet:
		if the player is carrying the helmet:
			say "You're not wearing it.";
		else if the player is not carrying the helmet:
			say "You're not carrying it right now."
1 Like

You can also place this inline with a substitution instead of a rule; this can also help if you have lots of complicated nesting in a description.

The description of the helmet is "It's a helmet. [helmstatus]"

To say helmstatus:
	if the player is wearing the helmet:
		say "You're wearing it.";
	if the player is not wearing the helmet:
		if the player is carrying the helmet:
			say "You're not wearing it.";
		else if the player is not carrying the helmet:
			say "You're not carrying it right now."

Also, from the manual:

But there is also a sixth relation used in Inform for these meanings: the possession relation, which is the meaning of the verb “to have”. At first sight this looks the same as the carrying relation, but in fact it is a convenient shorthand for “carrying or wearing”, provided for conditions rather than assertions.

if Mr Darcy has a wet shirt ...

will be true during play if he is either carrying or wearing the shirt.

2 Likes

Just for completeness’ sake, it’s possible to do the worn/carried/neither distinction as a simple inline thing, too - just use “[if the helmet is worn]BLARG[otherwise if the helmet is carried]DIFFERENT BLARG[otherwise]A YET DISTINCT THIRD BLARG”. But this can definitely start to get unwieldy so P.B.’s and Hanon’s approaches are great to have in the toolbox!

3 Likes

Is it just when you follow the [if] [if] [endif] [end if] structure inline that Inform rejects it? That is good to know.

2 Likes

There are a few nuggets there that I’m definitely taking for later. Thank you very much!