I7: Object Listings and Initial Appearance in Containers

Consider the following nascent work of science fiction:

[code]“Test Game” by “C.E.J. Pacian”

The Test Chamber is a room. “The lab techs have left pods 4 and 5 in the middle of the lab.”

A canister is a kind of container. A canister is usually scenery.

Pod 4 is a canister in the test chamber.

In pod 4 is a face hugger.

Pod 5 is a canister in the test chamber.

In pod 5 is the frozen head of Elvis Presley. The indefinite article of the frozen head is “the”. The initial appearance of the frozen head is “The frozen head of Elvis Presley bobs up and down in Pod 5, exuding rock and roll style.”[/code]

This produces the following output:

The output clearly works, but it also clearly could be a lot better.

I’d like to know how to:

  1. Change the default listing of objects in canisters so they are listed in the form “A face hugger is floating in Pod 4.”

  2. Make my irreverent initial appearance for the head of Elvis show up when we examine pod 5.

Obviously, whatever solution we come up with should also work for any other items that may or may not have initial appearances set.

A quick dive into the bowels of the Standard Library suggests that the second problem can be most conveniently solved with:

Instead of examining a canister (called the can):
	if the can contains nothing, say "[The can] is empty.";
	else carry out the printing the locale description activity with the can;
	rule succeeds.

Printing the locale description is the activity used to produce the normal output of the look command. It is usually applied to rooms, but works also for containers (and is used that way by the Standard Library if the player is inside an enterable container).

Note that the rule above never prints the description of the canister. If you want that, you’ll have to include it explicitly, e.g. like this:

Instead of examining a canister (called the can):
	if the description of the can is not "":
		say "[the description of the can][line break]";
	else if the can contains nothing:
		say "[The can] is empty.";
	carry out the printing the locale description activity with the can;
	rule succeeds.

As for the first problem, this (combined with the code above) seems to do the trick:

Rule for listing nondescript items of a canister (called the can):
	say "[A list of marked for listing things] [if the number of marked for listing things is 1]is[else]are[end if] [if the locale paragraph count is greater than 0]also [end if]floating in [the can]."

(Edit: Oops, just fixed that last rule so that it doesn’t mess up normal room descriptions.)

Awesome!

I did tweak the “Instead of examining” rule to a “Carry out examining” rule so I don’t lose any check and after rules, but this works perfectly for what I need.

Many thanks, vyznev.