Chapter 4 - Moving Around
Moving Around
The next step is to expand the map to a few more locations (rooms) so we can start moving around. We'll begin by adding the other three locations that feature in the original Adventures of Heidi. We have already covered most of what we need to know in order to do this. Add the following code to the end of the existing program. An explanation of new features follows.
|
"Through the deep foliage you glimpse a building to the west.
A track leads to the northeast, and a path leads south. "
west = outsideCottage
northeast = clearing
;
clearing : OutdoorRoom 'Clearing'
"A tall sycamore tree stands in the middle of this clearing.
One path winds to the southwest, and another to the north. "
southwest = forest
up = topOfTree
north : FakeConnector {"You decide against going that way right
now. "}
;
+ tree : Fixture 'tall sycamore tree' 'tree'
"Standing proud in the middle of the clearing, the stout
tree looks like it should be easy to climb. "
;
topOfTree : OutdoorRoom 'At the top of the tree'
"You cling precariously to the trunk, next to a firm, narrow
branch. "
down = clearing
;
outsideCottage
to the west property of forest
. You may object that outsideCottage
is simply a room, the room we started by defining; but Rooms are in fact a special kind of TravelConnector, connectors that point to themselves as destination. Traveling via a
Room thus means traveling to that Room. So if we want movement to take place directly from one room to another, we simply set the appropriate direction property to the destination room. Note that unlike TADS 2, in TADS 3 the direction properties northwest
, northeast
, southwest
, and southeast
must be spelled out in full; the other direction properties you will commonly use are north
, south
, east
,
west
, up
, down
, in
and
out
.
You have probably noticed that the north property from the clearing uses a different kind of connector, a FakeConnector. A FakeConnector is what it sounds like, a connector that only appears to go somewhere. An attempt to travel via a FakeConnector results in its travelDesc message being displayed without any travel actually taking place. One use of a FakeConnector might be to create 'soft boundaries' to your map, to make it look as if it extends further than it really does. But in this case we're using a FakeConnector because the room description mentions a path to the north, which we shall eventually want to implement, but do not wish to implement yet.
The code using this connector would have looked more like that using rooms as connectors if we had defined the FakeConnector as a separate object thus:
|
travelDesc = "You decide against going that way right
now. "
;
The clearing would then be defined with
|
north = fakePath
|
|
If you compile and run the game as it is it will look as if nothing has changed from the previous chapter; the new rooms we have added won't appear. The reason for this (which you've probably guessed already) is that we haven't added a connector out of the original outsideCottage room (a bug waiting to happen when adding more rooms to an already complex map). This is easy enough to put right; just add the following to the definition of outsideCottage, between the room description and the terminating semicolon:
|
east = forest
|
|
Getting Started in TADS 3
[Main]
[Previous] [Next]