A question about grouping/listing

In my attached example code, I’m trying to fashion a custom description of a hook (on which clothes are hanging.)

I’ve made a kind of thing: neckwear. I’ve got a rainbow scarf (neckwear), a polka dot scarf (neckwear) and a hat (not neckwear) on the hook.

I’m trying to use a combo of a ‘before listing contents of…’ and a ‘rule for grouping neckwear together…’ to get what I want. But I must have the wrong combination or I’m addressing the wrong rules/activities.

The description I get when the game runs is
“Hanging on the hook here you see a rainbow scarf, a polka-dot scarf and a hat.”

What I was hoping to get was
“Hanging on the hook here you see two ugly scarves and a hat.”

Could someone please advise on how I can get there? Note that I only made the scarves ‘neckwear’ kind for the purpose of making the grouping rule. If we can get the effect just addressing the two scarf objects specifically, that would also be fine.

Thanks much. Code below.

-Wade

[code]“Neckwear grouping”

the office is a room.

a hook is a supporter. It is in the office.

a neckwear is a kind of thing.

a rainbow scarf is a neckwear. It is on hook.
a polka-dot scarf is a neckwear. It is on hook.

a hat is on hook.

rule for writing a paragraph about hook:
say “Hanging on the hook here you see [a list of things which are on the hook].”;

Before listing contents of room when location is office:
group neckwear together;

Rule for grouping together neckwear when location is office:
say “two ugly scarves”;[/code]

According to the rules command, the rule that fires just before describing the hook is “rule for writing a paragraph about hook”. So I tried the following replacement, and it seems to work as you want it to:

Before writing a paragraph about the hook: group neckwear together;

The “grouping together” mechanism only works when Inform is producing a list directly through a listing contents activity (usually for a room or while taking inventory). But here the list of things on the hook is being generated by your text substitution “Hanging on the hook here you see [a list of things which are on the hook].” So it won’t work.

You might be able to work it by explicitly calling the listing contents activity with the hook.

Or it might be easier to expand your “writing a paragraph about the hook” rule to print exactly what you want, and forget about the grouping mechanism.

Thanks for the input, both.

Knight’s way works within the rule for writing… but produces an additional, conventional line about what’s on the hook. I might be able to suppress the additional line.

Re: writing the whole thing within my ‘rule… paragraph’, the thing is that in the real game, there are lots of things that will get moved on and off the hook, so using the list mechanism as I do automates away a lot of headache.

-Wade

This works:

rule for writing a paragraph about hook: 
	say "Hanging on the hook here you see ";
	list the contents of the hook, as a sentence;
	say ".";

Before listing contents of room when location is office:
	group neckwear together;

Before listing contents of hook when location is office:
	group neckwear together;

Does that work primarily because you took the list mechanism out of brackets? Or because you addressed listing both in the room and ‘in’ the hook?

Or is it that the former is the important change and the latter change captures all needed circumstances?

-Wade

Both are needed. “list the contents of OBJ” is a high-level entry point to the list-writing mechanism, and it invokes the “listing contents of OBJ” activity to figure out grouping on the fly.

The original code uses “say a list of DESC”. With that entry point, the list-writing mechanism doesn’t know what the parent object is, so it never calls “listing contents”.

OK. Thanks much.

-Wade