[I7] Saying a list of things with phrase options

I have a custom action for taking inventory so I can list the things carried by the player and the things worn by the player separately. I want to list them in a format similar to that of “list the contents of the player, as a sentence, including all contents, listing marked items only, using the indefinite article”. But I can’t just do that because I need to list the contents of different lists than that phrase is written for. Short of writing a whole new listing routine, is there any way I can apply those same options to any arbitrary list?

[spoiler]Unless I’m missing something, for most purposes you should be well off with

say "You are carrying [a list of things carried by the player] and wearing [a list of things worn by the player]." [/spoiler]

Edit: Whoops, sorry, I did miss the listing all contents option. Anyway, example 177 (Equipment List) in the manual chapter 11.14. shows how to list worn and carried items separately.

That’s adequate for most purposes, but I specifically need to include all contents and not list the items not marked for listing.

I considered that example, but it works by overwriting the existing marked for listing properties of the objects, so it wouldn’t work for listing only the things that I’ve declared elsewhere as marked for listing.

I suppose I could get around that by creating a new “unlistable” property, declaring all the items I don’t want listed to be unlistable, and then in the inventory action, change all the unlistable objects to be unmarked for listing. I was hoping not to have to change my object definitions, but it sounds like there isn’t a simpler way of doing this.

I kind of suspect I’m totally missing the point, but anyway the “list the contents of” phrase (with all its options) should work for listing the contents of any object, not just the player.

The issue is that “list the contents of” only does exactly that: lists the objects that are contained by another object. The list I want to print is not the objects that have the contained by relationship with the player, but the worn by relationship, so I can’t use “list the contents of” for that. What I really need is the equivalent of saying “[list of description of objects]”, but that only prints the entire list in sentence form with definite or indefinite articles, whereas I need more control over the output than that.

Practical example: if the player is carrying a container with something in it, the default inventory action will say “a container (in which is a something)”. I want that. But if you say “[list of things carried by the player]”, you only get “a container”. Now, because I’m listing the things carried by the player and the things worn by the player separately, I don’t have the option of using “list the contents of” because it doesn’t make that distinction. So I have to say “You are wearing [list of things worn by the player],” and that doesn’t show the “(in which is a something)” because (presumably) that message is generated by the “list the contents of” function, which is never getting called.

The built-in extension Complex Listing might also be helpful.

Ah, yes, that does look very useful. Thanks.

(edit: though including contents still isn’t one of the style options. Damn. Oh well, it’s a starting point)

I’m sure this is not the most elegant way to do it, but it may work.

[code]
Carry out taking inventory (this is the print custom inventory rule):
let C be the list of things carried by the player;
let W be the list of things worn by the player;
repeat with item running through W:
remove the item from play;
say "You are carrying ";
list the contents of the player, as a sentence, including all contents, listing marked items only;
say “.”;
repeat with item running through C:
remove the item from play;
repeat with item running through W:
now the player wears the item;
say "You are wearing ";
list the contents of the player, as a sentence, including all contents, listing marked items only;
say “.”;
repeat with item running through C:
now the player carries the item.

The print custom inventory rule is listed instead of the print standard inventory rule in the carry out taking inventory rulebook.[/code]