Thread Module
Flowgraph module for inter-flowgraph messaging and child project management. Enables flowgraph managers to send/receive messages and spawn child flowgraph projects that communicate back via the thread
Flowgraph module for inter-flowgraph messaging and child project management. Enables flowgraph managers to send/receive messages and spawn child flowgraph projects that communicate back via the thread system.
Module Properties
| Property | Value | Description |
|---|---|---|
moduleOrder | 1000 | Late initialization order |
hooks | onFlowgraphManagerPreUpdate | Processes queued messages each frame |
Class Methods
Lifecycle
| Method | Description |
|---|---|
C:init() | Calls clear() |
C:clear() | Resets children, messages, parentId |
C:executionStarted() | Empty (placeholder) |
C:executionStopped() | Stops all child flowgraphs, removes them, then clears state |
Messaging
| Method | Description |
|---|---|
C:sendMessage(targetId, message, sourceNode) | Sends a message to another flowgraph manager by ID (-1 targets parent); logs the event |
C:receiveMessage(message, sourceId) | Queues an incoming message for processing next frame |
C:onFlowgraphManagerPreUpdate() | Processes all queued messages: broadcasts via message.hook or onThreadMessageProcess |
Child Project Management
| Method | Description |
|---|---|
C:startProjectFromFilepath(file, sourceNode) | Loads and starts a child flowgraph from file; sets parent ID for return messaging; returns child manager ID |
Usage Example
local threadMod = mgr.modules.thread
-- Send a message to another flowgraph manager
threadMod:sendMessage(targetMgrId, {
name = "missionComplete",
hook = "onMissionCompleted", -- optional: broadcast as this hook
data = { score = 100 }
}, sourceNode)
-- Spawn a child flowgraph project
local childId = threadMod:startProjectFromFilepath(
"/gameplay/missions/race/race_flow.flow.json",
sourceNode
)
-- Send message to parent (-1 = parent)
threadMod:sendMessage(-1, { name = "childDone" }, sourceNode)
-- Messages without a .hook field are broadcast as:
-- mgr:broadcastCall("onThreadMessageProcess", message)Internal Details
- Messages are queued in
self.messagesand processed inonFlowgraphManagerPreUpdate - If
message.hookis set, broadcast uses that hook name withmessage.data - Child projects tracked in
self.childrenas{fgId, originalPath} - Child's
parentIdset to spawner's manager ID for return messaging - On execution stop, all children are stopped and scheduled for removal via
core_flowgraphManager.removeNextFrame
Additional Exports
afterTrigger()
See Also
- Flowgraph Action Module - Related reference
- Flowgraph AI Recording Module - Related reference
- Flowgraph Button Module - Related reference
- FlowGraph Guide - Guide
Prefab Module
Flowgraph module that manages prefab lifecycle-spawning, tracking, collision/navgraph reloading, vehicle extraction, and cleanup. Ensures all spawned prefabs are properly deleted when the flowgraph st
Timer Module
Flowgraph module providing a managed timer system with pause/resume, multiple time modes (real/sim/raw), and variable-backed storage. Timers are identified by auto-incrementing IDs and support elapsed