Manual:DIL Manual/unset()
Jump to navigation
Jump to search
unset()
Procedure. Turns bits off in an integer variable or field.
unset(i : integer, bits : integer)
Turns off every bit of bits in i and leaves the other bits as they are. Mostly used on flag fields with the constants from vme.h and values.h: unset(item.openflags, EX_CLOSED) opens a container, unset(u.flags, UNIT_FL_INVISIBLE) makes a unit visible.
Parameters
| Name | Type | Meaning |
|---|---|---|
| i | integer | An integer variable, or an integer field that can be assigned (u.flags, room.exit_info[dir], ...).
|
| bits | integer | The bits to turn off (a mask, not a bit number); join several with |.
|
Notes
- vmc refuses a constant or an expression as
i: "Arg 1 of 'unset' not an integer variable". - On a field of a null unit nothing happens.
- A field this zone may not change (such as
pc.leveloutside zones with access level 0) stops the program at run time, with "DIL SERIOUS: ... Type error in lvalue unset" in the log. - Only the bits change, nothing else: no messages, and the other side of a door keeps its flags.
set()turns bits on;isset()tests them.
Example
dilbegin open_item(item : unitptr);
code
{
if (not isset(item.openflags, EX_CLOSED))
{
act("$2n is already open.", A_ALWAYS, self, item, null, TO_CHAR);
return;
}
if (isset(item.openflags, EX_LOCKED))
{
act("$2n seems to be locked.", A_ALWAYS, self, item, null, TO_CHAR);
return;
}
act("You open $2n.", A_ALWAYS, self, item, null, TO_CHAR);
act("$1n opens $2n.", A_ALWAYS, self, item, null, TO_REST);
unset(item.openflags, EX_CLOSED);
return;
}
dilend
Opens a container. Adapted from basemove.zon.