Flags are a simple yet powerful way to determine which actions and contexts are applicable at any moment in time. They are a simple list of strings, for example is_thirsty
, wears_hat
, etc. You can then use these flags to filter actions (e.g. filter out the action remove_hat
when wears_hat
is set) and contexts (only show {{ char }} is thirsty
when is_thirsty
is set).
Flags can be used in conditions, scripts, and can be set directly from actions too.
Enum Flags
Some flags are mutually exclusive, and it quickly can become a pain to unset all variants of that flag. A typical example would be if you have a character that can be standing, sitting, dancing or crouching, you would have to unset all other flags when setting one. To make this easier, you can use enum flags.
An enum flag uses the syntax flag.value
. If you set the flag pose.standing
, then if you had a flag such as pose.sitting
before, it will automatically be unset.
Unsetting flags
It is possible to set a flag by prefixing it with !
, which will un-set it. For example, if you have the flag standing
and you set !standing
, this will remove the flag standing
.
For enums, the behavior is slightly different. If you have pose.standing
and you set !pose.standing
, the flag pose.standing
will be removed, but if you had the flag pose.sitting
, it will remain. If you use !pose
however, all pose.*
flags will be removed.
Flag conditions
You can make actions and contexts dependent on a specific set of flags using basic javascript-like conditions.
The simplest examples would be:
pose.standing
: Only if the flagpose.standing
is set.!pose.standing
: Only if the flagpose.standing
is not set.
But you can also combine flags:
pose.standing && !door.closed
: Only if the flagpose.standing
is set and the flagdoor.closed
is not set.hold.empty_bottle || hold.empty_glass
: Only if one of the flagshold.empty_bottle
orhold.empty_glass
is set.
You can also use ()
to group conditions.