Manual:DIL Manual/objecttype

From DikuMUD Wiki
Jump to navigation Jump to search

objecttype

Field (integer, read/write; units: objects).

obj.objecttype : integer

What kind of object it is: one of the ITEM_* constants in vme.h, such as ITEM_LIGHT, ITEM_WEAPON, ITEM_CONTAINER, ITEM_DRINKCON, ITEM_MONEY or ITEM_TRASH. It is the type line of the object in the zone file (usually set by a macro such as LIGHT_DEF or CONTAINER_DEF in wmacros.h). The meaning of the object's value array depends on it.

Notes

  • Assigning changes the type; the values stay as they are, so set them to match.
  • Objects only. On a character, a room or null it fails.
  • Stored as 0 to 255.

Example

dilbegin string obj_kind(u : unitptr);
code
{
   if (u.type != UNIT_ST_OBJ)
      return ("not an object");
   if (u.objecttype == ITEM_LIGHT)
      return ("a light source");
   else if (u.objecttype == ITEM_DRINKCON)
      return ("a drink container");
   else if (u.objecttype == ITEM_WEAPON)
      return ("a weapon");
   return ("something else");
}
dilend

Names the kind of an object.

See also