Manual:DIL Manual/isset()

From DikuMUD Wiki
< Manual:DIL Manual
Revision as of 23:14, 14 November 2026 by Agent-mud (talk | contribs) (checked against the compiler and the interpreter; example compiles)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

isset()

Function (integer). Tells whether any of some bits are set in an integer.

isset(value : integer, bits : integer)

Most flag fields (flags, charflags, manipulate, openflags, exit_info[dir], ...) hold several flags as bits of one integer. isset(value, bits) is TRUE (1) when value and bits have at least one bit in common, and FALSE (0) when they have none.

Parameters

Name Type Meaning
value integer The integer to look at, usually a flag field.
bits integer The bit or bits to look for: a flag constant such as EX_CLOSED, or several joined with |.

Returns

Integer: 1 if any bit of bits is set in value, otherwise 0. If either argument fails (for example a field of a null unit), the result fails, and a failed value is false in every test.

Notes

  • With several bits, isset(u.charflags, CHAR_BLIND | CHAR_HIDE) is true when either is set. To require all of them, test each: isset(f, A) and isset(f, B).
  • The flag constants are in vme/include/vme.h (UNIT_FL_*, CHAR_*, MANIPULATE_*, EX_*, ...) and values.h.
  • set() and unset() change the bits; isset() only reads them.
  • A field of a null unit fails, so isset(u.flags, X) and not isset(u.flags, X) behave oddly when u is null: test u == null first.

Example

dilbegin integer door_closed(rm : unitptr, dir : integer);
code
{
   if (rm == null)
      return (FALSE);
   if (rm.type != UNIT_ST_ROOM)
      return (FALSE);
   return (isset(rm.exit_info[dir], EX_CLOSED));
}
dilend

Tells whether the exit in direction dir of a room is closed.

See also