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
Foreach (Flowgraph Node)Get Foreach (Flowgraph Node)Integrated (Flowgraph Node)I/O (Flowgraph Node)

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 Extensionsflowgraphnodesmacro

Foreach (Flowgraph Node)

- **Node Name:** `Foreach`

Overview

  • Node Name: Foreach
  • Category: logic
  • File: extensions/flowgraph/nodes/macro/foreach.lua

Creates and runs a separate flowgraph instance for each element in a table. Each instance receives the key and value via the foreach module.

Pin Schema

Input Pins

PinTypeDescription
flowflowInflow for this node
tabletableThe table to iterate over (generic tableType)
elementFilestringPath to the .flow.json file to load for each element

Output Pins

None.

Data Properties

PropertyTypeDefaultDescription
destroyTargetOnStopbooltrueDestroy spawned flowgraph managers when execution stops

Behavior

  • init(mgr, ...) - Sets destroyTargetOnStop to true, clears targets list.
  • postInit() - Configures the elementFile pin to accept .flow.json files.
  • work() - On first flow, iterates the input table. For each key/value pair, loads a flowgraph manager from the element file, sets mgr.modules.foreach.key and .value, starts execution, and stores the manager reference.
  • _executionStopped() - If destroyTargetOnStop is true, stops and removes all spawned managers.

How It Works

This node is a macro-level iterator. When triggered, it loads a separate flowgraph project file for each element in the table. Each spawned flowgraph gets the current key and value injected into its foreach module, accessible via the Get Foreach node inside the child flowgraph.

The node only executes once per flow activation (tracked by self.done).

Example Usage

-- Iterate over a list of vehicle IDs:
-- table = {101, 102, 103}
-- elementFile = "/flowgraphs/processVehicle.flow.json"
-- Creates 3 flowgraph instances, each with:
--   mgr.modules.foreach.key = 1/2/3
--   mgr.modules.foreach.value = 101/102/103

-- Inside processVehicle.flow.json, use a "Get Foreach" node
-- to access the key and value for that iteration

See Also

  • Get Foreach (Flowgraph Node) - Related reference
  • Integrated (Flowgraph Node) - Related reference
  • I/O (Flowgraph Node) - Related reference
  • FlowGraph Guide - Guide

XOR (Flowgraph Node)

- **Node Name:** `Xor`

Get Foreach (Flowgraph Node)

- **Node Name:** `Get Foreach`

On this page

OverviewPin SchemaInput PinsOutput PinsData PropertiesBehaviorHow It WorksExample UsageSee Also