Skip to content

Enterable

Jim Nelson edited this page Sep 13, 2021 · 2 revisions

Make an entrance: Allow players to GO IN a building or room

Problem

If one room allows entering or going into another room, it's helpful if the player can GO IN the room rather than use directional commands.

Usually allowing the player to go inside another room is dealt with by using the in property:

kitchen: Room
  desc = "A walk-in pantry is here.  "
  in = pantry
;

pantry: Room 'Walk-in Pantry' 'a pantry'
  out = kitchen
;

But results in this situation:

Kitchen
A walk-in pantry is here.

>enter
Walk-in Pantry

>leave
Kitchen
A walk-in pantry is here.

>go in pantry
The word "pantry" is not necessary in this story.

The problem is that the pantry object is not located in or at the kitchen object, so it's inaccessible to the player.

One solution would be to use NestedRoom or Booth. Both classes are useful, and could even be used here. In other situations they don't make sense. For example, entering a house from a room outdoors.

Solution

Enterable can be used to create a reachable object in one room that leads to another room:

kitchen: Room
  desc = "A walk-in pantry is here.  "
  in = pantry
;

+ Enterable 'a pantry'
  connector = pantry
;

pantry: Room 'Walk-in Pantry' 'a pantry'
  out = kitchen
;

Note that the in and out properties are still used. This permits the player to simply type ENTER or IN to move to the pantry. The presence of the Enterable allows them to also type GO IN PANTRY.

Source

Clone this wiki locally