API ReferenceGE Extensionsflowgraph
Flowgraph Variable Storage
Class-based storage for flowgraph variables. Manages typed variables with merge strategies, serialization, custom ordering, and per-graph node updates.
Class-based storage for flowgraph variables. Manages typed variables with merge strategies, serialization, custom ordering, and per-graph node updates.
Public API (Class Methods)
| Method | Signature | Returns | Description |
|---|---|---|---|
C:init | (mgr) | nil | Initializes storage with manager reference and supported types |
C:getName | () | string | Returns "(mgrName / mgrId)" identifier |
C:getTypes | () | table | Returns list of supported variable types |
C:getMergeStrats | (type) | table | Returns available merge strategies for a type |
C:variableExists | (name) | boolean | Checks if a variable exists |
C:get | (name) | value, boolean | Gets variable value; second return is false if nonexistent |
C:getFull | (name) | table, boolean | Gets full variable data table |
C:clear | () | nil | Removes all variables and changes |
C:addVariable | (name, value, type, mergeStrat, fixedType, undeletable) | boolean | Adds a new variable; false if already exists |
C:removeVariable | (name) | boolean | Removes a variable; false if nonexistent or undeletable |
C:renameVariable | (name, newName) | boolean | Renames variable and updates graph nodes |
C:updateType | (name, type) | boolean | Changes variable type; resets value to type default |
C:changeBase | (name, value) | boolean | Sets both base and current value |
C:changeInstant | (name, value) | boolean | Sets current value only (no merge) |
C:change | (name, value) | boolean | Merges value using the variable's merge strategy |
C:finalizeChanges | () | nil | Finalizes all pending merge changes |
C:setMergeStrat | (name, strat) | boolean | Sets merge strategy for a variable |
C:setFixedType | (name, fixedType) | boolean | Locks/unlocks type changes |
C:setMonitor | (name, monitor) | boolean | Enables/disables monitoring |
C:setKeepAfterStop | (name, keep) | boolean | Keeps value across execution stops |
C:changeCustomVariableOrder | (name, newIdx) | nil | Reorders a variable in custom sort order |
Supported Types
string, number, bool, vec3, quat, color
Internals
- Merge strategies: Variables use merge functions (e.g.,
last,max,or_) to combine multiple writes per frame - Custom ordering:
customVariableOrdertracks display order;sortedVariableNamesis index-sorted - Node updates: Renaming or type-changing a variable propagates to all
getVariable/setVariablenodes in graphs and macros - Execution lifecycle:
_executionStoppedresets non-keepAfterStopvariables to base values
How It Works
- Variables are stored in
self.variables[name]withbaseValue,value,type,mergeStrat, etc. - During execution,
change()calls the variable's merge function; changes accumulate invariableChanges finalizeChanges()resolves all pending merges and re-initializes merge state- On stop, variables reset to their base value unless
keepAfterStopis set
Usage Examples
-- Create a variable storage (done internally by flowgraph manager)
local storage = require('/lua/ge/extensions/flowgraph/variableStorage')(manager)
-- Add variables
storage:addVariable("score", 0, "number", "max")
storage:addVariable("playerName", "unknown", "string", "last", true) -- fixedType
-- Read/write
local val, exists = storage:get("score")
storage:change("score", 50)
storage:finalizeChanges()
-- Rename
storage:renameVariable("score", "totalScore")
-- Serialize for save
local data = storage:_onSerialize()Notes
- Returns a factory function, not an extension module - instantiated per flowgraph manager
- Default merge strategies:
lastfor strings,maxfor numbers,or_for bools - Type changes reset values to sensible defaults (0, false, {0,0,0}, etc.)
Additional Exports
refreshSortedVariableNames()
getMaxSortIndex()
See Also
- Flowgraph Base Module - Related reference
- Flowgraph Base State Node - Related reference
- Flowgraph Base Node - Related reference
- FlowGraph Guide - Guide