Flowgraph File Module
Provides persistent key-value file storage for flowgraph projects. Reads and writes JSON save files in the `settings/cloud/flowgraphSaveData/` directory. Used by nodes to persist state across sessions
Provides persistent key-value file storage for flowgraph projects. Reads and writes JSON save files in the settings/cloud/flowgraphSaveData/ directory. Used by nodes to persist state across sessions.
No public module exports - created via _flowgraph_createModule(C).
Purpose
Flowgraph nodes that need to persist data (progress, scores, flags) use this module. Each logical "file" is a JSON document with a data table and lastModified timestamp. Changes are batched and written after each trigger cycle.
Key Methods
| Method | Signature | Description |
|---|---|---|
init | () | Calls clear(). |
clear | () | Resets loaded file cache and change tracking. |
forceReload | (file) | Removes a file from the cache so next access re-reads from disk. |
getFile | (file) | Loads a file from settings/cloud/flowgraphSaveData/{file}.save.json if not cached. Returns the file table. |
write | (file, field, value) | Sets file.data[field] = value and marks the file as changed. Updates lastModified. |
read | (file, field) | Returns file.data[field] for the given file. |
afterTrigger | () | Writes all changed files to disk as JSON. |
executionStopped | () | Calls clear(). |
executionStarted | () | Calls clear(). |
File Format
-- Stored at: settings/cloud/flowgraphSaveData/{name}.save.json
{
lastModified = 1703275200, -- os.time()
data = {
highScore = 15000,
completedLevels = { "level1", "level2" },
playerName = "Driver",
}
}Usage from Nodes
-- Writing persistent data:
local fileModule = self.mgr:getModule("file")
fileModule:write("myMission", "bestTime", 42.5)
fileModule:write("myMission", "completed", true)
-- Reading persistent data:
local bestTime = fileModule:read("myMission", "bestTime") -- 42.5
-- Force re-read from disk:
fileModule:forceReload("myMission")Properties
| Property | Default | Description |
|---|---|---|
moduleOrder | 0 | Standard priority. |
files | {} | Cache of loaded file tables keyed by name. |
changed | {} | Set of file names with pending writes. |
Storage Path
All files are stored under settings/cloud/flowgraphSaveData/ with the .save.json extension. The cloud prefix suggests these may be synced across sessions.
See Also
- Flowgraph Action Module - Related reference
- Flowgraph AI Recording Module - Related reference
- Flowgraph Button Module - Related reference
- FlowGraph Guide - Guide
Flowgraph Drift Module
Receives drift gameplay callbacks (spinout, crash, scoring events) and exposes them to flowgraph nodes via a TTL-based callback system. Bridges `gameplay_drift_general` events into the flowgraph.
Flowgraph Foreach Module
Minimal module that stores key-value iteration state for flowgraph projects spawned as foreach children. When a parent flowgraph iterates over a collection, each child manager gets a foreach module co