RLS Studios
ProjectsPatreonCommunityDocsAbout
Join Patreon
BeamNG Modding Docs

Guides

Reference

Server CommandsGE UtilitiesGame Engine MainNavigation GraphScreenshot CaptureServerServer ConnectionSpawnpoint ManagerSimulation TimeVehicle SpawningSuspension Frequency Tester
Flowgraph Base ModuleFlowgraph Base NodeFlowgraph Base State NodeFlowgraph Node BuilderFlowgraph GraphFlowgraph Group HelperFlowgraph LinkFlowgraph ManagerNew Node TemplateFlowgraph PinFlowgraph States ManagerFlowgraph UtilsFlowgraph Variable Storage

UI

Resources

BeamNG Game Engine Lua Cheat SheetGE Developer RecipesMCP Server Setup

// RLS.STUDIOS=true

Premium Mods for BeamNG.drive. Career systems, custom vehicles, and immersive gameplay experiences.

Index

HomeProjectsPatreon

Socials

DiscordPatreon (RLS)Patreon (Vehicles)

© 2026 RLS Studios. All rights reserved.

Modding since 2024

API ReferenceGE Extensionsflowgraph

Flowgraph Graph

Core graph class that holds nodes, links, and pins for a single flowgraph. Manages node creation/deletion, execution planning, variable storage, and serialization. Each manager contains one or more gr

Core graph class that holds nodes, links, and pins for a single flowgraph. Manages node creation/deletion, execution planning, variable storage, and serialization. Each manager contains one or more graphs organized in a parent-child hierarchy.

No public module exports - instantiated internally by the flowgraph manager.


Purpose

A graph is the fundamental container in the flowgraph system. It holds:

  • Nodes - the logic units (keyed by ID)
  • Links - connections between pins (keyed by ID)
  • Pins - all pin objects across all nodes (keyed by ID)
  • Variables - graph-scoped variable storage

Class (C) - Key Methods

MethodSignatureDescription
init(mgr, name, forceId)Sets up graph state: nodes/links/pins tables, variable storage, hook list, view position.
getParent()Returns the parent graph from the manager's graph table.
getChildren()Returns child graphs sorted by ID.
getRootGraph()Walks up the parent chain to find the root graph.
createNode(nodeType, ...)Creates a node of the given type, adds it to the graph.
deleteNode(node)Removes a node and its links from the graph.
createLink(sourcePin, targetPin)Creates a link between two pins.
deleteLink(link)Removes a link, cleaning up pin references.
gatherNodesAndLinks(rNodes, rLinks, interInfo)Recursively collects all nodes and links including integrated macros.
plan()Builds execution order by analyzing node connections, flow dependencies, and colors. Generates compiled trigger functions for each root node. Only runs on root graphs (not macros or child graphs).
clear()Destroys all child graphs, nodes, links, and pins.
setDirty(dirty, startFromRoot)Marks the graph (and children) as needing re-planning.
getDirtyChildren(dirtyChildren)Finds child graphs with dirty macros.
clearVariableChangesChildren()Recursively clears variable change tracking.
_executionStarted()Calls __executionStarted() on all nodes.
_executionStopped()Calls __executionStopped() on all nodes and stops variable storage.
_onClear()Calls _onClear() on all nodes and variable storage.
_onSerialize()Serializes graph to data table (nodes, links, variables, view state). Returns {data, minId}.
_onDeserialized(data)Rebuilds graph from serialized data: creates nodes, links, restores variables and view state.

Execution Planning

The graph plans execution order by analyzing node connections and flow dependencies. Key concepts:

ConceptDescription
_replanFlag indicating the execution plan needs rebuilding.
onUpdateNodeIdID of the node that receives the onUpdate hook.
hookListList of hooks this graph's nodes subscribe to.

Graph Hierarchy

Manager
 └─ Root Graph (type = "graph")
     ├─ Child Graph (type = "graph")
     ├─ Macro (type = "macro")
     └─ Instance (type = "instance", macroID = ...)

