Chapter 3: Place
3.1. Room Descriptions

The printing of a room description is a more delicate business than it might initially seem to be: Inform has to consider all the objects that the player might have brought into the room or dropped there, and all the objects on visible supporters, and decide how to group and list them.

All of this behavior is handled by the looking command, so we find the relevant rules in the carry out looking rulebook. To go through the elements step by step:

Looking begins by printing the name and description of the room we're in. We can introduce variations into room names and descriptions by changing their printed name and description properties, as in

change the printed name of the Church to "Lightning-Struck Ruin";
change the description of the Church to "The beams overhead have been burnt away and the pews are charred. Only the stone walls remain.";

If we need more drastic effects, we can turn off or change either of these features by altering the rules in the carry out looking rulebook. For instance, to remove the name of the location entirely from room descriptions, we would write

The room description heading rule is not listed in the carry out looking rules.

(A word of warning: there is one other context in which the game prints a room name — when restoring a save or undoing a move. To omit the room title here too, add

Rule for printing the name of a room: do nothing.)

Ant-Sensitive Sunglasses demonstrates how to use activities to make more flexible room description text.

Next, the game determines what items are visible to the player and need to be described. These never include the player himself, or scenery, but other things in the environment will be made "marked for listing". This is also the stage at which Inform chooses the order in which items will be listed.

We are allowed to meddle by changing the priorities of objects, in case we want some things to be described to the player first or last in the room description; Priority Lab goes into detail about how. We can also force things to be left out entirely: Low Light handles the case of an object that can only be seen when an extra lamp is switched on, even though the room is not otherwise considered dark. Copper River implements the idea of "interesting" and "dull" objects: the game determines which items are currently important to the puzzles or narrative and mentions those in the room description, while suppressing everything else.

Then Inform carries out the writing a paragraph about... activity with anything that provides one; anything it prints the name of, it tags "mentioned". Thus

Rule for writing a paragraph about Mr Wickham:
    say "Mr Wickham looks speculatively at [list of women in the location]."

will count Wickham and everyone he looks at as all having been mentioned, and will not refer to them again through the rest of the room description. More complicated uses of writing a paragraph abound. A developed system for handling supporters that don't list contents appears in The Eye of the Idol.

Inform then prints the initial appearances of objects that are marked for listing but not already mentioned; and then it performs the listing nondescript items activity, collating the remaining objects into a paragraph like

You can see a dog, a hen, ...

We can pre-empt items from appearing in this paragraph or change their listing by intervening with a Before listing nondescript items... rule, as in

Before listing nondescript items when the player needs the watch:
    if the watch is marked for listing:
        say "The watch catches your eye.";
        change the watch to not marked for listing.

If we wanted the watch always to be listed this way, it would be better to give it an initial appearance, but for conditional cases, the listing nondescript items activity is a good place to intervene. For instance, Rip uses this activity to incorporate changeable or portable items into the main description text for a room when (and only when) that is appropriate.

The listing nondescript items activity also allows us to replace the "You can see..." tag with something else more fitting, if for instance we are in a dimly lit room.

When the game compiles the list of nondescript items, it adds tags such as "(open)" or "(empty)" or "(on which is a fish tank)" to the names of containers and supporters. We can suppress or change the "(empty)" tag with the printing room description details of activity, as in

Rule for printing room description details: stop.

And we can suppress the "(open)" and "(on which is...)" sorts of tags with the "omit the contents in listing" phrase, as in

Rule for printing the name of the bottle while not inserting or removing:
    if the bottle contains sand, say "bottle of sand";
    otherwise say "empty bottle";
    omit contents in listing.

Finally, the looking command lists visible non-scenery items that sit on scenery supporters, as in

On the table is a folded newspaper.

These paragraphs can be manipulated with the printing the locale paragraphs description activity.

Another common thing we may want to do is change the description of a room depending on whether we've been there before (as in Slightly Wrong) or on how often we've visited (as in Infiltration). Night Sky, meanwhile, changes the description of a room when we've examined another object, so that the player's awareness of his environment is affected by other things the character knows.

