HighNestedRoom : NestedRoom
[Previous] [Main] [Next]

A HighNestedPlatform is a NestedRoom that represents a part of the room that's too high to get into, unless we provide some means of reaching it. An example might be the upper of two bunk beds. The obvious place to put pair of bunk beds might be in the crew quarters of our ship. In order to reach the top bunk the player must be standing on the chair we conveniently left in the main cabin aft; to achieve this we modify the stagingLocations() property of the HighNestedRoom to return the chair, but only when the actor's standing on it:

Bed, Fixture 'bottom bunk bed*bunks*beds' 'bottom bunk' @crewQuarters
   "The bottom bunk is mounted low on the port side, under the top bunk. "
;

HighNestedRoom, Bed, Fixture 'top bunk bed*beds*bunks' 'top bunk' @crewQuarters
   "The top bunk is mounted high on the port side, above the bottom bunk. "
   stagingLocations()
   {
     local lst = new Vector(5);
     if(gActor.posture==standing)
       lst.append(cabinChair);
     return lst.toList;
   }
;

+ Thing 'pillow' 'pillow'
  "It's just a plain white pillow. "
;   

At the same time we need to change the description of the crewQuarters room to reflect the addition of some new furniture:

crewQuarters : DarkCabin 'Crew Quarters' 'the crew quarters'
  "The crew quarters seem largely deserted, apart from a single locker
   fixed to the bulkhead, and a pair of bunk beds nestling against against
   the port side.
 There's an exit back aft and a ladder leading down into 
   the hold. Another exit leads foreward. "
  ...
;

If you compile and run this, you'll find that you can only get onto the top bunk if you're standing on the chair, but that there's a couple of things that are less than ideal. First, if you try to get on the bunk and the chair isn't present, the game tells you that you need to be sitting on the chair first, which is both incorrect (you actually need to be standing on it) and too revealing. Even worse, if the chair is present the game sits you on the chair and then tells you that the bunk is too high. The best solution is probably to modify stagingLocations so that it only returns the chair if the actor is actually standing on it. At the same time we'll take advantage of the revision to make it easier to add further things the player could stand on to reach the top bunk:

HighNestedRoom, Bed, Fixture 'top bunk bed*beds*bunks' 'top bunk' @crewQuarters
   "The top bunk is mounted high on the port side, above the bottom bunk. "
   stagingLocations()
   {
     local lst = new Vector(5);
     foreach(local cur in stagingPlatforms)
       if(gActor.posture==standing && gActor.isIn(cur))
         lst.append(cur);
     return lst.toList;
   }
   stagingPlatforms = [cabinChair]
;

One other thing you may have noticed is that although we can only get onto the top bunk with the aid of the chair, there is nothing to stop us taking the pillow while we're standing on the floor. There's nothing unrealistic about this; indeed it could well be that we could quite easily reach up and take the pillow without being able to get ourselves onto the top bunk, it just doesn't happen to be the behaviour we want here. To prevent the pillow being reached except from the top bunk we need to go a stage further and make the latter an OutOfReach.