Escapade!

An interactive fiction by Juhana Leinonen (2008) - the Inform 7 source text

Home page

Contents
Previous
Next

Complete text
Chapter II - Moving inside the cell

Internal position is a kind of value. The internal positions are unspecified, the middle, by the window and by the door. Everything has an internal position. The internal position of a thing is usually unspecified.

A room has an internal position.
A direction has an internal position. [these are necessary only because without them the game throws run-time errors with commands that have non-things as nouns.]

The internal position of the player is by the door.

After dropping:
    now the internal position of the noun is the internal position of the player;
    continue the action.
    
After taking:
    now the internal position of the noun is unspecified;
    continue the action.
    

Definition: a thing is across the room if the internal position of the player is not the internal position of it and it is at the extremes and the player is at the extremes.

Definition: a thing is at the extremes if the internal position of it is by the window or the internal position of it is by the door.

Ktonked is a truth state that varies. Ktonked is false. [so that we ktonk only once per turn]

The ktonk count is a number that varies. The ktonk count is 0.

This is the ktonk rule:
    if a random chance of 1 in 3 succeeds:
        continue the action;
    if the light bulb is not part of the electrical wire or the electrical wire is pulled out:
        continue the action;
    let obj be nothing;
    if the noun is not nothing and the noun is across the room:
        let obj be the noun;
    if the second noun is not nothing and the second noun is across the room:
        let obj be the second noun;
    if obj is not nothing and the current action is not unktonking and ktonked is false and not multiple taking and the cell is not dark:
        say "[one of]You move across the room toward [the obj]. The lamp hanging from the ceiling is just on the right height to bonk you on the forehead on your way. (ktonk!)[or]You move across the room to get closer to [the obj]. The lamp hits you on the forehead again. (ktonk)[line break][or]You remember the low-hanging lamp mere milliseconds before it hits you on the forehead. (ktonk)[line break][or](ktonk)[line break][or](ktonk)[line break][or]You move across the room, now remembering that devilish lamp and going around it! Take that, lamp![or](ktonk)[line break][or](ktonk)[line break][or](ktonk)[line break][or](ktonk) ...damn lamp...[or](ktonk)[line break][or](ktonk)[line break][or](ktonk)[line break][paragraph break]You make a solemn oath that if the lamp hits you even once more, you'll rip it right off, mercilessly.[or](ktonk)[line break][stopping]";
        increase the ktonk count by 1;
        if the noun is not nothing and ( the noun is at the extremes or the internal position of noun is the middle ):
            now the internal position of the player is the internal position of the noun;
        if the second noun is not nothing and ( the second noun is at the extremes or the internal position of the second noun is the middle ):
            now the internal position of the player is the internal position of the second noun;
        change ktonked to true;
    continue the action.

Every turn:
    change ktonked to false.

The ktonk rule is listed first in the before rulebook.