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 Base Node

Core base class for all flowgraph nodes. Defines the complete node lifecycle: initialization, pin management, work execution, drawing, serialization, and context menus. Every flowgraph node inherits f

Core base class for all flowgraph nodes. Defines the complete node lifecycle: initialization, pin management, work execution, drawing, serialization, and context menus. Every flowgraph node inherits from this class.


Public Functions

FunctionSignatureReturnsDescription
createBasecreateBase(...)node instanceCreates a raw base node. Sets metatable to C, calls C:init(mgr, graph, forceId).
useuse(mgr, graph, forceId, derivedClass)node instanceCreates a base node, overlays all derived class fields, runs _preInit() (creates output pins from schema), calls derived init() if overridden, then _postInit() (creates input pins, handles categories/behaviors).

Node Lifecycle

createBase/use → init → _preInit → [derived init] → _postInit → postInit
                                                                    │
  ┌─────────────────────────────────────────────────────────────────┘
  │
  execution: __executionStarted → [trigger → work/workOnce per frame] → __executionStopped
  │
  serialization: __onSerialize ↔ __onDeserialized

Key Instance Properties

PropertyTypeDefaultDescription
idnumberautoUnique node ID within the manager.
namestring'unknown'Display name.
descriptionstring'No Description!'Tooltip description text.
typestring'node'Node type: 'node', 'simple', or 'variable'.
categorystringnilFunctional category determining auto-created pins and behaviors.
behaviourtable{}Active behaviors: once, duration, simple, singleActive, obsolete.
dynamicModestring'repeat''repeat' (every frame) or 'once' (single execution with reset).
pinIntablemetatableRead-only proxy returning emptyPin for missing keys.
pinInLocaltable{}Actual input pin storage.
pinOuttable{}Output pin storage.
pinListtable{}Ordered list of all pins for drawing.
datatable{}Node-specific persistent data.
triggerCountnumber0Times this node has been triggered.
workCountnumber0Times work has executed.

Pin Management Methods

MethodSignatureDescription
createPin(direction, type, name, default, description, autoNumber, extra, fixed)Creates and registers a pin. Returns the pin object.
removePin(pin)Removes a pin and all its links from the graph.
renamePin(pin, newName)Renames an input pin, updating the lookup table.
shiftPin(idInList, direction)Moves a pin's position in pinList for display ordering.
autoCreatePin(direction, type, name, default, description, extra, fixed)Creates a pin only if one with the same name doesn't exist. Respects pinOrder sorting.
createResetPin()Adds a reset flow input pin and sets 'once' behavior.
removeResetPin()Removes the reset pin and clears 'once' behavior.

Work Execution

MethodDescription
_workDynamicRepeatDefault work wrapper: calls self:work() via xpcall, increments workCount, checks automated flow.
_workDynamicOnceOnce-mode wrapper: checks reset pin, calls workOnce() first time, then work() on subsequent frames.
work(args)Override in derived nodes for per-frame logic.
workOnce()Override for one-shot logic in 'once' dynamic mode.
trigger()External entry point; increments triggerCount, calls _trigger.
checkAutomatedFlowAuto-manages flow, incomplete, complete, completed output pins based on category.

Additional Methods

MethodSignatureDescription
setDurationState(state)Sets duration state ('inactive', 'started', 'finished') for f_duration nodes.
toggleDynamicMode()Toggles between 'once' and 'repeat' dynamic modes (only for dynamic category nodes).
setDynamicMode(mode)Sets dynamic mode to 'once' or 'repeat', creating/removing reset pin as needed.
getLinks()Returns targets, sources - tables of links where this node is target/source.
isFlowActive()Checks if any flow input dependency has a value.
alignToGrid(x, y)Snaps the node position to the editor grid (14px spacing).
toString()Returns "name( nodeType / id) in graphString".
_setupTimeline(beginTime, endTime)Configures timeline data for timeline-based execution.

Duration State Machine

For f_duration category nodes:

Stateincompletecompletecompleted
inactivefalsefalsefalse
startedtruefalsefalse
finishedfalsetruetrue (1 frame)
-- Set duration state from within work():
self:setDurationState('started')   -- begin the duration
self:setDurationState('finished')  -- mark as complete

Serialization

-- __onSerialize returns:
{
  type = "nodeType/path",
  pos = {x, y},
  data = { ... },
  dynamicMode = "repeat",
  customName = "My Node",       -- optional
  customColor = {r, g, b, a},   -- optional
  hardcodedPins = { pinName = { value = v, type = t } },
  quickAccess = { p_in = {}, p_out = {} },
  hiddenPins = { p_in = {}, p_out = {} },
  timeline = { beginTime, endTime, lane },  -- optional
}

Usage Example

-- Creating a derived node type (in a node definition file)
local C = {}
C.name = 'myCustomNode'
C.description = 'Does something cool'
C.category = 'logic'  -- auto-creates flow in/out pins

C.pinSchema = {
  { dir = 'in',  type = 'number', name = 'threshold', default = 10, description = 'Activation threshold' },
  { dir = 'out', type = 'bool',   name = 'exceeded',  description = 'True when threshold exceeded' },
}

function C:work()
  self.pinOut.exceeded.value = (self.pinIn.threshold.value or 0) > self.data.limit
end

function C:init()
  self.data.limit = 50
end

return require('/lua/ge/extensions/flowgraph/basenode').use(mgr, graph, forceId, C)

Additional Exports

  • M.createBase - (undocumented)
  • M.use - (undocumented)

See Also

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

Flowgraph Base Module

Base class factory for flowgraph modules. Modules are manager-level components that provide shared state and services to flowgraph nodes (e.g., button management, camera paths, file I/O).

Flowgraph Base State Node

Base class factory for state-graph nodes. Extends `basenode` with directional transition pins (N/E/S/W) for state-machine-style flowgraphs.

On this page

Public FunctionsNode LifecycleKey Instance PropertiesPin Management MethodsWork ExecutionAdditional MethodsDuration State MachineSerializationUsage ExampleAdditional ExportsSee Also