Pointers

Wherever an object or a location label can be used, so too can a number of special purpose pointers. When a command referring to a pointer is processed, the pointer will be substituted with the label of the item that it currently points to. This avoids the repetition of code and the assoicated problems of code-bloat and inconsistency. Below is a function demonstrating the use of pointers:

{+where_is
write "<ul>"
loop noun3
   if noun3 hasnt LOCATION
      noun4 = noun3(parent)
      write "<li> "noun3{The} 
      write " is in " noun4{the} ^
   endif
endloop
write "<ul>"
}

The above function loops through all the objects defined in the game and displays their current whereabouts. The loop command sets the pointer noun3 to each of the objects in turn, while the general purpose pointer noun4 is manually set to each object's parent. The two tables below detail each of the available object and location pointers:

Object Pointers

Pointer Description
player This pointer is set to the object that currently represents the player in the game.
noun1 This pointer is set to the first object referred to in the player's last move.
noun2 This pointer is set to the second object referred to in the player's last move.
noun3 This pointer is set to the first object in the game whenever a loop command is encountered. It will then be incremented to point to the next object each time an endloop command is encountered.
noun4 This pointer is set to the value of the first parameter passed to a function.
self or this This pointer is set to the object that the currently executing function is associated with.

Location Pointers

Pointer Description
here This pointer represents the location that the player is currently in. It is synonymous to the element player(parent).
destination This represents the location that the player is attempting to move into. The value of destination can be tested in the +movement function before the move is completed. Once the move is complete, destination will equal here until the next move is attempted. This is a read-only pointer and therefore cannot be used as the container parameter of a set command.
self or this This pointer is set to the location that the currently executing function is associated with.
Be sure your code never makes use of a pointer in place of an object or location while it does not point to a valid object or location. A pointer is not pointing to a valid object or location if it is set to a number less than one or greater than the number of objects and locations in the game.