Relations as Requirements (Inform 7)


I am having some difficulty getting a new clothing system working the way I want it to. Basically, I want to define clothes as occupying certain body slots, so that when the clothes get worn, the body slot becomes covered or uncovered. The problem I am bumping into is with the occupying relation I’ve defined: rather than treat it as a requirement, Inform 7 is creating a generic item of the specified kind, so when I say “The blue jeans occupy a pelvis, upper legs, and lower legs” a new instance of each of those body slots is created. Not sure how to fix this. Here’s the most relevant code to give an idea of what I’m going for.

Clothes are a kind of thing. Clothes are usually wearable.
A body slot is a kind of thing.
Occupying relates various clothes to various body slots.
The verb to occupy means the occupying relation.
Upper legs are a kind of body slot. Every person incorporates upper legs.
Lower legs are a kind of body slot. Every person incorporates lower legs.
Covering relates various clothes to various body slots.
The verb to cover means the covering relation.
Carry out wearing something:
	Repeat with slot-in-question running through body slots which are occupied by the noun:
		Now slot-in-question is covered by the noun.
The blue jeans are clothes. The jeans occupy upper legs and lower legs.

So if a player types “wear jeans”, then the generic upper legs and lower legs occupied by the jeans get covered, rather than the player character’s upper and lower legs. Is my approach here even remotely correct?

If you type SHOWME ME, does it show that you have body parts attached to the player? You might need to build the player’s anatomy specifically. I remember running into this problem when creating detailed body parts for AIF.

A nose is a kind of thing. One nose is part of every person. your nose is a nose. it is part of the player. understand "my nose" as your nose.

You might also want to specify “Covering relates one clothes to one body slot.” If you do various-to-various that means one sock could cover an army of people and multiples can cover the same body part. Also, various-to-various relations, especially when used on a kind of which there can be large numbers of operating in the game, is probably one of the easiest ways to bog the system down and cause a noticeable lag in the game due to memory issues.

It looks to me as though you might want “The blue jeans occupy every upper legs. The blue jeans occupy every lower legs.” That way the clothing item will have that relation to every appropriate body part of every person, which looks like what you want. (I’m not absolutely positive you can do this in an initial declaration; you might need to set it in a “When play begins:” rule.)

Right, you might want to specify “Covering relates one clothing to various body slots.” instead of various-to-various. Don’t forget you can type RELATIONS in the IDE as a debug command to check what relations are currently set in the game.

I am looking for various to various (I think) because: one slot can be covered by multiple items of clothing (such as a dress shirt being worn over a t-shirt), and multiple slots can be covered by the same item of clothing (such as a t-shirt covering a person’s chest, abdomen, shoulders, and upper arms).

This! This is what I was looking for. I had to change the word order around, but once I wrote

Every upper legs is occupied by the blue jeans. Every lower leg is occupied by the blue jeans.

I started to get the results I was looking for.

Another approach is to define a kind-of-value, which is distinct from the body slot kind but mappable to it:

Body-location is a kind of value. The body-locations are upper-legs-loc, lower-legs-loc, feet-loc, torso-loc.
A body slot has a body-location.
The body-location of upper legs is always upper-legs-loc. […]

Then you can write a relation which applies to body-location. The rest should be doable.

I think, if the objective is crossing an hostile environment, setting a “covered” flag when all appropriate garment is weared is more simple.

Best regards from Italy,
dott. Piergiorgio.