Child's Play

An interactive fiction by Stephen Granade (2007) - the Inform 7 source text

Chapter 8 - Scoping, Which is Fiddled Because in This Game Regions Are Really Rooms

After deciding the scope of the player when the location is regionally in Play Area:
    repeat with P running through the rooms in Play Area begin;
        place P in scope;
    end repeat.

After deciding the scope of the player when the location is regionally in Hidden Area:
    repeat with P running through the rooms in Hidden Area begin;
        place P in scope;
    end repeat.

A thing can be room-mentioning. A thing is usually room-mentioning.

To say the placement of (item - a thing):
    if the item and the player are not co-located begin;
        let place be the location of the item;
        let way be the best route from the location to the place;
        say "[is-are of item]";
        if item is inside a container (called c), say " inside [the c]";
        say "[if item is room-mentioning] [faraway descriptor of place][end if][if way is a direction] to the [way][note fiddled-scope]";
    end if.

After printing the description of something which is within a room which is not the location (this is the description of distant item location rule): say "[Cap it-they of the noun] [the placement of the noun]. [run paragraph on]".

Before doing something other than examining or following or building to something which is not enclosed by the location (this is the babies have stubby little arms rule):
    if the noun is a backdrop begin;
        if the noun is not in the location, instead say "[The noun] [is-are] way too far away for that[note fiddled-scope].";
    otherwise;
        instead say "[The noun] [the placement of the noun] and so [is-are of the noun] way too far away for that.";
    end if.

Does the player mean doing something other than examining or following something which is not enclosed by the location: it is very unlikely.

[I don't like how, because everything is effectively always in scope, you get clarification messages on doing things like pulling up on a loveseat. This next bit of wizardry prevents that from happening. TK This will need to be checked against every update of I7 ever, sigh.]
Include (-
[ CountPresentMatchedObjects i cnt;

    cnt = 0;
    for (i=0; i<number_matched; i++) {
        ! This next test corresponds to "obj is in the location" in I7
        if (real_location == I7_InWhat(match_list-->i)) {
            cnt++;
            if (cnt > 1) { rtrue; }
        }
    }
    rfalse;
];
-).
To decide if only one matched object is present: (- (CountPresentMatchedObjects) -)

Rule for clarifying the parser's choice when only one matched object is present:
    do nothing.

The source code to Child's Play is licensed under a Creative Commons NonCommercial Sampling Plus 1.0 License.