Chapter 6: Commands
6.6. Looking Under and Hiding

Finding hidden objects is a classic puzzle in IF. Beachfront provides the most basic example, an object that becomes visible only when we have searched the papers on a cluttered desk. Beneath the Surface takes this further, giving all large furnishings the ability to conceal items, and allowing the player to put things underneath other things, as well as find them. Flashlight adds an extra twist to the puzzle by requiring that the player have a flashlight to shine under a bulky object in order to find what lies underneath.

Looking inside an object is generally handled by the searching action, and we could extend that to allow the player to search multiple or complex objects. Matreshka turns the puzzle on its head by allowing the player to search a whole room systematically with only a single command.

* See Kitchen and Bathroom for the related case of needing to look in a mirror


98
* Example  Beachfront
An item that the player can't interact with until he has found it by searching the scenery.

WI
233
* Example  Beneath the Surface
An "underlying" relation which adds to the world model the idea of objects hidden under other objects.

WI
218
* Example  Flashlight
Visibility set so that looking under objects produces no result unless the player has a light source to shine there (regardless of the light level of the room).

WI

"Flashlight"

The Schoolhouse is a room. "Though normally comfortable, the room is dark and menacing during the storm; rain sheets on the windows, and you can barely see the flash of the lighthouse only a few miles away."

The cabinet is a fixed in place openable container in the Schoolhouse. The hurricane lantern is a thing in the Schoolhouse. "A hurricane lantern hangs from a peg." The lantern is lit.

Visibility rule when looking under something:
    if the player is carrying a lit thing (called lamp):
        say "You shine [the lamp] under [the noun]...";
        there is sufficient light;
    there is insufficient light.

There is a marble. The marble can be found or lost. The marble is lost.

Instead of looking under the cabinet when the marble is lost:
    move the marble to the player;
    now the marble is found;
    say "Billy's lost marble! So that's where it got to!"

Test me with "look under cabinet / get lantern / look under cabinet".

Because visibility is checked before instead rules, this discovery will (correctly) occur only when the player does have enough light.

173
* Example  Matreshka
A SEARCH [room] action that will open every container the player can see, stopping only when there don't remain any that are closed, unlocked, and openable.

WI


PreviousContentsNext