Okay, thanks everybody for your help. capmikee’s comment on relationships was a huge help and let me greatly simplify everything. Here’s the code I currently have which seems to work fairly well (so far, I haven’t really tested it with multiple NPC’s yet):
[spoiler][code]
“What not to wear II” by Anonymous
Part 1 - Body areas
Body-area is a kind of value. The body-areas are feet, lower-body, legs, hips, upper-body, full-body, head, none.
[relates with areas include other areas]
Body-includes relates various body-area to various body-areas. The verb to body-include (it body-includes, they body-include, it body-included, it is body-including) implies the body-includes relation. The verb to be body-included by implies the reversed body-includes relation.
full-body body-includes hips, legs and upper-body. lower-body body-includes hips and legs.
[identity relationships]
feet body-includes feet. lower-body body-includes lower-body. legs body-includes legs. hips body-includes hips. upper-body body-includes upper-body. full-body body-includes full-body. head body-includes head.
Part 2 - Garments
Chapter 1 - Defining base kinds
A garment-element is a kind of thing. A garment-element has a number called the layer-level. A garment-element has a body-area called the area.
[not actually needed - but you might add body-parts and then test if they are covered in a similar way to testing if a garment covers another garment]
A body-part is a kind of garment-element. A body-part has layer-level 0.
A garment is a kind of garment-element. A garment is wearable. A garment can be transparent.
A pair of pants is a kind of garment. The plural of pair of pants is pairs of pants. The area of a pair of pants is lower-body. A pair of pants usually has layer-level 5.
A pair of underpants is a kind of garment. The plural of pair of underpants is pairs of underpants. The area of a pair of underpants is hips. A pair of underpants usually has layer-level 2.
A foundation garment is a kind of garment. The area of a foundation garment is upper-body. A foundation garment usually has layer-level 2.
A pair of socks is a kind of garment. The plural of pair of socks is pairs of socks. The area of a pair of socks is feet. A pair of socks usually has layer-level 2.
A pair of shoes is a kind of garment. The plural of pair of shoes is pairs of shoes. The area of a pair of shoes is feet. A pair of shoes usually has layer-level 5.
A jacket is a kind of garment. The area of a jacket is usually upper-body. A jacket usually has layer-level 10.
A hat is a kind of garment. The area of a hat is head. A hat usually has layer-level 5.
A dress is a kind of garment. The area of a dress is full-body. A dress usually has layer-level 5.
A skirt is a kind of garment. The area of a skirt is lower-body. A skirt usually has layer-level 5.
A tie is a kind of garment. The area of a tie is upper-body. A tie usually has layer-level 7. A tie is always transparent.
A shirt is a kind of garment. The area of a shirt is upper-body. A shirt usually has layer-level 5.
Chapter 2 - Relationships
Definition: a garment-element is uppermost if it is not unwearable because of something opaque.
Clothing conflict relates a garment (called the top layer) to a garment (called the conflicting layer) when the conflicting layer is worn by the person asked and the top layer conflicts with the conflicting layer.
The verb to be unwearable because of implies the clothing conflict relation.
The verb to prevent wearing (he prevents wearing, they prevent wearing, he prevented wearing, he is preventing wearing) implies the reversed clothing conflict relation.
To decide if (top layer - a garment) conflicts with (conflicting layer - a garment):
[simplest case - if the two garment are the same, they don’t conflict]
if the top layer is the conflicting layer:
decide no;
[simple case - if the top layer has a higher level, it doesn’t conflict]
if the layer-level of the top layer is greater than the layer-level of the conflicting layer:
decide no;
[some part of the top layer area = some part of the conflicting layer area]
otherwise if a body-area body-included by the area of the conflicting layer is body-included by the area of the top layer:
decide yes;
otherwise:
decide no;
Chapter 3 - Rules for handling garments
Section 1 - removing
Before an actor taking off something which is unwearable because of something which is worn by the actor:
while the noun is unwearable because of something (called the impediment) which is worn by the actor:
say “(first removing [the impediment])[command clarification break]”;
silently try actor taking off the impediment;
if the noun is unwearable because of the impediment, stop the action.
Check an actor taking off a garment:
if the noun is unwearable because of something (called the impediment) which is worn by the actor, say “[The impediment] is in the way.” instead.
Report taking off something:
say “You are now wearing [a list of uppermost things worn by the player].” instead.
Section 2 - wearing
Before an actor wearing something unwearable because of a garment worn by the actor:
while the actor wears a garment (called the impediment) which prevent wearing the noun:
say “(first removing [the impediment])[command clarification break]”;
silently try actor taking off the impediment;
if the actor is wearing the impediment, stop the action.
Instead of taking inventory:
say “You’re carrying [a list of things carried by the player][if the player wears something]. You are wearing [a list of uppermost garments worn by the player][end if].”
Part 3 - The Scenario
The Dressing Room is a room.
The player carries some capris, some jeans, a corset, a plunge bra, a thong, boy-shorts, black satin D’Orsay pumps, brown leather boots, a camisole, a cocktail dress, a bolero, a cashmere shrug, a sheer wrap, and a linen tunic.
The woolly socks are a pair of socks.
The D’Orsay pumps and the brown leather boots are pairs of shoes.
The thong and the boy-shorts are pairs of underpants.
The capris and the jeans are pairs of pants.
The tunic is a shirt.
The camisole, the corset, and the plunge bra are foundation garments.
The cocktail dress is a dress.
The bolero, the cashmere shrug, and the sheer wrap are jackets. The shrug and the wrap are transparent.
Test me with “wear capris / wear jeans / i / wear thong / i / wear dress / wear corset / wear dress / i / wear wrap / i / wear boots / wear pumps / i”.
[/code][/spoiler]
Any comments? Criticisms?
I learnt a lot about inform by doing this, the sad part is that I’m not sure I can really think of too many scenarios where this level of clothing detail might actually be useful, so I might well end up never using it. Still, finding the limitations of the original example compelled me to try and find a more efficient solution.
With a little tweaking, a similar system could be created for a situation where you have to keep track of items overlying (either completely or partially) over items.