Flags
One convenience feature included with Narramancer is the Flag System.
A Flag in Narramancer is simply a True or False value stored on the table.
A flag can represent whether the player has seen a key part of the story yet or a key event has happened. If a flag is raised then we consider that event has having happened.
Each possible flag must be defined using a Flag ScriptableObject, created somewhere in the project folder using the Create Asset Context menu: Narramancer -> Flag.
Why not just use global variables?
Using global variables or other ways of keeping track of what part of the story we are in is entirely possible, but can become unwieldy if the number of events grows large. Flags provide a scalable way of having a lot of events, and referring to them using Object Fields avoids 'magic string' issues.
Raised Flags
The value behind a flag is actually an integer. The value of the flag starts at zero (unless otherwise assigned) and raising a flag increments the value by one.
The flag is considered raised if its value is greater than or equal to one. A flag can be raised multiple times, which can then be used to indicate not just that the event has happened at all, but count the number of times.
A flag can be lowered by setting its value to zero.
Using Flags
The nodes used to access and manipulate flags are as follows:
- Use the RaiseFlagNode, RemoveFlagNode, and SetFlagNode to raise, lower, or manually set the given flag.
- Use the IsFlagRaisedNode to check, true or false, whether a flag is raised, and the GetFlagNode to access the integer manually.
A screenshot of RaiseFlagNode, RemoveFlagNode, and SetFlagNode.
A screenshot of IsFlagRaisedNode and GetFlagNode.