Working with groups of similar things

Is there an easy way to work with duplicate things? I have a room with 6 beds and 6 footlockers. I must repeat everything for each and the room description shows a clutter of repeated phrases. Here is what it looks like:

Here is the code:

[BARRACKS]
Barracks is west of N-North Corridor. Exit of Barracks is "E".
Description of Barracks is "This rectangular room is the acolytes[apostrophe] sleeping quarters--barren and plain.[no line break][run paragraph on] [Description of cots]".

Cots is scenery in the Barracks. Description of cots is "Six cots are aligned along each wall in a tidy array. Beneath each cot is a footlocker.".
Understand "(none)" as plural of cot.

A clerical-cot is a kind of enterable supporter.
Description of cotView is "A thin mattress in a wooden frame. The acolytes who slept here were not accustomed to luxury. Under each cot is a letter painted on the floor: A, B, C, D, E, or F.".
Understand "cot" as clerical-cot.

cot A, cot B, cot C, cot D, cot E, and cot F are clerical-cots in the barracks.
Description of cot A is "[description of cotView]".
Description of cot B is "[description of cotView]".
Description of cot C is "[description of cotView]".
Description of cot D is "[description of cotView]".
Description of cot E is "[description of cotView]".
Description of cot F is "[description of cotView]".

Understand "lay on [thing]" as entering [thing].
After entering an enterable supporter in barracks:
	say "[one of]It feels scratchy.[or]The mattress is too thin to be comfortable.[or]How could anyone sleep on this?![or]I hope it doesn't have bedbugs![purely at random]".

[Suppress the room description when exiting a cot.]
After getting off enterable supporter: 
	say "(Standing up.)";
	stop the action.
	
test beds with "gonear barracks / x cots/ x cot/ x clerical-cot/ x cot B/ sit on cot B/ get off cot B/ lay on cot B/ get off cot A/ get off cot B/ x cot A/ x mattress".

Footlockers is scenery in the barracks. 
Understand "(none)" as plural of footlocker.
Description of footlockers is "A heavy metal box bolted to the floor. Although there is a place for a padlock, this footlocker does not have one.".

A footlocker is a closed openable container. It is fixed in place. 
footlocker A, footlocker B, footlocker C, footlocker D, footlocker E, and footlocker F are in barracks.

Yes, I can make beds and footlockers scenery, but then they lose their function as enterable supporters or openable containers, respectively.

Without wading in too far, you should be able to create a type with all the attributes you want.

A cot is a kind of supporter. It is enterable. It is scenery.

1 Like

You can combine multiple things in a group when listing them like this:

Utensil is a kind of thing. The knife, the fork and the spoon are utensils. Before listing contents: group utensils together as "utensils".

This prints out “two utensils (fork and spoon)”

(info here: 18.13. Listing contents of something)

So you could say Before listing contents: group clerical-cots together as "cots" or something. That section has other examples that could help.

However, you can make beds and footlockers scenery! It doesn’t affect the enterable or openable property at all. You can just say ‘a clerical-cot is usually scenery’. It doesn’t cause any problems, and is probably the best solution here. If you add that line to your code, it compiles perfectly.

4 Likes

Just to go back to this opening question, my experience is, not really? The answers below will certainly help, but as you’ve noticed there’s inevitably a certain amount of cruft on both the author’s and the player’s side of things – like, as you’ve noticed, it can be a pain to wrangle things to make sure objects are displaying and behaving correctly, and on the player’s side, it’s often a pain to figure out how to disambiguate thing, beyond the potentially credulity-straining idea that the acolytes letter-coded their cots instead of just knowing whose was whose.

There are times when it’s worth paying this tax, certainly, but in many cases, I think it’s the counsel of wisdom to just not get into this mess in the first place. Like, unless you’ve got a puzzle or something that depends on which of these identical cots and footlockers are which, it might be better all around to just have a single plural-named “cots” and a single plural named “footlockers” object; that way the player can conveniently examine them all at once, which is presumably what they’re going to do, without having to tediously lawnmower through 12 total objects, and you can spend your implementation time on stuff that’s more important to the game (I note you already have a “cots” scenery object, I’m guessing to catch players attempting to X COTS or whatever, so actually you’re already halfway to this approach).

(Again, not to say this approach is necessarily bad or ill-suited for what you’re doing! But I have some Inform-PTSD from doing a big puzzle involving multiple identical objects, and feel like it’s often been helpful for me after that experience to take a step back and ask “hold on, do I really need to do things this way?” whenever I’m tempted to do an indistinguishable-kinds thing).

5 Likes
  • Your current definition of the footlockers has a bug. You’ve created a single footlocker that is a container, rather than a kind, then a bunch of individual footlocker objects that are not containers. Instead it should be:
A footlocker is a kind of container. It is usually closed, openable, fixed in place.
footlocker A, footlocker B, footlocker C, footlocker D, footlocker E, and footlocker F
are footlockers in barracks.

This is usually a good idea for these situations, but in this case, you’d probably have to group the cots together, then the footlockers together. I don’t think you can group different kinds of things into one group? And aesthetically, you’d then have to write a description for a group of cots and another for a group of footlockers.

So as Brian said, another good solution is to make the cots and footlocker kinds both scenery, as well as whatever else they are. You’ve already got a basic description of the whole setup in the room description, but just add in the mention of the labelling A-F.

e.g. “Six cots, labelled A-F, are aligned with the wall in a tidy array. Beneath each cot is a matching lettered footlocker.”

I did a quick experiment of putting something on a cot and then LOOKing, and it reads fine.

  • A last little observation on your code. Since all the cots are identical in description, you can get rid of the concept of ‘cotView’ and just give the description to the kind:

