StairwayDown : Stairway
[Previous] [Main] [Next]

The description of entranceCave refers to a sturdy steel ladder leading down through a hole in the floor. This ladder is best implemented as a stairwayDown, which is both a physical game object that can be examined and a TravelConnector that can be traversed, by CLIMB and CLIMB DOWN commands. The ladder can simply be defined as:

+ downLadder : StairwayDown 'sturdy steel ladder' 'sturdy steel ladder'
  "The ladder leads down through a large hole in the floor. "
;

Here we are simply using the standard Thing template, although since StairwayDown inherits (indirectly) from Passage, it can also use the Passage template.

We can then add a down property to the room definition to point to this connector:

entranceCave : Room 'Entrance Cave' 'the entrance cave'
  "This is the main cave. A large rock rests against the north wall and
   there are other caves to south and east, but the way west is blocked by
   a huge boulder. A blazing torch is fixed to the wall, next to a sturdy 
   steel ladder leading upwards. "
   north = entranceTunnel   
   out asExit(north)
   down = downLadder
;

Note that as yet nothing defines where we end up when we go down the ladder. This is because there will be a corresponding StairwayUp in the cave below, and the StairwayUp will point to downLadder as its masterObject. The game will automatically link the StairwayUp to its masterObject and vice versa, so that when we traverse the StairwayDown it will know that its destination is in the corresponding StairwayUp's location. (We could equally well do this the other way round and make the StairwayUp the masterObject of the StairwayDown).