Inform 7 Home Page / Documentation
§7.13. Going from, going to
Going is an action defined like any other: it is the one which happens when the player tries to go from one location to another. But it is unlike other actions because it happens in two locations, not just one, and has other complications such as vehicles and doors to contend with. To make it easier to write legible and flexible rules, "going" is allowed to be described in a number of special ways not open to other actions, as demonstrated by the following example story:
"Going Going"
The Catalogue Room is east of the Front Stacks. South of the Catalogue Room is the Musicology Section.
Instead of going nowhere from the Front Stacks, say "Bookcases obstruct almost all passages out of here."
Instead of going nowhere, say "You really can't wander around at random in the Library."
Before going to the Catalogue Room, say "You emerge back into the Catalogue Room."
Note that "going nowhere" means trying a map connection which is blank, and if no rules intervene then "You can't go that way" is normally printed. Unless "nowhere" is specified, descriptions of going apply only when there is a map connection. So "going from the Musicology Section" would not match if the player were trying to go east from there, since there is no map connection to the east. Similarly, "going somewhere" excludes blank connections.
The places gone "from" or "to" can be specific named regions instead of rooms. This is convenient when there are several different ways into or out of an area of map but a common rule needs to apply to all: so, for example,
Before going from the Cultivated Land to the Wilderness, ...
Before going nowhere from the Wilderness, say "Tangled brush forces you back."
Note that it must be "going nowhere from the Wilderness", not "...in the Wilderness". (Note also the caveat that the regions must be named: "going from a region", or something similarly nonspecific, will not work.)
An important point about "going... from" is that, as mentioned in general terms above, it requires that there is actually a map connection that way: whereas "going... in" does not. Suppose there is no map connection north from the Wilderness. Then:
Instead of going north from the Wilderness, say "You'll never read this."
Instead of going north in the Wilderness, say "Oh, it's too cold."
The first of these never happens, because it is logically impossible to go north from the Wilderness: but the second does happen. (Technically, this is because "going north" is the action, and "in the Wilderness" a separate condition tacked onto the rule.) This distinction is often useful - it allows us to write rules which apply only to feasible movements.
This may be a good place to mention a small restriction on the ways we can specify an action for a rule to apply to, and how it can be overcome. The restriction is that the action should only involve constant quantities, so that the following does not work:
The Dome is a room. The Hutch is north of the Dome. The rabbit is in the Hutch. Before going to the location of the rabbit, say "You pick up a scent!"
because "the location of the rabbit" is a quantity which changes in play (the player can pick up the rabbit and take him to the Dome, for instance). However, we can get around this restriction by defining a suitable adjective, like so:
The Dome is a room. The Hutch is north of the Dome. The rabbit is in the Hutch. Definition: a room is rabbit-infested if it is the location of the rabbit. Before going to a rabbit-infested room, say "You pick up a scent!"
|
ExampleVeronica
An effect that occurs only when the player leaves a region entirely.
|
|
Suppose that we want to have something happen when the player leaves a region we've defined. "Instead of going from (the region)..." will not suffice for this, because this rule will be invoked every time the player successfully leaves a room within the region, whether or not he is going to a room that is also in the same region.
Instead we need a rule that is a bit more specific, like this:
"Veronica"
Neptune is a region.
Tijuana is a room.
High School is north of Tijuana. It is in Neptune.
Detective Offices is west of High School. It is in Neptune.
The player is in High School.
Instead of going from Neptune to a room which is not in Neptune:
say "It's a bad time to leave Neptune."
Test me with "s / w / e".
|
ExampleA&E
Using regions to block access to an entire area when the player does not carry a pass, regardless of which entrance he uses.
|
|
Rules about going to regions make it easy to exclude the player from a large portion of the map, even if there are many connecting paths to the region. For instance, in this story it would be annoying to have to write a rule about all four exits by which the player could reach the film set area:
"A&E"
Winding Street is a room. Winding Street is west of Duck Pond. Sloping Street is north of Winding Street, northwest of Duck Pond, west of Stately Lawn, and southwest of Stately Home. Stately Lawn is north of Duck Pond. Stately Home is north of Stately Lawn.
Film Set is a region. Duck Pond, Stately Lawn, and Stately Home are in Film Set.
Instead of going to Film Set when the player does not carry the VIP Pass: say "A burly studio guard materializes in your path, convincing you that you would prefer to be elsewhere."
The VIP Pass is in the garbage can. The garbage can is in Sloping Street.
After going to the Film Set:
say "Success! At last you are inside the set of 'Prouder and More Prejudiced'. Next step: locating Mr Firth.";
end the story finally.
Test me with "e / n / e / get pass / e".
"Bumping into Walls"
First we add an instruction to determine which ways lead to other rooms.
Definition: a direction (called thataway) is viable if the room thataway from the location is a room.
Now we build in the instruction for what Inform should say if the player tries to head in a direction that leads nowhere:
Instead of going nowhere:
let count of exits be the number of viable directions;
if the count of exits is 0, say "You appear to be trapped in here." instead;
if the count of exits is 1, say "From here, the only way out is [list of viable directions].";
otherwise say "From here, the viable exits are [list of viable directions]."
There is no theoretical reason why we have to define "count of exits" here: we could, if we wanted, just say "if the number of viable directions is 0", "if the number of viable directions is 1", and so on. However, each calculation of a "viable direction" takes a bit of computing power, so there is some slight savings in not requiring the game to count viable directions more than once in this routine.
Dome is a room. North of Dome is North Chapel. South of the Dome is South Chapel. West of the Dome is Western End. Quiet Corner is northwest of the Dome, north of Western End, and west of North Chapel. Loud Corner is east of North Chapel, northeast of Dome, and north of Eastern End. Eastern End is north of Dim Corner and east of Dome. Dim Corner is southeast of Dome and east of South Chapel. Ruined Corner is southwest of Dome, west of South Chapel, and south of Western End.
The Crypt is below the dome.
The church door is east of Eastern End and west of the Courtyard. The church door is a door.
Test me with "u / n / n / e / n / s / u / open door / e / n".
The main trick of this is always to record where the player has gone when he has just moved.
"Polarity"
The former location is a room that varies.
Here we record where the player has been before moving him; by calling this the "first carry out going rule", we make sure that this rule is followed during the going action before any other pieces of the movement occur. For more detail, see the chapters on advanced actions and on rules.
First carry out going rule:
now the former location is the location.
Understand "go back" as retreating. Understand "back" or "return" or "retreat" as retreating.
Retreating is an action applying to nothing.
Carry out retreating:
let way be the best route from the location to the former location, using doors;
if way is a direction, try going way;
otherwise say "You can't see an open way back."
And to deal with the case where the player has not yet moved:
When play begins: now the former location is the Dome.
Instead of retreating when the former location is the location: say "You haven't gone anywhere yet."
Dome is a room. North of Dome is North Chapel. South of the Dome is South Chapel. West of the Dome is Western End. Quiet Corner is northwest of the Dome, north of Western End, and west of North Chapel. Loud Corner is east of North Chapel, northeast of Dome, and north of Eastern End. Eastern End is north of Dim Corner and east of Dome. Dim Corner is southeast of Dome and east of South Chapel. Ruined Corner is southwest of Dome, west of South Chapel, and south of Western End.
The church door is east of Eastern End and west of the Courtyard. The church door is a door.
Test me with "back / n / go back / e / open door / go through door / go back".