| Chapter 3: Things |

| 3.26. Directions

"Direction" is a kind which is quite unlike most of those seen so far. While it has to do with the physical world, a direction does not exactly belong to it. One cannot find "southeast" sitting on a shelf, for instance. And while we could imagine a world with many or few containers (for instance), the idea of world with many or few directions is a little surreal. "Direction" is not a kind of thing, or a kind of room: it is a kind in its own right.

The chapter began with the twelve directions built into Inform:

> north, northeast, east, southeast, south, southwest, west, northwest, up, down, inside, outside

While it is possible to create entirely new directions, this can be very tricky: if the effect we need is really just to give new names to directions (like "starboard" or "widdershins"), there are easier ways; if we wanted to write about a Flatland without up or down, we could use techniques from later chapters to prohibit going up or down. See the Recipe Book for examples.

Even though we do not need to create them, the kind "direction" is still useful to know about. For instance, we will later see ways of defining new commands, and we might want to allow "RUN EAST" - or in any other direction - so the kind "direction" is helpful to specify which ways the player can run. Another convenience is that a direction has an "opposite" property, which is always another direction. The opposite of north is south: the opposite of southeast is northwest: the opposite of inside is outside, and so on.

34
| Example Prisoner's Dilemma A button that causes a previously non-existent exit to come into being.

We can change the directions in the map in mid-game, though in practice this is rarely necessary. But suppose we do not want a door or any sign of a door to exist before the player takes some action, in this case pressing a button: "Prisoner's Dilemma" Challenger's Waiting Room is a room. "The challenge is this: to wait as long as you can endure to do so in a room with no features and no clock. If you wait longer than all the other contestants, you win." The button is fixed in place in the Challenger's Waiting Room. "The only item in view is a black recessed button." Amid the Cheering Throng is a room. Instead of pushing the button for the first time: change the east exit of the Challenger's Waiting Room to Amid the Cheering Throng; change the west exit of the Cheering Throng to the Challenger's Waiting Room; say "With a groan of gears, the east wall swings open! If you've lost now, well, you've lost..." Test me with "e / push button / e / w". Our instructions about pushing the button will be further explained in the chapter on Actions, but the thing to note here is that we can "change (whatever) exit" in order to set or re-set map directions. Notice that we have to set both directions explicitly: changing the east exit of the Waiting Room does not automatically also change the west exit of Amid the Cheering Throng. This allows greater flexibility in our games but does require an extra line or so of work.

Previous | Contents | Next