Open, transparent, GENERIC container that does not list contents during room description

So, let’s say I have a room that contains a sword case and a bow chest, containing swords and bows respectively. The sword case and the bow chest are both stocks, meaning that they are containers holding items that the player can purchase (it’s the best name I could come up with.) I want stocks to list their contents when examined, but not in the description of a room, as this is somewhat irritating:

You can also see a sword case (in which are a wooden practice sword, a stone sword, a steel sword, a silver sword and a diamond-edged sword) and a chest (in which are a flimsy wooden bow, a steel-reinforced wooden bow, a steel-reinforced horn bow and a silver-reinforced horn bow) here.

I’ve tried to use omit contents in listing, like so:

A stock is a kind of container.

Rule for printing the name of something that is a stock:
	omit contents in listing.

However, I need some way to allow Inform 7 to still list the name of the stock, just not its contents. Otherwise, I get:

You can also see an  and an  here.

which is of course highly unintuitive. Furthermore, I’ve tried to add a say instruction inside the rule, but I can’t find anything to include in the say instruction that just lists the name of the stock.

What’s the best way to go about this? For clarity, the contents of a stock should be listed when examining it.

This may be a stupid question, but what happens when you make those stocks scenery? (I’m assuming that they are not movable and thus can be described in the room description.)

Otherwise, maybe this is what you need?

Rule for printing room description details of a stock: stop.

which I basically got from section 18.16 of the manual. And we can add some nice manual examine rule like:

Instead of examining a stock:
say "[The noun] [if more than one thing is in the noun]is filled with useful items: [list of things in the noun][otherwise is one thing is in the noun]contains only [list of things in the noun][otherwise]is entirely empty[end if]."

(Untested code.)

1 Like

By writing “Rule for printing the name of” you are overriding the default name-printing rules. Inform expects you to handle the name-printing yourself within that rule, which you don’t do, so you get no name at all. If you make that an “after” rule instead, it works as expected.

"Containers test"

The marketplace is a room.

A stock is a kind of container.
After printing the name of a stock:
	omit contents in listing.

A sword is a kind of thing.

The sword case is a stock in the marketplace. In it are three swords.

marketplace

You can see a sword case here.

> x case

In the sword case are three swords

5 Likes

Thanks. I also combined your answer with @VictorGijsbers’s to produce:

A stock is a kind of container.

After printing the name of a stock:
	omit contents in listing.

Instead of examining a stock:
	if the noun contains more than one thing:
		say "[The noun] contains the following items for sale:";
		repeat with content running through things in the noun:
			say "[line break]- [a content], for [price of content]";
		say "[line break]";
	otherwise if one thing is in the noun:
		say "[The noun] contains [a second noun], for [price of the second noun].";
	otherwise if the noun does not contain anything:
		say "[The noun] is empty."

Thank you both for your help :slight_smile:

1 Like