Another quick question.

What is the syntax for referencing a things kind? I would like to compare two objects kinds to see if I’m already wearing one without referencing the individual items… Thanks.

That’s actually a difficult thing to do. One way to think of it is that things have more than one kind; if a clothing is a kind of thing and a skirt is a kind of clothing and a blouse is a kind of clothing, and you’re wearing a skirt and you try to put on a blouse, should the “Am I wearing something of this kind?” test come out true or false? What if a top is a kind of clothing and a shirt is a kind of top and a blouse is a kind of top?

Anyway, there is an extension by Brady Garvin called “Object Kinds” which does let you do something like this–I think it checks the most specific kind of the object (so the shirt and blouse would count as different kinds). There are also a lot of other ways of dealing with the problem of wearing two of the same kind of clothing… you might want to check out the “What Not To Wear” extension and the extension Layered Garments by Shadow Wolf… though i don’t know if that’s updated to the latest versions of Inform.

Oh, and there’s more stuff about that here including some more stuff about how to get the kind of an object (there’s a link to some I6 code that does it and to Brady’s extension). And some kind of fun code at the end that I wrote that isn’t super relevant, but that does contain some very good advice, which is never make anything in your game orange and you’ll have to worry less about when to use “a” and when to use “an.” (This came up in my Imaginary Games entry.)

um, actually I’m using a snippet of code you wrote in that post you mentioned above. Thank you, btw, it works great. But I would like to check if the player is already wearing a garment kind (so tree would be garment -> dress, for example). If there is a “yellow dress” and a “white dress”, I would like to prevent the player from wearing both dresses. Easy solution for to write for just the “dress” subclass but I want to check for duplicates of all the garment subclasses.
Here’s the code

[spoiler]Use MAX_PROP_TABLE_SIZE of 200000.
Use full-length room descriptions, American dialect, and the serial comma. Use DICT_WORD_SIZE of 12.

Volume Clothing

