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
Flowgraph Action ModuleFlowgraph AI Recording ModuleFlowgraph Button ModuleFlowgraph Camera ModuleFlowgraph Drift ModuleFlowgraph File ModuleFlowgraph Foreach ModuleFlowgraph Level ModuleFlowgraph Mission ModuleMission Replay ModulePrefab ModuleThread ModuleTimer ModuleTraffic ModuleUI ModuleVehicle Module

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 Extensionsflowgraphmodules

Prefab Module

Flowgraph module that manages prefab lifecycle-spawning, tracking, collision/navgraph reloading, vehicle extraction, and cleanup. Ensures all spawned prefabs are properly deleted when the flowgraph st

Flowgraph module that manages prefab lifecycle-spawning, tracking, collision/navgraph reloading, vehicle extraction, and cleanup. Ensures all spawned prefabs are properly deleted when the flowgraph stops, with collision and navgraph reloads as needed.


Module Properties

PropertyValueDescription
moduleOrder50Mid-range initialization order

Class Methods

Lifecycle

MethodDescription
C:init()Initializes prefabs, sortedIds, flags tables; calls clear()
C:clear()Clears all tracked prefabs, flags, and sorted ID list
C:afterTrigger()Reloads collision (be:reloadCollision()) and/or navgraph (map.reset()) if flagged
C:executionStopped()Deletes all non-kept prefabs, reloads collision/navgraph if any contained them

Prefab Spawning & Tracking

MethodDescription
C:spawnPrefab(fileName)Spawns a prefab from file at origin, adds to MissionGroup, returns ID
C:addPrefab(id, moreData)Registers an existing prefab: finds children by type, stores vehicle transforms, flags collision/navgraph reloads
C:getPrefab(id)Returns tracked prefab data or empty table
C:deletePrefab(id, force)Deletes prefab unless marked dontDelete (force overrides); handles vehicle unpacking

Vehicle Management

MethodDescription
C:originalVehicleTransforms(data)Records position/rotation/up for all vehicles in a prefab; registers them with vehicle module
C:restoreVehiclePositions(id)Resets all vehicles in a prefab to their original transforms
C:getVehicleIdsForPrefab(id)Returns sorted list of vehicle IDs contained in a prefab

Prefab Options

MethodDescription
C:setKeepPrefab(id, keep)Marks a prefab to survive flowgraph stop (dontDelete flag)
C:setUnpackVehiclesBeforeDeletion(id, set)Marks prefab to extract vehicles to MissionGroup before deletion
C:unpackPrefabAndDelete(id, obj)Explodes prefab, moves vehicles to MissionGroup with current transforms, deletes prefab group

Usage Example

local prefabMod = mgr.modules.prefab

-- Spawn a prefab from file
local prefabId = prefabMod:spawnPrefab("levels/west_coast_usa/art/props/checkpoint.prefab.json")

-- Keep prefab after flowgraph stops
prefabMod:setKeepPrefab(prefabId, true)

-- Reset vehicles inside a prefab to original positions
prefabMod:restoreVehiclePositions(prefabId)

-- Get all vehicle IDs inside a prefab
local vehIds = prefabMod:getVehicleIdsForPrefab(prefabId)

-- Extract vehicles before deleting prefab
prefabMod:setUnpackVehiclesBeforeDeletion(prefabId, true)
prefabMod:deletePrefab(prefabId)

Internal Details

  • findObjectsRecursive walks SimSet/SimGroup/Prefab hierarchies to catalogue all objects by class
  • findAllObjects warns about named objects in activity prefabs (except ignored classes) to prevent conflicts
  • containsColliders checks TSStatic objects for non-"None" collisionType
  • requiresNavgraphReload checks for BeamNGWaypoint (not excluded from map) and drivable DecalRoad objects
  • Collision/navgraph reloads are deferred via flags and handled in afterTrigger() or via level module during loading
  • Spawned prefabs have canSave = false to avoid serialization

See Also

  • Flowgraph Action Module - Related reference
  • Flowgraph AI Recording Module - Related reference
  • Flowgraph Button Module - Related reference
  • FlowGraph Guide - Guide

Mission Replay Module

Flowgraph module that manages mission replay recording and playback. Handles automatic recording during mission attempts, replay file management (deletion by count or size), metadata generation, and c

Thread Module

Flowgraph module for inter-flowgraph messaging and child project management. Enables flowgraph managers to send/receive messages and spawn child flowgraph projects that communicate back via the thread

On this page

Module PropertiesClass MethodsLifecyclePrefab Spawning & TrackingVehicle ManagementPrefab OptionsUsage ExampleInternal DetailsSee Also