* See Looking for ways to change the default length of room descriptions


321
* Example  Ant-Sensitive Sunglasses
What are activities good for? Controlling output when we want the same action to be able to produce very flexible text depending on the state of the world -- in this case, making highly variable room description and object description text.

WI

Suppose we want to create an object -- or maybe even a series of objects -- that warp the player's perception of every room description and object around him.

We've already seen some ways to create variations in text. For instance, we could make a room description with if substitutions in it, like so:

The Kitchen is a room. "[if the player is wearing the sunglasses]Are ants coming out of the sink? No, probably no.[otherwise]A small kitchen tucked into a corner of the vacation house. There is storage space for five or six cups, a sink, a two-ring stove; nothing else to speak of.[end if]"

That works fine if we have one or two variations we want to add; it's not so good if we're going to have several items that work like the sunglasses, or if we want the sunglasses to override the description of every room in the house.

A slightly more flexible method is to use a substitution that calls out to a say phrase, like this:

The Kitchen is a room. "[kitchen-description]"

To say kitchen-description:
    if the player is wearing the sunglasses:
        say "Are ants coming out of the sink? No, probably no.";
    otherwise:
        say "A small kitchen tucked into a corner of the vacation house. There is storage space for five or six cups, a sink, a two-ring stove; nothing else to speak of."

But again this doesn't handle the case of overriding multiple rooms at once very well.

When we reach a point where we need a given piece of text to be very flexible depending on the world model, it's time to use an activity.

Activities offer several advantages. One, we can create an activity like this:

Printing the room-description of something is an activity.

and then write a rule that applies to multiple rooms at once, like:

Rule for printing the room-description of a room when the player wears the sunglasses:
    say "The walls look like they're covered with ants. Just a coincidence, I'm sure."

Inform's usual rule-ranking also means that more-specific rules will override less-specific ones, so we could add

    Rule for printing the room-description of the Kitchen when the player wears the sunglasses:
    say "Are ants coming out of the sink? No, probably not."

and have that rule override the behavior of the activity just in the kitchen. Meanwhile, our base room descriptions remain straightforward and uncluttered by if-statements.

Several other examples will show how to hook activities into existing actions: Crusoe goes into detail about how how to make the descriptions of things more variable, and Aftershock demonstrates activities for describing the behavior of switchable devices.

Here, we preview all of those methods, just to get a sense of how they work and why they might be useful in controlling a game. Subsequent chapters go into more detail about the syntax of creating activities and the list of activities that are already defined by Inform.

"Ant-Sensitive Sunglasses"

Part 1 - Procedure

To add a new activity to an existing Inform rule, we need to do three things:

1) Define our new activity.

2) Give a basic rule that says what is supposed to happen when that activity occurs, as in "Rule for..."

3) Replace the existing rule in Inform's rulebooks with a new one that calls on our activity.

Here we do this with examining:

Section 1 - Item Description

Printing the description of something is an activity.

Now, by default, we want to print the description property; we just want the option to write some extra rules overriding that property. So we tell Inform that our most basic rule for printing the description of something is just to give that description text:

Rule for printing the description of something (called item):
    if the description of the item is not "":
        say "[description of item][paragraph break]";
    otherwise:
        say "You see nothing special about [the item].".

Next, we need the standard examining rule to look at our printing-the-description activity:

The activity-based examining rule is listed instead of the standard examining rule in the carry out examining rules.

This is the activity-based examining rule:
    carry out the printing the description activity with the noun;
    rule succeeds.

Now we do the same thing to room descriptions.

Section 2 - Room Description

Printing the room-description of something is an activity.

Rule for printing the room-description of a room (called item):
    if the description of the item is not "":
        say "[description of item][paragraph break]";
    otherwise:
        do nothing instead.

The activity-based room description body text rule is listed instead of the room description body text rule in the carry out looking rules.

Our replacement rule this time around is a little bit trickier just because the rule that we're replacing is a complicated one: describing a room already checks to see whether there's light to see by, whether the player has turned off room descriptions when he enters a room for the second time, and whether the player character is (say) inside a closed box he can't see out of.

