§17.7. Understanding any, understanding rooms

Ordinarily, if we write

Understand "manipulate [something]".

then the "[something]" will only match what is within reach or sight: this is the concept of "scope", which is what prevents a player from spookily acting on objects from a distance. The parser itself prevents the manipulation rules from ever being invoked on such distant items, which is as it should be.

Sometimes, though, we positively want to allow this possibility. If we use the special word "any", as in

Understand "manipulate [any door]".

then any door, anywhere in the model world, can be allowed in the player's command. (Of course, the manipulation rules may not do what the player hopes: all that has happened is that the command is now possible to type.) The "any" can be followed by any description of items or rooms, and the latter opens up new possibilities, since rooms are ordinarily never allowed to be named in the player's commands.

For example, the following gives the player the ability to walk between rooms without giving explicit directions of movement.

Going by name is an action applying to one thing.

Carry out going by name: say "You walk to [the noun]."; move the player to the noun.

Understand "go to [any adjacent visited room]" as going by name.

(This is really only a sketch: in a finished work, "go to" would produce helpful errors if non-adjacent but visited rooms were named, and we might also worry about rules applying to movement, because the method above will circumvent them.)

As might be expected, "[anything]" means the same as "[any thing]"; "[anybody]" and "[anyone]" mean the same as "[any person]"; and "[anywhere]" means the same as "[any room]".


arrow-up.pngStart of Chapter 17: Understanding
arrow-left.pngBack to §17.6. Actions applying to kinds of value
arrow-right.pngOnward to §17.8. Understanding names

Suppose that, contrary to the usual rules of interactive fiction, we want to allow the player to discover the locations of things he hasn't actually seen yet:

paste.png "One of Those Mornings"

Understand "find [any thing]" as finding.

Finding is an action applying to one visible thing.

Carry out finding:
    if the player is carrying the noun:
        say "You're holding [the noun]!";
    otherwise:
        say "You left [the noun] [if the noun is on a supporter]on[otherwise]in[end if] [the holder of the noun]."

The holder of the noun can be a room, a supporter, or a container: the phrase is not picky. We would want to be a little more careful if it were ever possible for an item to have been "removed from play" in our game, since then the holder could be nothing, and that would have odd results. In this particular example, though, that will not arise.

And that's it, as far as the find command goes. The rest is local color.

The Exhibition Room is a room. It contains a closed locked lockable transparent openable container called the display case. The display case contains a priceless pearl. The display case is scenery. The description of the Exhibition Room is "By far the finest thing in the room is a priceless pearl in a glass display case. It should of course be yours[if key is not visible], if only you can remember where you hid the key[end if]."

The silver key unlocks the display case.

A jade vase, a teak chest, a bronze teakettle, and a child's burial casket are openable closed containers in the Exhibition Room.

After taking the pearl:
    say "The pearl rolls into your hand, gleaming in the oblique light; your fortune is made.";
    end the story finally.

If we want to have the key found in different places when the game is replayed:

When play begins:
    let the space be a random container which is not the display case;
    move the silver key to the space.

Every turn:
    say "Your watch ticks with maddening loudness."

The time of day is 1:02 AM.

At 1:08 AM: say "The security guard arrives to find you fumbling about with keys. Curses."; end the story.

Test me with "find pearl / find teakettle / get teakettle / find teakettle / find key".

*ExampleOne of Those Mornings
A FIND command that allows the player to find a lost object anywhere

Suppose that, contrary to the usual rules of interactive fiction, we want to allow the player to discover the locations of things he hasn't actually seen yet:

paste.png "One of Those Mornings"

Understand "find [any thing]" as finding.

Finding is an action applying to one visible thing.

Carry out finding:
    if the player is carrying the noun:
        say "You're holding [the noun]!";
    otherwise:
        say "You left [the noun] [if the noun is on a supporter]on[otherwise]in[end if] [the holder of the noun]."

The holder of the noun can be a room, a supporter, or a container: the phrase is not picky. We would want to be a little more careful if it were ever possible for an item to have been "removed from play" in our game, since then the holder could be nothing, and that would have odd results. In this particular example, though, that will not arise.

And that's it, as far as the find command goes. The rest is local color.

The Exhibition Room is a room. It contains a closed locked lockable transparent openable container called the display case. The display case contains a priceless pearl. The display case is scenery. The description of the Exhibition Room is "By far the finest thing in the room is a priceless pearl in a glass display case. It should of course be yours[if key is not visible], if only you can remember where you hid the key[end if]."

The silver key unlocks the display case.

A jade vase, a teak chest, a bronze teakettle, and a child's burial casket are openable closed containers in the Exhibition Room.

After taking the pearl:
    say "The pearl rolls into your hand, gleaming in the oblique light; your fortune is made.";
    end the story finally.

If we want to have the key found in different places when the game is replayed:

When play begins:
    let the space be a random container which is not the display case;
    move the silver key to the space.

Every turn:
    say "Your watch ticks with maddening loudness."

The time of day is 1:02 AM.

At 1:08 AM: say "The security guard arrives to find you fumbling about with keys. Curses."; end the story.

Test me with "find pearl / find teakettle / get teakettle / find teakettle / find key".

Suppose that, contrary to the usual rules of interactive fiction, we want to allow the player to discover the locations of things he hasn't actually seen yet:

paste.png "One of Those Mornings"

Understand "find [any thing]" as finding.

Finding is an action applying to one visible thing.

Carry out finding:
    if the player is carrying the noun:
        say "You're holding [the noun]!";
    otherwise:
        say "You left [the noun] [if the noun is on a supporter]on[otherwise]in[end if] [the holder of the noun]."

The holder of the noun can be a room, a supporter, or a container: the phrase is not picky. We would want to be a little more careful if it were ever possible for an item to have been "removed from play" in our game, since then the holder could be nothing, and that would have odd results. In this particular example, though, that will not arise.

And that's it, as far as the find command goes. The rest is local color.

The Exhibition Room is a room. It contains a closed locked lockable transparent openable container called the display case. The display case contains a priceless pearl. The display case is scenery. The description of the Exhibition Room is "By far the finest thing in the room is a priceless pearl in a glass display case. It should of course be yours[if key is not visible], if only you can remember where you hid the key[end if]."

The silver key unlocks the display case.

A jade vase, a teak chest, a bronze teakettle, and a child's burial casket are openable closed containers in the Exhibition Room.

After taking the pearl:
    say "The pearl rolls into your hand, gleaming in the oblique light; your fortune is made.";
    end the story finally.

If we want to have the key found in different places when the game is replayed:

When play begins:
    let the space be a random container which is not the display case;
    move the silver key to the space.

Every turn:
    say "Your watch ticks with maddening loudness."

The time of day is 1:02 AM.

At 1:08 AM: say "The security guard arrives to find you fumbling about with keys. Curses."; end the story.

Test me with "find pearl / find teakettle / get teakettle / find teakettle / find key".

**ExampleActaeon
A FOLLOW command allowing the player to pursue a person who has just left the room.