Bronze — 39 of 46

Emily Short

Release 13

Section 7 - Go Back (the way we came)

The former direction is a direction that varies. The last location is a room that varies.

Carry out going a direction:

now the last location is the location;

now the former direction is the noun.

Understand "go back" as retreating. Understand "back" or "return" or "retreat" as retreating.

Retreating is an action applying to nothing.

Carry out retreating:

let new direction be the opposite of the former direction;

say "(heading [new direction])[line break]";

try going the new direction.

Understand "leave [any room]" or "go outside [any room]" as departing. Departing is an action applying to one thing.

Check departing: if the noun is not the location, say "You aren't in [the noun]." instead.

Carry out departing:

let chosen way be the logical exit;

if chosen way is a direction

begin;

say "(heading [chosen way], since that is the only direction available)[line break]";

try going chosen way;

otherwise;

say "You will have to be more specific about which direction you want to go[if novice mode is functioning]. [exit description][end if].";

end if.

Understand "exits" or "dirs" or "directions" or "dir" or "find exits" or "find exit" as asking for directions. Asking for directions is an action out of world. Carry out asking for directions: say exit description.

To decide what direction is the logical exit:

let counter be 0;

let chosen way be north;

repeat with way running through directions

begin;

let place be the room way from the location;

if place is a room

begin;

increase counter by 1;

let chosen way be the way;

end if;

end repeat;

if counter is 1, decide on the chosen way.