Key Properties

PropertyTypeDescription
idnumberUnique graph ID within the manager.
namestringDisplay name.
typestring"graph", "macro", or "instance".
parentIdnumberID of the parent graph (nil for root).
nodestable{[id] = nodeObj} - all nodes in this graph.
linkstable{[id] = linkObj} - all links in this graph.
pinstable{[id] = pinObj} - all pins across all nodes.
variablesVariableStorageGraph-scoped variable container.
viewPosim.ImVec2PtrEditor viewport position for this graph tab.
viewZoomim.FloatPtrEditor viewport zoom level.
isStateGraphboolWhether this graph uses state-machine nodes.

GC Profiling

-- Each graph tracks garbage collection pressure:
self.gcprobeTable = {
  total = 0,
  history = {},
  entries = {},       -- per-node GC stats
  totalHistory = {},
}

Usage Context

-- Graphs are created by the manager:
local graph = mgr:createGraph("My Graph")
local node = graph:createNode("logic/branch")
local link = graph:createLink(sourcePin, targetPin)

-- Execution is driven by the manager, which calls into graphs
-- for triggering, updating, and serialization.

Additional Exports

resolveInterHops(rLinks, interInfo)

  • rLinks - any
  • interInfo - any

moveNodeToGraph(node, newGraph)

  • node - any
  • newGraph - any

linkExists(startPin, endPin)

  • startPin - any
  • endPin - any
  • Returns: boolean

hasLink(pin)

  • pin - any
  • Returns: boolean

pinsCompatible(sourcePin, targetPin)

  • sourcePin - any
  • targetPin - any

canCreateLink(a, b, newLinkInfo)

  • a - any
  • b - any
  • newLinkInfo - any
  • Returns: boolean

findPin(pinId)

  • pinId - any
  • Returns: any

updateChildrenTypes(t, ignoreType)

  • t - any
  • ignoreType - any

getMacro()

getInstanceRoot()

getChildPosition()

  • Returns: any

getDeepChild(indexes)

  • indexes - any
  • Returns: any

getRecursiveHooksAndDependencies(hooks, deps)

  • hooks - any
  • deps - any
  • Returns: any

findNodeInChildren(id)

  • id - any
  • Returns: any

findNodeRecursive(id)

  • id - any
  • Returns: any

forceRecursiveNodeUpdatePosition()

toString()

  • Returns: any

printStructure()

getParentWithStates()

  • Returns: any

getChildrenWithStates()

getSiblings()

getLocation(withIds)

  • withIds - any
  • Returns: any

See Also

  • Flowgraph Base Module - Related reference
  • Flowgraph Base State Node - Related reference
  • Flowgraph Base Node - Related reference
  • FlowGraph Guide - Guide

Flowgraph Node Builder

ImGui node builder that handles the visual layout and rendering of flowgraph nodes. Manages node stages (begin → header → content → input → middle → output → end), pin layout, and header texture rende

Flowgraph Group Helper

Helper class for grouping and ungrouping nodes in the flowgraph editor. Handles converting selected nodes into subgraphs, computing bounding rectangles, centering node layouts, and managing link re-ro

On this page

PurposeClass (C) - Key MethodsExecution PlanningGraph HierarchyKey PropertiesGC ProfilingUsage ContextAdditional ExportsresolveInterHops(rLinks, interInfo)moveNodeToGraph(node, newGraph)linkExists(startPin, endPin)hasLink(pin)pinsCompatible(sourcePin, targetPin)canCreateLink(a, b, newLinkInfo)findPin(pinId)updateChildrenTypes(t, ignoreType)getMacro()getInstanceRoot()getChildPosition()getDeepChild(indexes)getRecursiveHooksAndDependencies(hooks, deps)findNodeInChildren(id)findNodeRecursive(id)forceRecursiveNodeUpdatePosition()toString()printStructure()getParentWithStates()getChildrenWithStates()getSiblings()getLocation(withIds)See Also