A Handy Kit

An interactive fiction by Andrew Plotkin (2006) - the Inform 7 source text

Home page

Contents
Previous
Next

Complete text
Chapter 3 - Your Kit

A tool is a kind of thing.

The toolcase is an openable container. Understand "grey" or "gray" or "toolkit" or "case" or "tool case" as the toolcase.
Understand "closed" as the toolcase when the toolcase is closed.
Understand "open" as the toolcase when the toolcase is open.

The description of the toolcase is "Your toolcase is a flat grey plastic form[if closed], which is closed.[otherwise], lined with shaped sponge foam. [contents of the toolcase]."

[A phrase which shows what's in the case. Note that it does not end with a period/paragraph break. I wanted this to be usable as a string substitution inside a sentence.]
To say contents of the toolcase:
    If the toolcase is closed begin;
        say "The toolcase is closed";
        stop;
    end if;
    If the toolcase does not contain something, say "The toolcase is empty";
    otherwise say "In the toolcase [is/are list of things in the toolcase]"

[Same as above, but shorter, for use in an inventory listing]
To say brief contents of the toolcase:
    If the toolcase is closed begin;
        say "a closed toolcase";
        stop;
    end if;
    If the toolcase does not contain something, say "an empty toolcase";
    otherwise say "a toolcase (in which [is/are list of things in the toolcase])"

Instead of searching the toolcase, say "[contents of the toolcase]."
The inventory listing of the toolcase is "[brief contents of the toolcase]".

Instead of opening the toolcase when the toolcase is open:
    Say "The toolcase is already open."
Report opening the toolcase when the toolcase does not contain something:
    Instead say "You open the toolcase, and find it empty."
Report opening the toolcase:
    say "You open the toolcase. Inside [is/are list of things in the toolcase].";
    if the toolcase encloses something perfumey begin;
        say "[conditional paragraph break]";
        [This has to be broken up into two say phrases, due to a quirk of the paragraph machinery.]
        say "A wave of nasty perfume drifts out of the case.";
    end if;
    stop the action.

A check inserting it into rule:
    If the second noun is the toolcase and the noun is not a tool,
        instead say "[The noun] won't fit in the case.";
[I originally wrote the above this way:
    Instead of inserting something into the toolcase when the toolcase is open and the noun is not a tool:
        say "[The noun] won't fit in the case.";
It's a toss-up which is nicer. The check rule doesn't have to have the "toolcase is open" exception, because the compiler inserts it after the "can't insert into closed containers" rule. On the other hand, you have to mess with "second noun".]

[We have some foam padding, which is purely decorative.]
The foam padding is part of the toolcase. Understand "shaped" or "sponge" as the foam padding. The description is "The toolcase is lined with foam padding, neatly shaped into hollows for the various tools that the case holds."
Instead of taking the foam padding, say "The foam padding is part of the case."
Instead of searching the foam padding, say "[contents of the toolcase]."
Instead of inserting something into the foam padding, try inserting the noun into the toolcase.

Rule for deciding the concealed possessions of the toolcase: if the toolcase is open then no; otherwise yes.
[This conceals the foam padding when the case is closed. The tools aren't affected, because they wouldn't be visible anyway.]