RLS Studios
ProjectsPatreonCommunityDocsAbout
Join Patreon
BeamNG Modding Docs

Guides

Reference

server/commands - Camera & Input Commandsge_utils - Game Engine Utility Functionsmain.lua - GE Lua Entry Point & Game Loopmap.lua - Navigation Graph (AI Road Map)screenshot.lua - Screenshot Systemserver/server - Level Loading & Game ServerserverConnection - Client-Server Connection Manager`setSpawnpoint` - Default Spawn Point Persistence`simTimeAuthority` - Simulation Time & Bullet Time Control`spawn` - Vehicle Spawning & Safe Placement`suspensionFrequencyTester` - Suspension Natural Frequency Analysis
Activity ManagerAudio Bank ManagerAudio Ribbon SystemBus Route ManagerCamera SystemCore Chat (IRC)Core CheckpointsCore Command HandlerCoupler Camera ModifierDevices (RGB Peripherals)Dynamic PropsEnvironmentFlowgraph ManagerForestFun StuffGame ContextGame StateGround Marker ArrowsGround MarkersHardware InfoHighscoresHotlappingInventoryJob SystemLap TimesLevelsLoad Map CommandMetricsMod ManagerMultiseatMultiseat CameraMulti SpawnOnlinePaths (Camera Paths)Quick Access (Radial Menu)Recovery PromptRemote ControllerReplayRepositoryRope Visual TestScheme Command ServerCore SnapshotCore SoundsCore TerrainTraffic SignalsTrailer RespawnVehicle Active PoolingVehicle Bridge (GE ↔ VLua Communication)Vehicle MirrorsVehicle PaintsCore VehiclesVehicle TriggersVersion UpdateWeather SystemWindows Console

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 Extensionscore

Trailer Respawn

Manages trailer attachment tracking, respawn placement, and vehicle train queries.

Manages trailer attachment tracking, respawn placement, and vehicle train queries.


Overview

Extension: core_trailerRespawn - Tracks coupler attach/detach events to maintain a registry of vehicle-to-trailer relationships. When a vehicle resets or changes active state, its trailer is automatically repositioned. Prevents coupling loops and handles prop filtering.


Dependencies

core_vehicleBridge


Public Functions

FunctionDescription
M.setEnabled(enabled)Enables/disables the coupler event listeners
M.getEnabled()Returns whether the system is enabled
M.getTrailerData()Returns the trailer registry table
M.getAttachedNonTrailer(vehId)Walks attachment chain to find first non-trailer vehicle
M.isVehicleCoupledToTrailer(vehId, trailerId)Recursively checks if vehicles are coupled
M.getVehicleTrain(vehId, res, forward)Returns all connected vehicles in a train
M.placeTrailer(vehId)Repositions the trailer attached to the given vehicle
M.coupleTrailer(vehId)Triggers auto-coupling for the registered trailer
M.resetData()Clears all trailer registration data

Event Handlers

HandlerDescription
M.onCouplerAttached(obj1, obj2, node1, node2)Registers trailer attachment
M.onCouplerDetach(objId, nodeId)Unregisters vehicle on detach
M.onVehicleActiveChanged(vehId, active)Shows/hides and repositions trailers
M.onVehicleSpawned(vehId)Unregisters respawned vehicle
M.onVehicleResetted(vehId)Repositions trailer after vehicle reset
M.onVehicleDestroyed(vehId)Cleans up destroyed vehicle
M.onSerialize() / M.onDeserialized(data)Persists registry across reloads
M.debugEnabledBoolean. Enables debug mode (default false).
M.dependenciesTable. Required extensions: {'core_vehicleBridge'}

Trailer Registry Format

trailerReg[vehId] = {
  trailerId = number,    -- attached trailer vehicle ID
  trailerNode = number,  -- coupler node on trailer
  node = number          -- coupler node on vehicle
}

Module State

VariableTypeDefault
dependenciestable{"core_vehicleBridge"}
debugEnabledbooleanfalse

Usage Examples

-- Check if a vehicle has a trailer
local data = core_trailerRespawn.getTrailerData()
if data[vehId] then
  log('I', '', 'Trailer ID: ' .. data[vehId].trailerId)
end

-- Get all vehicles in a train
local train = core_trailerRespawn.getVehicleTrain(vehId)
for id, _ in pairs(train) do
  log('I', '', 'Train member: ' .. id)
end

-- Manually reposition trailer
core_trailerRespawn.placeTrailer(vehId)

Hooks Emitted

HookArgsWhen
onTrailerAttached(objId1, objId2)After coupler attachment registered

See Also

  • Vehicle Manager - Vehicle spawning and data

Traffic Signals

Comprehensive traffic signal system with instances, controllers, sequences, and intersection management.

Vehicle Active Pooling

Manages pools of vehicles with active/inactive states for performance. Controls which vehicles are visible (active) based on configurable limits and distance culling.

On this page

OverviewDependenciesPublic FunctionsEvent HandlersTrailer Registry FormatModule StateUsage ExamplesHooks EmittedSee Also