flags
Set of 'switches' that can be either set ('on') or reset ('off').
All flags are reset by default. Flags can be set in the definition, and
set, reset, or read at run time.
Remarks:
- Flags are predefined, binary values that are normally assigned
to the flags parameter
of the object. The flag values are choosen in a way that they can
be combined through OR-ing (i.e. applying the OR operator, as in
BRIGHT | PASSABLE).
- In an object definition, flags are set by OR-ing them and assigning
them to the flags parameter
(flags = BRIGHT | PASSABLE;). Note that there must be spaces
left and right of the flag values.
- In C-Script, a flag is set or reset at runtime by assigning the ON
or OFF value (like my.ZNEAR =
ON;).
- LC In C, C++,
or Lite-C, a flag is set at runtime by OR-ing the flags parameter
with the flag (material.flags
|= TANGENT;); it is reset by AND-ing
the flags parameter
with the inverse flag (material.flags &= ~TANGENT;);
and it is read by AND-ing the flags parameter with the flag and
comparing the result with zero.
-
LC Entities have more than 32 flags and thus need several flag parameters in lite-C.
The other parameters are flags2, eflags, emask, and smask.
The parameter a flag belongs to is given in its Type field.
Example (C-Script):
ENTITY* gun { ... flags = BRIGHT | PASSABLE; ... }
...
gun.ZNEAR = ON; // set the ZNEAR flag of the gun object
gun.ZNEAR = OFF; // reset the ZNEAR flag of the gun object
if (gun.ZNEAR == ON) { ... } // read the ZNEAR flag of the my object
Example (lite-C):
ENTITY* gun { ... flags = BRIGHT | PASSABLE; ... }
...
gun.flags |= ZNEAR; // set the ZNEAR flag of the my object
gun.flags &= ~ZNEAR; // reset the ZNEAR flag of the my object
if (gun.flags & ZNEAR) { ... } // read the ZNEAR flag of the my object
LC For convenience, some
macros were defined in acknex.h for setting,
resetting, toggling, or testing flags:
#define set(obj,flag) obj.flags |= (flag)
#define reset(obj,flag) obj.flags &= ~(flag)
#define toggle(obj,flag) obj.flags ^= (flag)
#define is(obj,flag) (obj.flags & (flag))
...
set(my,ZNEAR);
reset(my,ZNEAR);
toggle(my,ZNEAR);
if is(my,ZNEAR) { ... }
LC In lite-C several
flags can be set an reset in one single statement:
mypanel.flags |= (SHOW | LIGHT | OVERLAY);
set(mypanel, SHOW | LIGHT | OVERLAY);
► latest
version online