API ReferenceGE Extensionscore
Flowgraph Manager
Central manager for BeamNG's visual scripting system (flowgraphs). Handles creation, loading, serialization, and per-frame execution of flowgraph manager instances.
Central manager for BeamNG's visual scripting system (flowgraphs). Handles creation, loading, serialization, and per-frame execution of flowgraph manager instances.
Public API
| Function | Signature | Description |
|---|---|---|
M.addManager | (data?) → mgr | Creates a new flowgraph manager, optionally deserializing from data. |
M.loadManager | (filepath, hidden?, keepSavedDirs?) → mgr, success | Loads a .flow.json file into a new manager. |
M.removeManager | (mgr) | Destroys and removes a manager from the active list. |
M.removeNextFrame | (mgr) | Queues a manager for removal on the next frame. |
M.startNextFrame | (mgr) | Queues a manager to start running next frame. |
M.getManagerByID | (id) → mgr|nil | Finds an active manager by its unique ID. |
M.getManagerGraphNode | (mgrId, graphId, nodeId) → node|nil | Safely retrieves a node from an active manager's graph. |
M.getManagerModule | (mgrId, moduleName) → module|nil | Safely retrieves a module from an active manager. |
M.getAllManagers | () → table | Returns the list of all active managers. |
M.clearAllManagers | () | Destroys all managers. |
M.getSingleton | (name) → mgr|nil | Loads or returns a unique named manager from flowgraphEditor/{name}.flow.json. |
M.getAvailableNodeTemplates | () → tree, lookup | Scans node path for all .lua node definitions; returns tree structure and flat lookup. |
M.getAvailablePinTypes | (node) → table | Extracts available input/output pin types from a node's pinSchema. |
M.getNextUniqueIdentifier | () → number | Returns a monotonically increasing unique ID. |
M.startOnLoadingScreenFadeout | (fg) | Registers a flowgraph to auto-start when the loading screen fades out. |
M.refreshDependencies | () | Rebuilds dependency list from runningProxies keys. |
M.controls | (name) | Broadcasts onControlsReset or onControlsAction to all managers based on name ('reset' or 'action'). |
M.getAvailableStateTemplates | () → tree, lookup | Scans for *state.flow.json files under /flowgraphEditor/states/; returns tree structure and flat lookup. |
Hooks / Lifecycle
| Function | Description |
|---|---|
M.onExtensionLoaded | Registers global _flowgraph_createNode, _flowgraph_createStateNode, _flowgraph_createModule helpers. |
M.onUpdate | Resolves hooks, processes deferred start/remove queues, broadcasts onFlowgraphManagerPreUpdate. |
M.onSerialize | Serializes all non-transient managers. |
M.onDeserialized | Restores managers from serialized data, re-starts singletons. |
M.onFileChanged | Hot-reloads nodes when their source .lua files change. |
M.onLoadingScreenFadeout | Starts all flowgraphs queued via startOnLoadingScreenFadeout. |
M.onFlowgraphSceneObjectAdd | Called on FlowgraphSceneObjectAdd event |
M.onFlowgraphSceneObjectRemove | Called on FlowgraphSceneObjectRemove event |
M.onFlowgraphSceneObjectChanged | Called on FlowgraphSceneObjectChanged event |
Module State
| Variable | Type | Default |
|---|---|---|
runningProxies | table | {} - tracks running proxy extensions |
enableUsageTracking | boolean | false |
nodePath | string | '/lua/ge/extensions/flowgraph/nodes/' |
Usage Example
-- Load and start a flowgraph
local mgr, ok = core_flowgraphManager.loadManager("flowgraphEditor/myGraph.flow.json")
if ok then
mgr:setRunning(true)
end
-- Access a singleton (auto-creates and caches)
local hudMgr = core_flowgraphManager.getSingleton("hudManager")
-- Safely read a node value
local node = core_flowgraphManager.getManagerGraphNode(mgrId, graphId, nodeId)
if node then
print(node.pinOut.value.value)
endKey Internals
- Node templates live under
/lua/ge/extensions/flowgraph/nodes/. _flowgraph_createNodeis a global factory injected at load time.- Managers are
require('/lua/ge/extensions/flowgraph/manager')instances. M.runningProxiestracks proxy extensions for dependency management. |M.enableUsageTracking| Boolean. Enables flowgraph usage tracking (defaultfalse). | |M.nodePath(graph, nodeId)| Returns the path string for a node in a flowgraph. |- Custom nodes from a manager's
savedDir/customNodes/are also hot-reloaded.
Environment
Comprehensive environment control: time of day, sky colors, clouds, fog, precipitation, gravity, temperature, and ground model physics. Manages the full weather/environment pipeline for levels.
Forest
Utility wrapper for accessing the Forest scene object. Caches the forest object ID for efficient repeated lookups.