Listing contents of empty things

This should be terribly simple, but I can’t find it in the documentation:

How do I change the listing-contents activity for a (particular) empty object so it prints something other than “empty”?

I assume you mean when the game prints “(empty)” after an open container in the room description, which isn’t governed by the listing contents of activity, but rather the “Printing room description details of something” activity (see ch 17.15). Try this:[code]Lab is a room.
The box is a container in the lab. It is open, openable, and opaque.
The ball is in the box.

Rule for printing room description details of the box:
unless the box contains something:
say " (with nothing inside it)" instead;
otherwise:
continue the activity.

test me with "get ball / l ".[/code]
If you want to change how this parenthetical info is printed in inventory lists, see example 177 “Equipment List.”

This thread, especially the longish post on page 2, explains in detail the interrelationship between the listing the contents and printing the name of activities:

https://intfiction.org/t/supporter-strangeness/1444/1

–Erik

Right, but all this only applies when the item is in the location. It’ll still display (empty) in inventory.

See here:

inform7.com/learn/man/doc291.html

So you’re suggesting I situationally rename the object from “object” to “object (text I want)” and omit contents?

There’s no way to directly change the “(empty)” part?

That may seem like a different problem from the one discussed in that thread, but it’s actually exactly the same issue. We tend to assume that the “listing contents” activity controls the printing of the contents of a container, but in the case of inventory, it’s the listing contents of the player activity that’s controlling things. As with the examples in the thread I linked to, the activity you really need to intervene in is the “printing the name of” activity. To intervene only in the case of the inventory, you could use this (following on Mike’s example):

After printing the name of the box while listing contents of the player: unless the box contains something: say " (with nothing inside it)"; omit contents in listing; otherwise: continue the activity.

To intervene in every case, use the same code but with the more general preamble: “After printing the name of the box”.

Incidentally, the linked thread also includes some code for diagnosing this kind of issue. If you include this code in your game:

[code]Before listing contents of an object (called X):
say "–>[italic type](listing contents of [name X])[roman type] ";
continue the activity.

After listing contents of an object:
say “<–”;
continue the activity.

To say name (O - an object): [prints the name of the object w/o using the printing the name of activity, which would create an infinite recursion]
(- print (string) {O}.short_name; -)[/code]

…then it will tell you straight out that the inventory listing is incorporated under “listing contents of the player”. (Again, though, you only need to know that if you want different behavior in different contexts. If you want the contents to be printed in exactly the same way everywhere, you can use just a single “printing the name of” rule, as mentioned above or in the manual page that Zed links to.)

–Erik

“Omit contents in listing” really just means: Don’t invoke the I6-level list-writer when listing the contents of this item. There is no I7 interface to the list-writer; you either allow it to do its thing or you don’t. Since it is the list-writer that produces the “(empty)” text, the only I7-level way to change the “(empty)” text is to intervene via “the printing the name of” activity.

It sounds as though you want to change “empty” generally, for all text in the game. To do that, you could include a rule like this:

After printing the name of a container (called the receptacle): unless the receptacle contains something: say " (containing nothing)"; omit contents in listing; otherwise: continue the action.

That should act on any container in any context.

(I agree with you that the manual could do a better job in discussing everything just about everything pertaining to listing contents.)

–Erik