The description of a clerical-cot is usually "A thin mattress in a wooden frame. The acolytes who slept here were not accustomed to luxury. Under each cot is a letter painted on the floor: A, B, C, D, E, or F."

-Wade

1 Like

You can group any “description of things” together.

1 Like

Do you mean doing something like this? (using current example, but making cots and footlockers not scenery first.)

Definition: a thing is groupy:
	if it is a clerical-cot, decide yes;
	if it is a footlocker, decide yes;
	decide no;

Before listing contents of the barracks:
	group groupy things together;

Rule for grouping together groupy things:
	say "the military stuff";

I created ‘groupy’ to lump together two kinds. Is that the kind of thing you meant?

-Wade

Yeah, that’s exactly the idea I was talking about, although I wasn’t sure if it could be applied to the OP’s original example. In playing around with it, however, I noticed an annoying limitation that I don’t have time to get into as I’m on my way to work.

1 Like

I have found a truly wonderful proof, but this margin is too small to contain it.

1 Like

It’s my impression or your example is inspired by late 1970s-early 1980s D&D/AD&D adventure modules, whose often indulges in detailed description of dungeons (and evil temples…)'s accomodations ?

Best regards from Italy,
dott. Piergiorgio.

:joy:

2 Likes

:rofl:

Thanks for all this help. I will try these ideas out. What I originally wanted was the “Listing Contents of Something” which I missed somehow. I’ll let you know what I find.

OK, I tried out some of these ideas. The group idea of cots and their “subclasses” worked great, but the lockers failed miserably. Call me dim but I can’t see the difference between the two. I get this compile error:

**Problem.** The sentence 'The footlockers are scenery in the barracks' [![](blob:https://intfiction.org/9dc2bb0f-d890-47ff-8a85-94bd181af760)](source:story.ni#line2019) seems to be telling me that two descriptions, one a form of footlocker and the other of object, are the same. That's a little puzzling - like saying that 'An open door is a container.'

What am I missing?

Oh! I forgot the revised code:

Barracks is west of N-North Corridor. Exit of Barracks is "E".
Description of Barracks is "This rectangular room is the acolytes[apostrophe] sleeping quarters--barren and plain.[no line break][run paragraph on] [Description of cots] [Description of lockers]".
Before listing contents: group clerical-cots together as "cots".
[Before listing contents: group lockers together as "lockers".]

A clerical-cot is a kind of enterable supporter. Clerical-cot is usually scenery.
Description of clerical-cot is "A thin mattress in a wooden frame. The acolytes who slept here were not accustomed to luxury. Under each cot is a letter painted on the floor: A, B, C, D, E, or F.".

cot A, cot B, cot C, cot D, cot E, and cot F are clerical-cots in the barracks.
The cots are scenery in the Barracks.
Description of cots is "Six cots are aligned along each wall in a tidy array.".

A footlocker is a kind of container. A footlocker is usually closed and openable. A footlocker is usually scenery. 
Description of footlocker is "Beneath each bed of the six beds is a footlocker.".

locker A, locker B, locker C, locker D, locker E, and locker F are footlockers in barracks.
The lockers are scenery in the barracks.
Description of locker is "A heavy metal box bolted to the floor. Although there is a place for a padlock, this footlocker does not have one.".

When I showme lockers, I get that there is no description, but obviously, it is there in the code. ?!

Brian,
Why doesn’t it print out THREE things: fork, spoon, AND knife)?

Good question! That’s from me not copying the whole text; looking more closely, they’re saying that it updates automatically, so that if you are in an area that just has those two (or if you are holding those two) then it would list them like that. If the knife is present, all three will be mentioned!

I think I found the problem. Although I listed the six lockers explicitly, it did not recognize “x lockers”. I assumed that lockers would be understood as plural of locker, but it wasn’t. I even said “Plural of locker is lockers”-- no joy. As soon as I put “lockers are scenery in the barracks”, then “x lockers” gave the group description, as desired.

For those interested, here is the cleaned up code. It must have reduced about 20%.

[BARRACKS]
Barracks is west of N-North Corridor. Exit of Barracks is "E".
Description of Barracks is "This rectangular room is the acolytes[apostrophe] sleeping quarters--barren and plain.[no line break][run paragraph on] [Description of cots] [Description of lockers]".
Description of cots is "Six cots are aligned along each wall in a tidy array.".
Description of lockers is "Beneath each of the six cots is a footlocker.".

A cleric-cot is a kind of enterable supporter. A cleric-cot is usually scenery.
Description of cleric-cot is "A thin mattress in a wooden frame. The acolytes who slept here were not accustomed to luxury. Under each cot is a letter painted on the floor: A, B, C, D, E, or F.".

cot A, cot B, cot C, cot D, cot E, and cot F are cleric-cots in the barracks.
cot A, cot B, cot C, cot D, cot E, and cot F are scenery in the barracks.
The cots are scenery in the Barracks.

A cleric-box is a kind of closed openable container. A cleric-box is usually scenery.
Description of cleric-box is "A heavy metal box bolted to the floor. Although there is a place for a padlock, this footlocker does not have one.".

locker A, locker B, locker C, locker D, locker E, and locker F are cleric-boxes in barracks. 
locker A, locker B, locker C, locker D, locker E, and locker F are scenery in barracks.
The lockers are scenery in barracks.

It seems that if a particular object has no description, it borrows it from its parent. “x cot B” produces the cleric-cot description. Am I right about this?

That’s correct, almost[1] all properties are inherited from the parent kind.

[1] Plurals aren’t, for one.