A detailed clothing system - work in progress

I’ve combined elements from the clothing examples in the documentations with some of my own ideas (mostly using a property to define relations on and then having computed relations based on this for the actually clothing items so that I don’t need to process all clothing items at startup to set their layering relationships)

It’s still a work in progress and I’m far from happy with the naming (I’ve had to use a few synonyms for the same concept to avoid naming clashes with my relations)

Section Clothing

A body area is a kind of object.

A clothing type is a kind of object.

Overlying relates various clothing types to various clothing types.

The verb to overlie implies the overlying relation.

Masking relates various clothing types to various body areas.

The verb to mask implies the masking relation.

Guarding relates various clothing types to various body areas.

The verb to guard implies the guarding relation.

Covering relates a clothing type (called X) to a body area (called Y) when X masks Y or X guards Y.

The verb to cover implies the covering relation.

Abovelayered relates a clothing type (called X) to a clothing type (called Y) when the number of steps via the overlying relation from X to Y is greater than 0.

The verb to be layered above implies the abovelayered relation.

Obstructing relates a clothing type (called X) to a clothing type (called Y) when a body area which is guarded by X is covered by Y and Y is not layered above X.

The verb to obstruct implies the obstructing relation.

Eclipsing relates a clothing type (called X) to a clothing type (called Y) when X is layered above Y and every body area covered by Y is covered by X.

The verb to eclipse implies the eclipsing relation.

Clothing is a kind of thing. Clothing has a clothing type called the type. Clothing is usually wearable.

Blocking relates clothing (called X) to clothing (called Y) when the type of X obstructs the type of Y and X is not Y.

The verb to block implies the blocking relation.

Hiding relates clothing (called X) to clothing (called Y) when X is worn by a person (called Z) and Y is worn by Z and the type of X eclipses the type of Y.

The verb to hide implies the hiding relation.

Definition: clothing is visible if it is not hidden by something.

Before wearing something when something which blocks the noun is worn by the player: 
	while the player wears something (called the impediment) which blocks the noun: 
		say "(first removing [the impediment])[command clarification break]"; 
		silently try taking off the impediment; 
		if the player is wearing the impediment, stop the action.

Before taking off something when something which blocks the noun is worn by the player: 
	while the player wears something (called the impediment) which blocks the noun: 
		say "(first removing [the impediment])[command clarification break]"; 
		silently try taking off the impediment; 
		if the player is wearing the impediment, stop the action.

A body part is a kind of thing. A body part has a body area called the area.

Protection relates clothing (called X) to a body part (called Y) when X is worn by a person (called Z) and Y is a part of Z and the type of X covers the area of Y.

The verb to to protect implies the protection relation.

The verb to be protected by implies the reversed protection relation.

Definition: a body part is visible if it is not protected by something.

A person can be detailed. A person is rarely detailed.

Instead of taking inventory: 
	say "[if the player carries something][We]['re] carrying [a list of things carried by the player][else][We]['re] empty-handed[end if].[if the player wears something] [We] [are] wearing [a list of visible clothing worn by the player]. [end if][if the player wears something not visible] Underneath, [we] [are] wearing [a list of not visible clothing worn by the player].[end if][if any visible body part is a part of the player] There is nothing covering [a list of visible body parts which are part of the player].[end if]"

Instead of examining someone detailed:
	if the noun wears something:
		say “[The noun] is wearing [a list of visible clothing worn by the noun].”;
	if any visible body part is a part of the noun:
		say "There is nothing covering [a list of visible body parts which are part of the noun].".

Section Clothing types

The chest-area is a body area.

The upper-arm-area is a body area.

The forearm-area is a body area.

The stomach-area is a body area.

The groin-area is a body area.

The thigh-area is a body area.

The lower-leg-area is a body area.

The foot-area is a body area.

The underpants-type is a clothing type.  It guards the groin-area.

The bra-type is a clothing type. It guards the chest-area.

The swimsuit-type is a clothing type. It guards the chest-area, stomach-area and groin-area.

