Rule for grouping together / list of objects in the holder

Because plain group objects together, group objects together as, and group objects together giving articles aren’t what I’m looking for, I tried to combine “before listing contents: group objects together” with a custom rule for grouping objects together. But I couldn’t figure out some way to listify only the objects that should actually be grouped together – if I simply let L be the list of (kind), or the list of touchable (kind), that is too broad. I need to be able to distinguish the contents of the group on the table from the group in the box from the group I’m directly carrying – multiple metaphorical buckets.

I tried using “the list of objects in the holder”, but Inform doesn’t seem to understand that (and the search results for “holder” were talking about the holder of a specific object). Is there an appropriate “holder” syntax that I missed, or a holder-level equivalent of “the location” for referring to all objects in the same… er… sub-location place?

(My full desired behavior includes pre-examination and post-examination differences and listing group thresholds, producing something like the following:

[spoiler]

)[/spoiler]

Is it just the formatting you want to be different from the normal grouping together rules, or something more specific? What do your current code and output look like?

I think it’s just the formatting, aside from the conditional stuff. My current code is a mess of commented-out retries and wild guesses. The code that was overly broad was

Before listing contents: group components together. Rule for grouping together components when the pile is unknown: say "a pile". Rule for grouping together components when the pile is known and the listing group size is greater than 3: let L be the list of touchable components; say "various parts: [L with indefinite articles]".

(The pile is a dummy object I am using to produce pre-/post-examination differences.)

If I took a couple of parts and then also picked up the box, I would get the following inventory listing:

You are carrying: a box (open) various parts: a point, a line, a triangle, a square, a pentagon, a hexagon, a heptagon, an octagon, a nonagon, and a circle point and line

(notice the repetition of the point and the line)

And the nonfunctional holder code simply replaced “touchable components” with “components in the holder”. This doesn’t compile.

Here’s something that might work for you. See also Ex 333 “AARP - Gnosis” in the Recipe Book.

[Note: code edited from original post to add slight improvements.]

[spoiler][code]Place is a room.

A utensil is a kind of thing. [The next two statements are only necessary if you want these words to describe utensils generally; they’re not needed for your example.] Understand “utensil” as a utensil when the item described is a utensil and the item described is not part of a utensil group. Understand “utensils” as the plural of utensil.

Rule for deciding whether all includes a utensil part of a utensil group when the current action is examining:
it does not. [prevents examining utensils on turn they’re freed from group]

Rule for deciding whether all includes a utensil enclosed by the player when the current action is taking:
it does not. [prevents taking utensils out of held containers when using plural]

Understand “examine [things]” as examining. [needed to handle inspecting multiple groups or items at once]

[A thing can be spotted or unspotted.]

A utensil group is a kind of thing. Understand “single” or “utensil” as a utensil group when the item described is a utensil group and exactly one thing is part of the item described. Understand “mixed” or “lot” as a utensil group when the item described is a utensil group and at least two things are part of the item described. Understand “utensils” as a utensil group when the item described is a utensil group and at least one thing is part of the item described. Understand “utensils” as the plural of a utensil group.

[Rule for deciding the concealed possessions of a utensil group:
decide yes.] [comment out or remove if you don’t want player to be able to access the fork until after examining set A]

Rule for printing the name of a utensil group (called uninspected group):
say “a [if the uninspected group incorporates at least 2 things]mixed lot of utensils[otherwise]single utensil[end if]”.

Before taking something (called item) part of a utensil group (called set):
now item is in the holder of set. [no longer part of set]

Before examining a utensil (called foreseen item) part of a utensil group (called prior group):
now the foreseen item is in the holder of prior group. [no longer part of set, but this rule has no effect if members of set are concealed by optional rule above]

Carry out examining a utensil group (called inspected group):
say “[if the number of things part of the inspected group is at least two]It includes [otherwise]It’s [end if][a list of things part of the inspected group].”; [note spacing error when examining multiple things understood by “utensils” – I don’t know how to fix this but maybe someone else does]
now every thing part of the inspected group is in the holder of the inspected group;
now the inspected group is off-stage;
rule succeeds. [halts processing of carry out rulebook]

Before listing contents:
group utensils together giving articles.

Before grouping together utensils when the current action is not examining a utensil group:
say "various utensils: ".

A closed openable container called a box is in Place. A privately-named utensil group called set A is in the box.

A spoon, a fork, a knife, a ladle, a pair of tongs, and a pair of chopsticks are utensils part of set A.

The player carries a privately-named utensil group called set B. A utensil called a spatula is part of set B.[uncomment to demonstrate having multiple utensil groups in play]

[Instead of jumping:
say “unspotted: [the number of unspotted on-stage things that are not the player].”]

test me with “i / open box / x fork / x utensils / close box / open box / take knife / i / take fork / take spoon / take chopsticks / take box / i / drop utensils / look / take utensil / fork”[/code][/spoiler]

It produces the following output from “>TEST ME”:

[edit: updated to reflect code changes in edit above]

Holy moly! Thanks for going so detailed :open_mouth: Okay, if I understand correctly, the core of this idea is making individual items parts of a dummy object called “utensil group”? (Although there are many rules I would not have ever given a single thought to. And I had no idea “rule succeeds” halted carrying out!)

Yes, basically.

It’s possible to fix the funny-spacing error I mentioned, but it’s a bit involved so unless you really need it, I would skip the

Understand "examine [things]" as examining.

part. Also, you probably want to change one line so the player can refer to “mixed lot of utensils”:

Understand "mixed" or "lot" [*] or "of utensils" [*] as a utensil group when the item described is a utensil group and at least two things are part of the item described. 

And since the parser isn’t very happy when you take away an easy way for it to resolve “>X UTENSILS” in a situated with a mixed lot and some individual utensils, there is probably some more work to do for polish that is beyond my skill level. Maybe someone else can help more.

Also note: The bits about spotted/unspotted are some leftovers I forgot to take out. You can ignore them.