Manual:DIL Manual/outside

From DikuMUD Wiki
Jump to navigation Jump to search

outside

Field (unitptr, read-only; units: all).

u.outside : unitptr

The unit that u is in: the room a character stands in, the character carrying or wearing an object, the container an object lies in. Null for a room that isn't inside another unit.

Notes

  • It can't be assigned (vmc: "Illegal lvalue"). Move a unit with link(), or move a character through an exit with exec("north", u).
  • After exec("<dir>", self), compare self.outside with the room before to see whether the move worked.
  • An object that is worn is still inside its wearer: outside is the character, and equip tells where it is worn.
  • The units inside u are found with inside and next.
  • On null it fails.

Example

dilbegin unitptr room_of(u : unitptr);
var
   r : unitptr;
code
{
   r := u;
   while (r)
   {
      if (r.type == UNIT_ST_ROOM)
         return (r);
      r := r.outside;
   }
   return (r);
}
dilend

Finds the room a unit is in, however deep it is packed (a coin in a purse in a sack carried by a player).

See also