The shorts-type is a clothing type. It overlies the underpants-type and swimsuit-type. It guards the groin-area and thigh-area.

The pants-type is a clothing type. It overlies the underpants-type and swimsuit-type. It guards the groin-area, thigh-area and lower-leg-area.

The stockings-type is a clothing type. It overlies the underpants-type. It guards the groin-area, thigh-area, lower-leg-area and foot-area.

The skirt-type is a clothing type. It overlies the stockings-type and swimsuit-type. It masks the groin-area and thigh-area.

The long-skirt-type is a clothing type. It overlies the stockings-type and swimsuit-type. It masks the groin-area, thigh-area and lower-leg-area.

The dress-type is a clothing type. It overlies the bra-type and stockings-type and swimsuit-type. It guards the chest-area and stomach-area. It masks the groin-area and thigh-area.

The long-dress-type is a clothing type. It overlies the bra-type and stockings-type and swimsuit-type. It guards the chest-area and stomach-area. It masks the groin-area, thigh-area and lower-leg-area.

The shortsleve-shirt-type is a clothing type.  It overlies the bra-type and swimsuit-type. It guards the chest-area, upper-arm-area and stomach-area.

The shirt-type is a clothing type.  It overlies the bra-type and swimsuit-type. It guards the chest-area, upper-arm-area, forearm-area and stomach-area.

A pair of underpants is a kind of clothing. The type is the underpants-type.

A bra is a kind of clothing. The type is the bra-type.

A shorts is a kind of clothing. The type is the shorts-type.

A pair of pants is a kind of clothing. The type is the pants-type.

A swimsuit is a kind of clothing. The type is the swimsuit-type.

A pair of stockings is a kind of clothing. The type is the stockings-type.

A skirt is a kind of clothing. The type is the skirt-type.

A long skirt is a kind of clothing. The type is the long-skirt-type.

A dress is a kind of clothing. The type is the dress-type.

A slong dress is a kind of clothing. The type is the long-dress-type.

A short sleve shirt is a kind of clothing. The type is the shortsleve-shirt-type.

A shirt is a kind of clothing. The type is the shirt-type.

Privates are a kind of body part. The area is the groin-area. Privates are a part of every man. Privates are a part of every woman.

A Chest is a kind of body part. The area is the chest-area. A chest is a part of every woman.

Your privates are privates which are part of the player. 

Section Test

The Construct is a room.

The pair of red underpants is a pair of underpants. It is here.

The green swimsuit is a swimsuit. It is here.

The red bra is a bra. It is here.

The floral dress is a dress. It is here.

The pair of boxer shorts are a pair of underpants. The player is wearing the pair of boxer shorts.

The pair of tracksuit pants are a pair of pants. The player is wearing the tracksuit pants.

The stained t-shirt is a short sleve shirt. The player is wearing the stained t-shirt.

Janet is a detailed woman. Janet is here.

The bikini bottom is a pair of underpants. Janet is wearing the bikini bottom.

The bikini top is a bra. Janet is wearing the bikini top.

The sarong is a skirt. Janet is wearing the sarong.

Bruce is a detailed man. Bruce is here.

Fred is a man. Fred is here.

Kate is a detailed woman. Kate is here.

I’m writing this as part of an adult game (I’ve kept the language and components sanitised so far so I can share it) but it may have other applications and it may be useful as examples of complex relations.

1 Like

I downloaded this and played around with it and didn’t run into any conflicts/stability issues, so I think you have a pretty good potential extension here. I could easily see this fitting in to a larger work where clothing types or pieces affect puzzles, entry to rooms, and even persuasion.

Documentation would definitely help though, especially towards the end with the list of what type overlies/masks/guards which other types and body areas.

Color me impressed.

Very cool.

Thanks for the feedback.

Yeah. I completely forgot to explain what any of this means. Sorry about that.

The model is based on “clothing” and “body parts”

Each article of clothing has a “clothing type” and each body part has a “body area”

