The Beast of Torrack Moor

An interactive fiction by Linda Wright (2007) - the Inform 7 source text

Home page

Contents
Previous
Next

Complete text
Chapter 6 - Locksmith by Emily Short (modified)

[ Adapted version of Locksmith by Emily Short. The behaviour has been modified so that opening/unlocking a door causes the player to move through it automatically. ]

Door navigation is a thing. Door navigation is either neutral, first going, first opening or first unlocking. Door navigation is neutral.

Before going through a closed public door (called the blocking door) (this is the opening doors before entering rule):
    if the door navigation is neutral,
        change door navigation to first going;
    try opening the blocking door;
    if the door navigation is first going,
        change door navigation to neutral;
    stop the action.

Before opening a closed public door (called the blocking door) (this is the unlocking before opening rule):
    let the locking outcome be 0;
    if the door navigation is neutral,
        change the door navigation to first opening;
    if the blocking door is locked begin;
        silently try unlocking keylessly the blocking door.
        change locking outcome to 1;
    end if;
    if the blocking door is locked, stop the action;
    now the blocking door is open;
    say "[if the locking outcome is 1]Unlocking the door with the correct key, you push it[otherwise]You push the door[end if] open and go in.";
    try going the blocking door;
    if the door navigation is first opening,
        change door navigation to neutral;
    stop the action.

Instead of unlocking a locked closed public door (called the blocking door) with something when the door navigation is neutral:
    change the door navigation to first unlocking;
    try opening the blocking door;
    change the door navigation to neutral.