A Handy Kit

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

Home page

Contents
Previous
Next

Complete text
Section - Connectable Modules

The bang tab is a purple module in the toolcase. Understand "small" or "cube" as the tab. The description is "It's a small [color] cube, which contains enough stabilized gel to make a satisfactory BANG noise. There's a minus link on one edge[tool status bang tab]."

Rule for activating-tmp the bang tab:
    if the bang tab is visible begin;
        say "[effective][The bang tab] explodes with a satisfactory BANG[if the toolcase contains the bang tab], rattling the toolcase[end if]";
    otherwise;
        if the toolcase contains the bang tab and the toolcase is closed and the toolcase is visible,
            say "[effective]BANG! [The toolcase] flies open as the tab explodes";
        otherwise
            say "[effective]You hear a loud bang nearby";
    end if;
    if the player encloses the bang tab, say ". You rub your numbed fingers";
    say ".";
    if the toolcase contains the bang tab, now the toolcase is open;
    remove the bang tab from play

The stink pack is a brown module in the toolcase. Understand "small" or "cone" as the stink pack. The description is "It's a small brown cone, covered with tiny pores. It [if stink pack is not expended]contains[otherwise]previously contained[end if] a pressurized capsule of nasty perfume. There's a minus link on one edge[tool status stink pack]."
The stink pack can be expended. The stink pack is not expended.

Rule for activating-tmp the stink pack:
    if the stink pack is expended, stop;
    now the stink pack is expended;
    if the stink pack is visible begin;
        say "[effective][The stink pack] hisses loudly, spraying perfume[if the toolcase contains the stink pack] out of the toolcase[otherwise] everywhere[end if].";
    otherwise;
        if the toolcase contains the stink pack and the toolcase is closed and the toolcase is visible,
            say "[effective]You hear a loud hiss from inside [the toolcase].";
    end if;
    [We want to perfumize everything in scope to the stink pack. The "can touch" relation handles this nicely, except that if the item is in the closed toolcase, it doesn't work right. (I think this is because the scope rules fail to understand the idea of being in a container -- they're written to deal with the scope of *people*, and people enter vehicles, not containers.) So we special-case the toolcase (har har), but otherwise use the natural I7 idiom.]
    if the toolcase contains the stink pack and the toolcase is closed begin;
        [I first wrote this as:
        repeat with item running through things enclosed by the toolcase begin;
            if the item is perfumizable, now the item is perfumey;
        end repeat;
        ...but that was making extra work for myself, wasn't it?]
        now each perfumizable thing which is enclosed by the toolcase is perfumey;
    otherwise;
        now each perfumizable thing which can be touched by the stink pack is perfumey;
    end if.

Rule for deactivating-tmp the stink pack:
    stop.

The minilamp is a yellow module in the toolcase. Understand "small" or "mini" or "lamp" or "torch" or "light" or "tube" or "lens" as the minilamp. The description is "It's a small yellow tube with a lens at one end[if minilamp is lit]; a beam of light shines out[end if]. There's a minus link on one edge of the tube[tool status minilamp]."
[Handy trick here. We want to modify the object's name in inventory listings and room descriptions (including sublists inside containers), but not during action commands. Solution: "while listing contents of some object". Note that "...of something" is not sufficient, because rooms are not "things"!]
Before printing the name of the minilamp while listing contents of some object:
    if the minilamp is lit, say "lit ".

Rule for activating-tmp the minilamp:
    if not momentarily-tmp, now the minilamp is lit;
    if the minilamp is not visible, stop;
    if momentarily-tmp, say "[effective][The minilamp] glows for a moment, then goes out.";
    otherwise say "[effective][The minilamp] begins glowing."
Rule for deactivating-tmp the minilamp:
    now the minilamp is unlit;
    if the minilamp is not visible, stop;
    say "[effective][The minilamp] goes dark."

The sonic relaxer is an orange module in the toolcase. Understand "small" or "pyramid" as the relaxer. The description is "It's a small orange pyramid, traced with conductor matrix. [if relaxer is inactive]It is silent at the moment[otherwise]It is emitting relaxing frog-sounds[end if]. There's a minus link on one edge[tool status relaxer]."
The relaxer can be either inactive or active. The relaxer is inactive.

Instead of listening to the relaxer when the relaxer is active:
    say "Frog noises are coming from [the relaxer]."

Instead of listening to the toolcase when the relaxer is active and the toolcase contains the relaxer:
    say "Frog noises are coming from [the toolcase]."

Rule for activating-tmp the relaxer:
    if not momentarily-tmp, now the relaxer is active;
    let the producer be the relaxer;
    if the relaxer is in the toolcase and the toolcase is closed and the toolcase is visible,
        let the producer be the toolcase;
    if the producer is not visible, stop;
    if momentarily-tmp, say "[effective][The producer] emits a single croak.";
    otherwise say "[effective][The producer] begins playing a series of gentle frog croaks."
Rule for deactivating-tmp the relaxer:
    now the relaxer is inactive;
    if the location of the player encloses the relaxer,
        say "[effective]The chorus of frog-noises ceases."

After looking when the location of the player encloses the active relaxer:
    say "Gentle frog sounds fill the room."