The explicit relations are defined between these types and areas. The relations between actual articles of clothing bad body parts are implied by the relations between their types and areas.

I did this so that I don’t need to write something like (from the example “What Not To Wear”):

When play begins: 
    now every pair of socks overlies every pair of feet; 
    now every pair of shoes overlies every pair of socks;
    ...

Which (I hope) means that I can potentially change the type of a piece of clothing or turn something else into clothing at some point in the story without regenerating these relations.

The explicit relations:

Overlying (to overlie) indicates which types of clothing a type of clothing might be worn over. Only the next layer down needs to be specified as the logic based on this relation looks for paths connecting types.

For example, if the raincoat-type overlies the sweater-type and the sweater-type overlies the shirt-type then the game knows that the raincoat-type is also worn over the shirt-type.

Masking (to mask) indicates which types of clothing conceal which body parts. When combined with the overlying relation this is also used to determine what clothing is visible. Basically, you can’t see underpants if a skirt is worn over them.

Guarding (to guard) indicates which types of clothing block access to which body parts. this implies the same behavior as masking but also means that it prevents access to anything it overlies which covers the same body part. The result of this is basically that you can’t put on or take off a bra while wearing a blouse (on the other hand, a skirt would only hide underpants so underpants can be worn and unworn while wearing a skirt.)

If two pieces of clothing cover the same area (either mask or guard) but neither resolves to being worn over the other then these pieces of clothing are incompatible and cannot be worn at the same time. This goes for clothing of the same clothing type too. (two pairs of pants can’t be worn at the same time)

I’ve just realised that I missed something in this model and am a little bit stuck on how best to proceed.

I’ve forgotten about shoes. Other clothing types prevent you from putting on or taking off lover-level clothing which is worn on the same body area. Shoes prevent you from putting on or removing pants but do not (necessarily) cover any of the same boy areas.

Hats would have a similar relationship to t-shirts (but not button-up shirts)

If anyone has any ideas on how to express this I’d be grateful.

One idea might be to define a sliding-over relation between clothing types and body areas, so that pants slide over the feet and t-shirts slide over the head. Then you could define clothing as snaggy or not, so that shoes are snaggy but socks aren’t. You could write a rule that prevents the player from taking off/putting on clothing when the player is wearing something snaggy on a body part that the clothing slides over.

Another way would be to make an ad hoc relation between clothing and clothing–“remotely obstructing” or something like that. Then you could use the What Not To Wear solution of using a When Play Begins rule to make every pair of shoes remotely obstruct every pair of pants (and underpants, I guess), and rewrite the relevant rules (or relations) so they check whether one item of clothing blocks another or remotely obstructs it. But you’d probably like to avoid this.

I haven’t tested this or really looked at your code in much detail so I’m not really sure if this works. And, really impressive-looking work here! One tiny thing: it looks as though you have “sleeve” spelled “sleve”; not sure if that’s intentional.

Thanks for the idea. I’ve tried it out and it seems to do what I need. I’ve bypassed the “snaggy” concept by using my existing overlying relation. Pants overlie socks so they can pass over the socks without problem. They don’t overlie shoes so they are obstructed by shoes.

Section Clothing
...
Passing relates various clothing types to various body areas.

The verb to pass implies the passing relation.
...
Passchecking relates a clothing type (called X) to a body area (called Y) when X masks Y or X guards Y or X passes Y.

The verb to passcheck implies the passchecking relation.
...
Obstructing relates a clothing type (called X) to a clothing type (called Y) when a body area which is guarded by X is passchecked by Y and Y is not layered above X.
...

Section Clothing types
...
The sock-type is a clothing type. It guards the foot-area.
...
The underpants-type is a clothing type.  It overlies the sock-type. It guards the groin-area. It passes the foot-area.
...
The swimsuit-type is a clothing type. It overlies the sock-type. It guards the chest-area, stomach-area and groin-area. It passes the foot-area.