[matt w https://intfiction.org/t/clothes-formations-that-dont-make-sense/8873/8]

Understand “fasten [something]” as wearing. Fastening is an action applying to one thing.

A garment-element is a kind of thing.
A body-part is a kind of garment-element.

A torso, a head, hair, a neck, a face, pair of hands, pair of arms, a seat, pair of legs, and pair of feet are kinds of body-part.
One torso is part of every person.
One head is part of every person.
Hair is part of every person.
One neck is part of every person.
One face is part of every person.
One pair of hands is part of every person.
One pair of arms is part of every person.
One seat is part of every person.
One pair of legs is part of every person.
One pair of feet is part of every person.

A garment is a kind of garment-element.
A garment can be transparent.

[Types of wearable garments]
[gowns]
A gown is a kind of garment.
A gown is usually wearable.

A morning_gown is a kind of gown.
A morning_gown is usually wearable.
A walking_dress is a kind of gown.
A walking_dress is usually wearable.

[undergarments]
A chemise is a kind of garment.
A chemise is usually wearable.
A pair of drawers is a kind of garment. The plural of a pair of drawers is a pair of drawers.
A pair of drawers is usually wearable.
A stays is a kind of garment.
A stays is usually wearable.
A petticoat is a kind of garment.
A petticoat is usually wearable.
A pelisse is a kind of garment.
A pelisse is usually wearable.

[foot ware]
A pair of stockings is a kind of garment. The plural of a pair of stockings is pair of stockings.
A pair of stockings is usually wearable.
A pair of slippers is a kind of garment. The plural of pair of slippers is a pair of slippers.
A pair of slippers is usually wearable.
A pair of half_boots is a kind of garment. The plural of half_boots is a pair of half_boots.
A pair of half_boots is usually wearable.

Beneathing relates various garment-elements to various garment-elements with fast route-finding.
The verb to beneath means the beneathing relation. The verb to be beneath implies the beneathing relation.

Check taking off:
if the noun is beneath something (called the impediment) which is worn by the player, say “[The impediment] [are] in the way.” instead.

Carry out taking off:
now the noun is not beneath anything.

Report taking off something:
say “[clothes-description of the player]” instead.

Definition: a garment-element is uppermost if it is not beneath something opaque.

Check taking off something which is beneath something which is worn by the player:
while the noun is beneath something (called the impediment) which is worn by the player:
say “(first removing [the impediment])[command clarification break]”;
silently try taking off the impediment;
if the noun is beneath the impediment, stop the action.

Overlying relates various garment-elements to various garment-elements. The verb to overlie means the overlying relation.

Covering relates a garment-element (called A) to a garment-element (called B) when the number of steps via the overlying relation from A to B is greater than 0 and A and B clash. The verb to cover means the covering relation.

Swaddling relates various garment-elements to various garment-elements. The verb to swaddle means the swaddling relation.

To decide whether (A - a garment-element) and (B - a garment-element) clash:
repeat with limb running through body-parts that are swaddled by A:
if B swaddles limb, yes;
no.

To decide whether (A - a garment-element) really covers (B - a garment-element):
if A covers B and A and B clash, yes;
no.

Check wearing something when a garment which covers the noun is worn by the player:
while the player wears a garment (called the impediment) which covers 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.

[Carry out wearing:
repeat with hidden item running through things worn by the player:
if the noun really covers the hidden item, now the hidden item is beneath the noun. ]

Instead of looking under something which is worn by the player:
if something (called the underwear) is beneath the noun, say “[We] [peek] at [the underwear]. Yup, still there.”;
otherwise say “Just [us] in there.”

To peek is a verb.

Check wearing something:
let N be the layering depth of the noun;
repeat with item running through things worn by the player:
say “[the item][line break]”;
if the layering depth of the item is N and the item covers a body-part which is covered by the noun:
say “(first taking off [the item])[command clarification break]”;
silently try taking off the item;
if the player wears the item, stop the action;

To decide what number is the layering depth of (chosen garment - a thing):
let N be 0;
if the chosen garment covers a body-part (called base):
let N be the number of steps via the overlying relation from the chosen garment to the base;
decide on N.

When play begins:
now every chemise overlies every torso;
now every chemise swaddles every torso;
now every chemise swaddles every pair of legs;
now every pair of stockings overlies every pair of feet;
now every pair of stockings swaddles every pair of feet;
now every pair of drawers overlies every pair of legs;
now every pair of drawers swaddles every pair of legs;
now every stays overlies every chemise;
now every stays swaddles every torso;
now every petticoat overlies every chemise;
now every petticoat swaddles every pair of legs;
now every gown overlies every stays;
now every gown overlies every petticoat;
now every gown swaddles every torso;
now every gown swaddles every pair of legs.

When play begins:
repeat with first item running through things worn by the player:
repeat with hidden item running through things worn by the player:
if the first item really covers the hidden item, now the hidden item is beneath the first item.

To decide which object is the outermost covering of (limb - a body-part):
let owner be a random person incorporating limb;
repeat with test item running through (garments worn by owner) that swaddle limb:
if test item is beneath a garment that swaddles limb:
next;
decide on test item;
decide on nothing.

To say clothes-description of the player:
let clothes-list be a list of things;
repeat with limb running through body-parts incorporated by the player:
if the outermost covering of the limb is not nothing:
add the outermost covering of the limb to the clothes-list, if absent;
if clothes-list is empty:
say “[We]['re] wearing nothing at all. Better put something on before you catch your death from cold.”;
otherwise:
say “[We]['re] wearing [clothes-list with indefinite articles].”

Part Wardrobe

A Wardrobe is a kind of container.
A Wardrobe is usually opaque, openable, open and not enterable.
[A wardrobe is usually scenery.]

Part Player Stuff

Helena is a woman.
The player is Helena.
The player is in Helenas Chamber.
Hel_Hair is hair that is part of Helena. the description of Hel_Hair is “wavy medium brown locks.”

Hel_DirtyChemise is a chemise.
Understand “chemise” or “wrinkled chemise” as Hel_DirtyChemise.
the printed name of Hel_DirtyChemise is “a wrinkled chemise”.
The player is wearing Hel_DirtyChemise.
the description of Hel_DirtyChemise is “[if worn]The plain, knee-length garment has short short sleeves and an adjustable drawstring neck line. A faint smell of sweat clings to the wrinkled chemise. You are not surprised considering you were too tired to change into a night gown before bed last night.[otherwise]You’ve worn the chemise long enough that it definitely needs to be laundered[end if].”.
[the scent of Hel_DirtyChemise is “the faint smell of body odor”.]

Volume World

The Second Floor is a Region.

Part Helenas Chamber

Helenas Chamber is a room.
The printed name of Helenas Chamber is “Your Bedroom”.

Helenas Chamber is in the Second Floor.

Chapter Wardrobe

Hel_Wardrobe is a wardrobe in Helenas Chamber.
The printed name of Hel_Wardrobe is “your wardrobe”.
The description of Hel_Wardrobe is “the ancient wood of the Wardrobe feels warm beneathe your hand. The simple ornamentation and heady beeswax smell serve as excellent storage. The doors on the wardrobe are currently [if open]open.[otherwise]closed.”
Understand “wardrobe” or “my wardrobe” or “cabinet door” or “cabinet door” or “cupboard doors” or “cupboard door” as Hel_Wardrobe.
Instead of player taking Hel_Wardrobe:
say “You would need two stout men just to shift it a few feet so as to sweep behind it. You manage not an inch.”.

Section Clothing

[clothing in wardrobe]
Hel_CleanChemise is a chemise in Hel_Wardrobe.
Understand “chemise” or “clean chemise” as Hel_CleanChemise.
the printed name of Hel_CleanChemise is “a clean chemise”.
[the description of Hel_CleanChemise is "The plain, knee-length garment has short short sleeves and a square neck line. ".]
the description of Hel_CleanChemise is “[if worn]The plain, knee-length garment has short short sleeves and an adjustable drawstring neck line.[otherwise]This chemise is clean and still smells like fresh linen.[end if]”.
[the scent of Hel_CleanChemise is “newly washed linen”.]

Hel_stockings are a pair of stockings in Hel_Wardrobe.
The printed name of Hel_stockings is “a pair of white stockings”.
Understand “garter”, “garters”, “stocking” or “stockings” as Hel_stockings.
the description of Hel_stockings is “a pair of white cotton stockings with matching garters that tie below your knee.”.

Hel_drawers are a pair of drawers in Hel_wardrobe.
The printed name of Hel_drawers is “a pair of white linen drawers”.
Understand “drawers” as Hel_drawers.
the description of the Hel_drawers is “The drawers are made from white linen[if Hel_drawers are worn] and extend to just below your knee[otherwise] fasten about your waist with back lacing. When worn the drawers drawers come to just below your knees.[end if].”.

Hel_stays are stays in Hel_wardrobe.
The printed name of Hel_stays is “a set of stays”.
Understand “set of stays” or “stays” as stays.
the description of the Hel_stays is “This particular set of stays has minimal boning and laces up the front.”.

Hel_petticoat is a petticoat in Hel_wardrobe.
the printed name of Hel_petticoat is “a petticoat”.
Understand “petticoat” or “petticoats” as Hel_petticoat.
the description of Hel_petticoat is “a bodiced petticoat with intricate whitework along it’s scalloped bottom hem.”.

Hel_morngown is a morning_gown in Hel_Wardrobe.
the printed name of Hel_morngown is “a white morning gown”.
the description of Hel_morngown is “A simple white muslin morning gown with a high neckline and long sleeves. While still meant for indoor wear, it is better suited to cold days then more fashionable evening dresses.”.
Understand “morning gown”, “white morning gown”, “white gown” and “gown” as Hel_morngown.

Hel_ylwWalkdress is a walking_dress in Hel_Wardrobe.
the printed name of Hel_ylwWalkdress is “a yellow walking dress”.
the description of Hel_ylwWalkdress is “This high waisted yellow calico walking dress is not quite the latest stir of fashion but close enough to make any gentle bred lady proud.”.
Understand “dress”, “yellow dress”, “yellow walking dress” and “walking dress” as Hel_ylwWalkdress.

Hel_CrmWalkDress is a walking_dress in Hel_wardrobe.
the printed name of Hel_CrmWalkDress is “a cream waking dress”.
the description of Hel_CrmWalkDress is “A high waisted walking dress of cream muslim printed scrolling floral pattern in muted shades of brown, rose and blue. It has a modest gathered bodice, long sleeves, and secures at the front with ties.”.
Understand “dress”, “cream dress”, “cream walking dress” and “walking dress” as Hel_CrmWalkDress.

Hel_pelisse a pelisse is in the Hel_Wardrobe.
the printed name of Hel_pelisse is “a blue pelisse”.
Understand “blue pelisse” or “pelisse” as Hel_pelisse.
the description of Hel_pelisse is “a blue pelisse”.

[shoes]
Hel_slippers are a pair of slippers in Hel_Wardrobe.
the printed name of Hel_slippers is “a pair of yellow slippers”.
Understand “slippers” or “pair of slipper” as Hel_slippers.
the description of Hel_slippers is “A pair of yellow, leather slippers with almost no visible heel. Cut-aways on the toes reveal an insert of white satin, embroidered in blue, pink, and green.”.

Hel_whiteslippers are a pair of slippers in Hel_Wardrobe.
the printed name of Hel_whiteslippers is “a pair of white slippers”.
Understand “slippers”, “white slippers” or “pair of slipper” as Hel_whiteslippers.
the description of Hel_whiteslippers is “Simple white satin slippers with ribbons to be wrapped and tied about the ankles.”.

test me with "take clean chemise / wear clean chemise ".[/spoiler]
I guess my specific question is can I find the name of the parent class of a child object?

Oh ha ha I thought I’d posted some other relevant code but I couldn’t find it. Glad it’s useful!

Basically I think if you want to find the parent class you have to use the Object Kinds extension; it’s not built into Inform 7.

Another possible solution would be to create another relation, “conflicts with” or something, and add some more code to the “When Play begins” rule that sets the relations like this:

now every pelisse conflicts with every pelisse; now every chemises conflicts with every chemise; etc.

and then you could check whether the player is already wearing something that conflicts with the noun. This would also let you set half_boots to conflict with slippers, if that’s appropriate. But it’s more typing and more difficult to maintain, since every time you defined a new kind of clothing you’d have to add it to the When Play Begins rule as well.

I haven’t checked out the Object Kinds extension mentioned earlier, but I was able to get this to work (has some I6 code included).

An issue is that Inform7 mangles the name of the parent class of an object, so, if you say “A book is a kind of thing.”, it will produce a class name that looks like K42_book. This may or may not be a problem depending on what you want to do. The kind names are structured, so you could programmatically strip away the prefix if you need the exact name that you used to define the kind in the first place.

"Kind of Annoying"

Irrelevant Location is a room. 

A toy is a kind of thing.

A toy called a ball is here.

A toy called a block is here.

Furniture is a kind of thing. Furniture is usually fixed in place.

Furniture called a table is here.

Furniture called a sofa is here.

Include (-
[ SharedClass x y c;
  objectloop (c ofclass class) {
      if (x ofclass c && y ofclass c) {
          ! filter out common kinds that all objects will share
          if (c ~= Object && c~= K0_kind && c ~= K2_thing) {
              return c;
          }
      }
  }
  return nothing;
];

[ PrintSharedClass x y c;
   c = SharedClass(x, y);
   if (c) {
       print (name) x, " and ", (name) y, " share a kind: ", (name) c, "^";
   } else {
	 print (name) x, " and ", (name) y, " do not share a kind.^";
   }
];
-).

[to print out whether two objects share a kind and print the name of that kind]
To compare the kinds of (X - thing) and (Y - thing):
	(- PrintSharedClass({X}, {Y}); -).

[to just return true if two objects share a kind and false otherwise]
To decide if (X - thing) and (Y - thing) share a kind:
	(- SharedClass({X}, {Y}) -).

when play begins:
	[test out the first rule]
	compare the kinds of ball and block;
	compare the kinds of table and sofa;
	compare the kinds of ball and table;
       [test out the second rule]
	if table and sofa share a kind:
		say "table and sofa share a kind.";
	otherwise:
		say "table and sofa do not share a kind.";
	if block and sofa share a kind:
		say "block and sofa share a kind.";
	otherwise:
		say "block and sofa do not share a kind.";

Before you go too far into the Object Kinds forest, consider that it wouldn’t actually be much work to implement it manually for a dozen garment subclasses. It’s cut-and-paste work, but it’ll take you ten minutes and then you can get back to writing your game.

Oh, I don’t have any objections to writing the individual statements because of the typing. Using the example, Get me to the Church on Time the code used to check for the player wearing two of the same items is:

[code]Instead of wearing a pair of pants when the player is wearing a pair of pants (called the wrong trousers):
say “You’ll have to take off [the wrong trousers] first.”

Instead of wearing a shirt when the player is wearing a shirt (called the wrong top):
say “You’ll have to take off [the wrong top] first.”
[/code]I was worried that if I put in instead rules, or check rules for every type of clothing, it would be really slow. But is that not what you meant?

Anyway, the relation trick work would work and fits nicely with the code Matt already wrote. However, there are times when I’ve wanted to get access to a thing’s kind so thank you for the routine. As always, thank you for taking the time to help. I appreciate it.

I e done the same thing by using adjectives for garments to avoid relation overhead. Garments can be and are declared “torsoworn” “handworn” “pelvisworn” etc and can have multiple adjectives.

Check wearing a handworn garment…if the player wears a handworn garment…do something else…

Also you’ll soon discover that complicated multi-part clothing is an inescapable rathole to spend time on…unless the game is specifically about clothes or has an armor system.

lol, yes I was kind of getting that impression. I’m trying to make something for a friend’s daughters. They asked for something specific, a historic simulation type game, and part of that time period revolves heavily on dress. The good thing is they don’t have high expectations and the game won’t be something for the general public.

luckily, it seems (fingers-crossed) to be working at the moment. I can take on and off multiple layers of clothing on different body parts and check to see if I already have a particular type of garment on.