Movement

Move

A move command must be of the format:


   move object to destination

The object can be any object label, object pointer or the integer index of an object, while the destination can be any item label, item pointer or the integer index of an item. In essence, the move command will set the parent element of the object to be equal to the destination. In addition to this, it performs several functions relating to the mass of the object that is being moved. For example, the command:


   move note to box

will, in addition to moving the note to be a child of the box, automatically increase the capacity property of the object (if any) that the note was in before the move command, and decrease the capacity property of the box. This reflects the decreased burden on notes previous parent and an increase in the box's contents in accordance with the note's mass property. The following code is equivalent to the above move command:


   set noun4 = note(parent)
   set note(parent) = box
   set noun4(capacity) + note(mass)
   set box(capacity) - note(mass)

As you can see, the move command is by far the easier option.

If the capacity property of the destination object ends up a negative number, the move command will still successfully complete. It is therefore wise to test for this before issuing a move command. Below is an example of this from the library function +insert_in:
   if noun2(capacity) < noun1(mass)
      write "<p>There is not enough room in " noun2{the} 
      write " for " noun1{the} .^
      set TIME = false
      break
   endif

Travel

A travel command must be of the format:


   travel direction

The travel command is used to move the player from one location to another. It simulates the player moving in the specified direction under their own steam. The player can also be moved to a different location by directly setting their parent to equal the new location. This, however, does not in perform any tests as to whether this movement is physically possible. The travel command is normally only ever used by the direction verbs in the library. One of the directions north, south, east, west, up, down, in, out, northeast, northwest, southeast or southwest must be specified as its single parameter.

Before the move actually occurs, two functions are executed. If either of these functions exists, and does not issue a break false command, the move will not occur. The first of these functions is the movement function associated with the location the player is attempting to move out of. The second, executed if this first function does not exist of issues a break false command, is the global function +movement. The variable COMPASS and the location pointer destination are set to the appropriate values before either of these functions is called.

Two common uses of the movement function associated with a particular location are to replace the standard, "You can't go that way," message or to add some text describing the journey from one location to another. For example:

   location hut : hut
      short       the "hut"
      north       clearing

   {movement
   if COMPASS != NORTH
      write "<p>The only exit from here is the front door "
      write "to the north.^"
      break
   endif
   write "<p>You step out into the sun light, taking a"
   write "moment for your eyes to adjust.^"
   break false
   }

Firstly, this function checks if the player is attempting to go in a direction other than their current location's only exit. If this is the case, an appropriate message is displayed and a break command is executed. It is this break command that prevents the move from taking place. If the player is attempting to travel in a valid direction, a short description of the journey is displayed and a break false is executed. It is this break false command that tells the interpreter that the move should take place.