Some help with player clothing?

Having trouble here, keep getting errors!

The errors are about “the top worn by the player”.

[code]clothing is a kind of wearable thing.

top is a kind of clothing.

Jacket is a thing. Jacket is a top.

clothing.color is a kind of value. The clothing colors are red, blue, green, purple, orange, pink, yellow and violet.
A top has clothing.color

Every turn:
If the player is in the hallway:
If the player is wearing the Jacket:
now the clothing.color of the top worn by the player is blue.[/code]

In cases like this, Inform doesn’t know that there’s only one. So you have to say “a random…” instead of just “the”.

Bedroom is south of Hallway.

Clothing is a kind of wearable thing.
Clothing color is a kind of value. The clothing colors are red, blue, green, purple, orange, pink, yellow and violet. [1]
Clothing has a clothing color. Clothing is usually pink. [2]

A top is a kind of clothing.

The jacket is a top. The description is "It's a [clothing color] jacket."
The player carries the jacket.

Definition: clothing is nonblue if it is not blue. [3]

Every turn when the location is the Hallway and the nonblue jacket is worn: [4]
	now the jacket is blue; [5]
	say "[The jacket] turns blue as it reacts with the mysterious Hallway air."
Test me with "n / x jacket / wear jacket / x jacket / s / n".
  1. We’ve renamed “clothing.color” to “clothing color”. I7 identifiers can have spaces in them, and the clothing.color naming convention is unidiomatic and carries too much baggage for readers familiar with other programming languages.

  2. We’ve made clothing color a property of the clothing kind rather than just the top kind. Other kinds of clothing can also have colors and, like, it’s called “clothing color”, not “top color”.

We’ve also given clothing an explicit default color value. Note that we can be less verbose and say “clothing is usually pink” instead of “the clothing color of clothing is usually pink”.

  1. This definition will help us write our every turn rule so that it only applies when the jacket isn’t already blue.

  2. We’ve pulled the nested conditionals out from the body of the rule and made them part of the rule’s condition (every turn when …).

We’ve also changed the conditions. We’ve used “the location is the Hallway” instead of “the player is in the Hallway”, because it will apply if the player is indirectly contained in the Hallway (e.g., sitting in a chair in the Hallway). We’ve used “the jacket is worn” instead of “the player is wearing the jacket”, because it’s shorter and “worn” with no qualifier is assumed to mean worn by the player. Finally, we’ve added “nonblue” (see 3 above) as a qualifier to the jacket so that this rule will only apply if the jacket isn’t blue.

  1. Presumably the jacket is the top whose color we want to change, so there’s no need to be roundabout.

If not, then it must be possible for the player to be wearing some top in addition to the jacket. We then have other problems, because there’s no the top worn by the player; the player might be wearing multiple tops. In that case, you’d want to do as Draconis suggests and set a local variable to “a random top worn by the player”.

If you want to exclude the jacket from being chosen, you could modify the every turn rule’s condition to include something like “and a nonjacket top (called T) is worn” (having defined nonjacket in a similar way as we defined nonblue). Then, you’d be able to just use T in the body of the rule without needing a local variable set to a random top.

It all depends on what behavior you really intended here.