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 Pin

- **File:** `extensions/flowgraph/pin.lua`

Overview

  • File: extensions/flowgraph/pin.lua

The Pin class represents a single input or output connection point on a flowgraph node. Pins carry typed values (flow, number, string, vec3, etc.) and manage links, drawing, tooltips, and value tracking.

Exports

Returns a constructor function function(graph, node, direction, type, name, default, description) that creates a new Pin instance.

Constructor Parameters

ParameterTypeDescription
graphobjectThe parent graph.
nodeobjectThe parent node.
directionstring'in' or 'out'.
typestring/tablePin type (e.g. 'number', 'flow', 'vec3', or a table of accepted types).
namestringDisplay name.
defaultanyDefault value.
descriptionstringTooltip description.

Key Methods

MethodSignatureDescription
init(graph, node, dir, type, name, default, desc)Initialises the pin with ID, type, links, and usage tracking metatables.
getFirstConnectedLink() → linkReturns the first link object connected to this pin.
isUsed() → boolTrue if the pin has any links or is hardcoded.
isActive() → boolTrue if the pin can accept new links (during link creation).
_onLink(link)Called when a link is connected. For non-flow inputs, replaces the single link.
_onUnlink(link)Called when a link is disconnected.
valueSetVec3(v)Sets the value from a vec3 object as {x, y, z}.
valueSetQuat(v)Sets the value from a quat object as {x, y, z, w}.
draw(builder, style, isHeader, constValue, outWidth)Renders the pin in the editor.
drawTooltip(mgr)Renders the hover tooltip with type, value, and description.
highlightLinks()Marks all connected links for highlight rendering.
showContextMenu(menuPos, main)Renders right-click context menu (hide, show/hide links, quick access).
getTypeWithImpulseAndChain() → stringReturns effective type including impulse/chain variants.
getTableType() → stringReturns the table subtype (e.g. "generic") for table-typed pins.

Internals

Usage Tracking

When enableUsageTracking is true (default), the pin uses metatables to intercept .value reads and writes:

-- Reading pin.value updates _frameLastUsed
pin.value  -- actually reads pin._value and stamps the frame

-- Writing pin.value also stamps the frame
pin.value = 42  -- actually writes pin._value

This allows isUsed() and frame-based optimisation (nodes can skip computing unused outputs).

Link Behaviour

  • Input pins (non-flow): Only one link allowed - new link replaces old.
  • Output pins and flow pins: Multiple links supported (fan-out).

How It Works

  1. Pins are created by nodes during graph construction.
  2. Each pin gets a unique ID from the manager's ID allocator.
  3. Value access is tracked via metatables for performance optimisation.
  4. Drawing is handled separately for input (_draw_in) and output (_draw_out) directions.
  5. Links are managed as arrays; input pins enforce single-link constraints.

Usage Example

-- Creating a pin (done internally by flowgraph):
local pin = require('/lua/ge/extensions/flowgraph/pin')(graph, node, 'in', 'number', 'speed', 0, 'Vehicle speed')

-- Reading a pin value in a node's work() method:
function C:work()
  local speed = self.pinIn.speed.value  -- triggers usage tracking
  self.pinOut.result.value = speed * 2  -- triggers usage tracking
end

-- Setting vec3 values efficiently:
self.pinOut.position:valueSetVec3(someVec3)

Key Dependencies

  • ui_flowgraph_editor - type colours, icons, editor preferences
  • editor_flowgraphEditor - tooltip permission checks
  • Flowgraph manager - ID allocation, frame counting

See Also

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

New Node Template

Template file demonstrating the structure for creating new flowgraph nodes. Shows all available pin types, node metadata fields, and the minimal `work()` entry point.

Flowgraph States Manager

- **File:** `extensions/flowgraph/states.lua`

On this page

OverviewExportsConstructor ParametersKey MethodsInternalsUsage TrackingLink BehaviourHow It WorksUsage ExampleKey DependenciesSee Also