Grouping Objects Descriptions

So, when I found “grouping” in the documentation, I was excited, but I’m not sure it does what I hoped it would. If I have, say, 5 swords in the room, and I want to group them together, all this code seems to do is make sure they are strung together instead of scattered in the room description. This is nice, but I am looking for a way to get results like “There are several swords, a few pieces of armor, and a cloak on the ground. There are various tools, a basket of fruit, and a piece of paper on the desk.”

I have no idea where to even begin here, so I don’t have psuedo code for an example, but is there an extension to do stuff like this? Group items together by kind per holder, instead of listing every single item or not listing anything?

Write a rule for listing nondescript items that groups things the way you want it to.

Well, I’ve been trying for a while on this, and I’m just not sure… I got some help in another thread from eu about walking the kind hierarchy, but I’m just not sure how to put all the pieces together.

Maybe I can rephrase what I’m trying to do… any time there is a list of things, and there are more than 1 things of the same kind, I would like to group them together with a phrase like “there are [the number of the kind of the item] [the kind of the item] here” as in “there are 3 weapons here” instead of listing “there is a sword, a sword, and a sword here”… there really isn’t something already written to handle this?

What I have so far, (again with kind hierarchy help from eu):

To decide what number is kind index of (O - an object): (- ({O}.KD_Count) -).
To decide what number is the parent kind index of the kind index (I - a number): (- KindHierarchy-->({I} * 2 + 1) -).
To say (N - a number) as a kind index: (- print (I7_Kind_Name)(KindHierarchy-->(2 * {N})); -).

To say the list of nondescripts:
	let L be a list of numbers;
	repeat with items running through things in the location:
		if items is not a person:
			if the kind index of items is not listed in L:
				if the kind index of items is greater than 1:
					let x be the kind index of items;
					if the parent kind index of the kind index x is not listed in L:
						add the parent kind index of the kind index x to L;	
	repeat with results running through L:
		say "[results as a kind index]";
	
Rule for listing nondescript items:
	say "[the list of nondescripts]";

This just truncates lists of more than one thing to a single entry, but doesn’t give the number or any grammatical syntax. I’m kind of at a loss at how to keep those pieces of information together. If I have a sword and two axes in a room, the above gives results like this:

Room Name
weapon

That’s it, just “weapon”. Not “3 weapons” let alone “There are 3 weapons here.” I’m really struggling trying to figure out how to add to this…

Nevermind, I think I’m starting to make progress again… if I figure it out, I’ll post my results.

To do this for a particular kind:

Before listing contents:
	group weapons together.

Rule for grouping together weapons:
	say "[listing group size in words] weapons".

This is mentioned at the end of chapter 17.14.

Doing it for several kinds will require several rules, but that’s almost certainly easier than the kind-index hacking you’ve got now.

Thank you zarf! And, argh… I only read 17.13, and got bogged down trying to figure that out before giving up and seeking the more hackish way, as you called it.

This will work, but I have to create a rule by hand for each kind I want grouped… I was hoping for a more centralized, programmatic way for it to group things, but I guess in the end that might be virtually, if not entirely impossible because different groupings of things might need to be grouped at different levels of hierarchy and have different indefinite articles or other supporting phrases. OK… I guess I’ll do what is outlined in 17.14 for each kind I want grouped! No problem, and thank you very much!