The shorts-type is a clothing type. It overlies the sock-type, underpants-type and swimsuit-type. It guards the groin-area and thigh-area. It passes the foot-area.

The pants-type is a clothing type. It overlies the sock-type, underpants-type and swimsuit-type. It guards the groin-area, thigh-area and lower-leg-area. It passes the foot-area.
...
The shoe-type is a clothing type. It overlies the stockings-type and sock-type. It guards the foot-area.
...
A pair of socks is a kind of clothing. The type is the sock-type.

A pair of shoes is a kind of clothing. The type is the shoe-type.

Thanks for the spell-check too.

For the specific task you are working on, you may not want to reinvent the wheel.

Over in the Adult Interactive Fiction, there is plenty of need for carrying out adding and subtracting garments and reporting on such. Unfortunately there’s rarely an incentive to get their R- and X-rated extensions modified to fit into the G- and PG-rated official depositories.

Advanced Layered Clothing, which is part of the AIF toolkit by “Another Wannabe”
http://awaifgames.blogspot.com/search/label/Advanced%20Layered%20Clothing%20(Google%20Drive%20link%20on%20site)

Garments is part of AIF Framework by Fictitious Frode
https://informedaif.wordpress.com/2016/01/27/aif-framework-release-4-v1-1/

That author is also doing a massive rewrite + consolidation into “Erotic Storytelling”
https://github.com/FictitiousFrode/AIF

It seems that the lesson learned by both was that “overlaying/underlaying” ends up a computational mess and converted to a system where more of a system where garment types are assigned layer numbers, and when inventorying, it checks for the highest numbered item covering each region and puts it in scope. This also allows for partially obstructed objects to be seen. (like a skirt over a leotard, for example)

The other lesson is to let the specific garment types carry as much of the information and code as possible and let the individual garments be just an invocation and description.

Maybe one of these is exactly what you need, or you can copy (with credit) and modify to your uses.

1 Like

Sorry it too so long to reply. It’s been a crazy couple of weeks.

Thanks for the links. I did a bit of googling before I started but could not find anything beyond the samples in the documentation.

I’ll check out those links when I get a chance but I’m pretty happy with how my version is working now.

I have a feeling though that my specific purposes are going to ultimately need my own code as my story revolves around a niche kink.

I’m glad I did this exercise either way. It has taught me a lot about Inform 7, especially using relations.

This was one of the reasons I used clothing types and defined all the relations between these rather than between individual articles of clothing. If I had 100 articles of clothing in the game then any relations between them potentially need to track 10000 combinations.

A few years ago I started a similar project in TADS that had a layer-number (and a bitfield representing the regions of the body an article of clothing covered). That project ultimately didn’t go anywhere as I struggled to get the details working and could never really convince myself that TADS was the right system to use (Inform has much broader platform support).

I considered a similar approach for this project but it just felt like it went against the spirit of the language.

This is similar to the solution I came upmwith for Dynamic Clothing. I found that the relationships I needed (particularly the uppermost layer) had to be referenced and calculated so many times per turn that it bogged down with only a few clothed characters in scope. I then assigned each character a list of uppermost garments that were only recalculated as needed (such as when a garment was worn or removed by the actor) which sped things up considerably.

As someone who has spent a fair amount of time on the subject (writing two of the extensions referenced above): If you really want to re-invent the wheel, have a clear motivation for doing so. Some issues you will run into (off the top off my head):

  • Referential cascading: If coats goes over pants, and pants go over stockings, it’s easy to create a model that assumes the coat also covers stockings while there is no overlap.
  • Carious accessibility checks for actions, including garments that do not block access even when worn (think transparent, touch-through, etc).
  • Clothing that can be unbuttoned, moved out of the way, etc.
  • Not assuming that every body part is implemented on every person (!) / Easily supporting custom body parts.
  • Some method for easily controlling when the player can move around undressed.

If you have any requirements that you feel my extension doesn’t cover, feel free to drop me a PM or comment with the details and I’ll look into if/how it can be implemented.

2 Likes