But all of those details are re-copied from the standard rules, and the important thing is that, at the end, we again carry out our activity.

This is the activity-based room description body text rule:
    if the visibility level count is 0:
        if set to abbreviated room descriptions, continue the action;
        if set to sometimes abbreviated room descriptions and
            abbreviated form allowed is true and
            darkness witnessed is true,
            continue the action;
        begin the printing the description of a dark room activity;
        if handling the printing the description of a dark room activity,
            issue miscellaneous library message number 17;
        end the printing the description of a dark room activity;
    otherwise if the visibility ceiling is the location:
        if set to abbreviated room descriptions, continue the action;
        if set to sometimes abbreviated room descriptions and abbreviated form
            allowed is true and the location is visited, continue the action;
        carry out the printing the room-description activity with the location.

Section 3 - Device Description

Showing action of something is an activity.

Rule for showing action of something (called item):
    if the item is switched on, say "[The item] is switched on.";
    otherwise say "[The item] is switched off."

The activity-based described devices rule is listed instead of the examine devices rule in the carry out examining rules.

This is the activity-based described devices rule:
    if the noun is a device:
        carry out the showing action activity with the noun;
        now examine text printed is true.

Report switching on something:
    say "You flip a switch. ";
    carry out the showing action activity with the noun instead.

Part 2 - Scenario

Include Plurality by Emily Short.

The Kitchen is a room. "A small kitchen tucked into a corner of the vacation house. There is storage space for five or six cups, a sink, a two-ring stove; nothing else to speak of."

The microwave is a device in the Kitchen.

South of the Kitchen is the Living Area. The description of the Living area is "A whitewashed living/dining/reclining area in what used to be a shepherd's stone hut, but now costs vacationers 600 euros a week. It offers no mod cons, only a straight view of the Mediterranean and a wobbly writing table."

Rule for printing the room-description of a room when the player wears the sunglasses:
    say "The walls look like they're covered with ants. Just a coincidence, I'm sure[antsy]."

Rule for printing the room-description of the Kitchen when the player wears the sunglasses:
    say "Are ants coming out of the sink? No, probably not[antsy]."

Rule for printing the description of something (called the item) when the player wears the sunglasses:
    say "[The item] [is-are] [one of]ant-colored[or]ant-legged[or]covered in ants[at random][antsy]."

Rule for showing action of the microwave:
    say "The microwave hums meaningfully to itself."

Rule for showing action of the microwave when the player wears the sunglasses:
    say "The microwave hums as though inhabited by a billion ants[antsy]."

The player carries sunglasses of freakiness and an apple. The apple is edible. The sunglasses are wearable.

ant-paranoia is a number that varies.

To say antsy:
    increase ant-paranoia by 1;

Every turn:
    if the ant-paranoia is greater than 3:
        say "Augh! AUUUGH! GET THEM OFF--";
        end the story saying "You have lost your mind."

Test me with "look / turn on microwave / turn off microwave / x apple / x sunglasses / s / wear sunglasses / look / x apple / n / turn on microwave".

344
* Example  Priority Lab
A debugging rule useful for checking the priorities of objects about to be listed.

WI
345
* Example  Low Light
An object that is only visible and manipulable when a bright light fixture is on.

WI
343
** Example  The Eye of the Idol
A systematic way to allow objects in certain places to be described in the room description body text rather than in paragraphs following the room description, and to control whether supporters list their contents or not.

WI
341
* Example  Rip Van Winkle
A simple way to allow objects in certain places to be described in the room description body text rather than in paragraphs following the room description.

WI
348
*** Example  Copper River
Manipulating room descriptions so that only interesting items are mentioned, while objects that are present but not currently useful to the player are ignored.

WI
3
** Example  Slightly Wrong
A room whose description changes slightly after our first visit there.

WI
152
* Example  Infiltration
A room whose description changes depending on the number of times the player has visited.

WI
147
* Example  Night Sky
A room which changes its description depending on whether an object has been examined.

WI


PreviousContentsNext