StoryFlags
The story's blackboard: named values (booleans, integers, floats, strings) that story data reads with conditions and changes with effects - quest stages, who you've talked to, what you chose.
Constructor
new StoryFlags(): StoryFlagsStarts empty. Flag names are case-sensitive.
Instance Methods
clear(): void
Removes every flag.
Returns
void
get(key: string): dynamic
Reads a flag as stored.
Parameters
key(string) — the flag name
Returns
dynamic— the value, or invalid if the flag isn't set
getInt(key: string): integer
Reads a flag as a number, e.g. a quest stage or a counter.
Parameters
key(string) — the flag name
Returns
integer— the value (a float is truncated), or 0 if it's missing or not a number
isSet(key: string): boolean
Whether a flag is set, the same test the flag condition uses.
Parameters
key(string) — the flag name
Returns
boolean— true for true, a non-zero number or a non-empty string
set(key: string, value: dynamic): boolean
Sets a flag.
Parameters
key(string) — the flag namevalue(dynamic) — a boolean, integer, float or string
Returns
boolean— true if the stored value changed
add(key: string, amount: integer): boolean
Adds to a numeric flag, starting from 0 if it isn't set.
Parameters
key(string) — the flag nameamount(integer) — may be negative
Returns
boolean— true if the stored value changed
toAA(): roAssociativeArray
A copy of every flag, e.g. to save or show in a debug view.
Returns
roAssociativeArray— flag name -> value
loadAA(data: roAssociativeArray): void
Replaces every flag with saved ones (from toAA()). Values that aren't a boolean, number or string are dropped.
Parameters
data(roAssociativeArray) — flag name -> value
Returns
void