Hi, sorry to bump an old topic but since I modified the code posted here I figured this best belonged here.

I wondered if it would be possible to remove the distinction between clothing and body parts. I haven’t played around with the following code too much, but it seems to work to prevent you taking off socks without shoes and hiding feet under footwear and the like. I feel like there is definitely room for improvement.

"Full Cloth" by Anonymous

Section 1 - The Extension

A layer type is a kind of object.
A layerable thing is a kind of thing.
A layerable thing has a layer type called the type.

Overlying relates various layer types to various layer types. 
The verb to overlie (he overlies, they overlie, he overlaid, it is overlain, he is overlying) means the overlying relation. 

Transitive overlying relates a layer type (called the overlier) to a layer type (called the overlain) when the number of steps via the overlying relation from the overlier to the overlain is greater than 0. 
The verb to transitively overlie (he transitively overlies, they transitively overlie, he transitively overlaid, it is transitively overlain, he is transitively overlying) means the transitive overlying relation.

View masking relates various layer types to various layer types. 
The verb to view mask (he view masks, they view mask, he view masked, it is view masked, he is view masking) means the view masking relation.

Take masking relates various layer types to various layer types.
The verb to take mask (he take masks, they take mask, he take masked, it is take masked, he is take masking) means the take masking relation.

Hiding relates a layerable thing (called the concealer) to a layerable thing (called the hidden) when the concealer is not the hidden and the concealer is worn by a person (called the agent) or the concealer is a part of a person (called the agent) and the hidden is worn by the agent or the hidden is a part of the agent and the type of the concealer transitively overlies the type of the hidden and every layer type view masked by the type of the hidden is view masked by the type of the concealer.
The verb to hide (he hides, they hide, he hid, it is hidden, he is hiding) means the hiding relation.

Protecting relates a layerable thing (called the protector) to a layerable thing (called the protected) when the protector is not the protected and the protector is worn by a person (called the agent) or the protector is a part of a person (called the agent) and the protected is worn by the agent or the protected is a part of the agent and the type of the protector transitively overlies the type of the protected and every layer type take masked by the type of the protected is take masked by the type of the protector.
The verb to protect (he protects, they protect, he protected, it is protected, he is protecting) means the protecting relation.

Definition: a layerable thing is visible if it is not hidden by something.

Definition: a layerable thing is touchable if it is not protected by something.

Instead of taking inventory: 
	say "[if the player carries something][We]['re] carrying [a list of things carried by the player][else][We]['re] empty-handed[end if].[if the player wears something] [We] [are] wearing [a list of visible layerable things worn by the player]. [end if][if the player wears something not visible] Underneath, [we] [are] wearing [a list of not visible layerable things worn by the player].[end if][if any visible layerable thing is a part of the player] There is nothing covering [a list of visible layerable things which are part of the player].[end if]"

Check wearing something when something (called the impediment) which protects the noun is worn by the player: 
	say "([We] would have to remove [the impediment] first!)" instead.

Check taking off something when something (called the impediment) which protects the noun is worn by the player: 
	say "([We] would have to remove [the impediment] first!)" instead.

Section 2 - The Example

The feet layer is a layer type.
The socks layer is a layer type.
	The socks layer overlies the feet layer.
	The socks layer view masks the feet layer.
	The socks layer take masks the feet layer.
The shoes layer is a layer type.
	The shoes layer overlies the socks layer.
	The shoes layer take masks the feet layer.

Your hairy feet are layerable things.
	The type of your hairy feet is the feet layer.
	Your hairy feet are part of the player.
Some striped socks are layerable things.
	The type of some striped socks is the socks layer.
	Some striped socks are wearable.
	Some striped socks are in the Example Location.
A pair of shoes is a layerable thing.
	The type of a pair of shoes is the shoes layer.
	A pair of shoes is wearable.
	A pair of shoes is in the Example Location.

Example Location is a room.

EDIT: After further testing, this doesn’t prevent putting on socks while already wearing shoes; will have to track down why.