RLS Studios
ProjectsPatreonCommunityDocsAbout
Join Patreon
BeamNG Modding Docs

Guides

GE Hook CatalogInput Bindings & Keybinding SystemDebugging Your ModData Persistence & SavingVehicle Engine Documentation MapVehicle Engine Tag IndexGE Documentation MapDocumentation Tag IndexPhone UI SystemAngular Overlay Pattern (Mod UI)

Reference

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

GuidesReference

GE Hook Catalog

Every GE hook with signatures and descriptions — lifecycle, per-frame, vehicle, physics, world, input, and file system hooks.

This is the complete list of hooks your GE extension can subscribe to. Define a matching function on your M table to receive any of these events.

:::tip[How hooks work] Define local function onVehicleSpawned(vid, vehObj) end and export it as M.onVehicleSpawned = onVehicleSpawned. The engine calls it automatically when a vehicle spawns. :::


Lifecycle Hooks (Boot → Level → Shutdown)

HookSignatureSourceDescription
onExtensionLoaded(deserializedData) or (name)extensions.luaCalled on self-load (no args or deserialized state) and when other extensions load (receives their name)
onInit(deserializedData)extensions.luaGE-only second-phase init after all batch extensions call onExtensionLoaded
onFirstUpdate()main.luaVery first frame after init. One-shot.
onUiReady()main.luaCEF UI fully loaded and responsive
onClientPreStartMission(levelPath)main.luaBefore mission resources are loaded
onClientPostStartMission(levelPath)main.luaLevel Lua loaded, scene objects available
onClientStartMission(levelPath)main.luaLevel items loaded (uses hookNotify)
onWorldReadyState(state)main.lua0=not ready, 1=loading materials, 2=fully loaded
onClientEndMission(levelPath)main.luaLeaving level (uses hookNotify)
onPreWindowClose()main.luaWindow close button pressed
onPreExit()main.luaAbout to shut down
onExit()main.luaFinal shutdown

Per-Frame Hooks

HookSignatureSourceDescription
onUpdate(dtReal, dtSim, dtRaw)main.luaEvery frame, after input, before physics
onPreRender(dtReal, dtSim, dtRaw)main.luaEvery frame, after physics, before render
onGuiUpdate(dtReal, dtSim, dtRaw)main.luaEvery frame, during update() when UI flag set
onDrawDebug(focusPos, dtReal, dtSim, dtRaw)main.luaDebug visualization pass (during luaPreRender)

dt arguments:

  • dtReal - Wall-clock time since last frame
  • dtSim - Simulation time (affected by slow-motion/bullettime)
  • dtRaw - Unscaled raw delta

Vehicle Hooks

HookSignatureSourceDescription
onPreVehicleSpawned(vid, vehObj)main.luaBefore spawn hooks - use for data init
onVehicleSpawned(vid, vehObj)main.luaVehicle fully spawned
onVehicleDestroyed(vid)main.luaVehicle removed from scene
onVehicleSwitched(oldId, newId, player)main.luaPlayer changed active vehicle
onVehicleResetted(vehicleID)main.luaVehicle reset (R key)
onVehicleActiveChanged(vehicleID, active)main.luaVehicle activated/deactivated (traffic pooling)

Physics Hooks

HookSignatureSourceDescription
onPhysicsEngineEvent(args)main.luaPhysics engine events
onPhysicsPaused()main.luaPhysics paused (from physicsStateChanged)
onPhysicsUnpaused()main.luaPhysics resumed (from physicsStateChanged)
onResetGameplay(playerID)main.luaGameplay reset

Coupler Hooks

HookSignatureSourceDescription
onCouplerAttached(objId1, objId2, nodeId, obj2nodeId)main.luaVehicles coupled (trailer)
onCouplerDetached(objId1, objId2, nodeId, obj2nodeId)main.luaCoupler physically separated
onCouplerDetach(objId, nodeId)main.luaUser-initiated coupler detach

World/Environment Hooks

HookSignatureSourceDescription
onBeamNGTrigger(data)main.luaBeamNGTrigger zone entered/exited
onBeamNGWaypoint(args)main.luaWaypoint reached
onSetClusterPosRelRot(vehicleID, cNodeId)main.luaVehicle cluster teleported
onClusterTeleportNoReset(vehicleID, nodeId, px, py, pz, rdx, rdy, rdz, rdw)main.luaCluster teleport without reset
onAiModeChange(vehicleID, newAiMode)main.luaAI mode changed

Input Hooks

HookSignatureSourceDescription
onMouseLocked(locked)main.luaMouse lock state changed

Editor Hooks

HookSignatureSourceDescription
onEditorEnabled(enabled)main.luaEditor toggled on/off

File System Hooks

HookSignatureSourceDescription
onFilesChanged(files)main.lua:679File change batch detected
onFileChanged(filename, type)main.lua:681Individual file change
onFileChangedEnd()main.lua:683File change batch complete
onTexDrawPrimCompressDone(textureName)main.luaTexture compression finished

UI/Screen Hooks (from extensions, not main.lua)

HookSignatureSourceDescription
onScreenFadeState(state)ui/fadeScreen.lua1=fading to black, 2=fully black, 3=fading from black
onModManagerStateChanged()core/modmanager.luaMod installed/activated/deactivated
onBeforeMountEntry(filename, mountPoint)core/modmanager.luaBefore mod is mounted into VFS

Usage Pattern

local M = {}

-- Subscribe to any hook by exporting a function with that name
local function onVehicleSpawned(vid, vehObj)
  log('I', 'myext', 'Vehicle spawned: ' .. tostring(vid))
end

local function onWorldReadyState(state)
  if state == 2 then
    -- World fully loaded, safe to do work
  end
end

M.onVehicleSpawned = onVehicleSpawned
M.onWorldReadyState = onWorldReadyState
return M

Notes

  • hookNotify (used by onClientStartMission, onClientEndMission) differs from hook - it processes the "loaded fresh" list immediately, meaning extensions loaded during this hook get their onExtensionLoaded called right away.
  • All hooks are called in dependency-resolved order.
  • A hook function returning false does NOT cancel propagation to other extensions (except onExtensionLoaded which aborts loading of THAT extension).

See Also

  • Creating Extensions - How to create extensions that use hooks
  • Boot Sequence - When hooks fire during startup
  • Architecture - Full extension system reference
  • Common Patterns - Patterns using hooks

Understanding Vehicle Damage Systems

How BeamNG's three damage systems work together — beamstate for physics, damageTracker for gameplay, and partCondition for persistence.

Input Bindings & Keybinding System

How to read, write, and capture keybindings — data structure, Lua and UI APIs, input capture flow, and critical cleanup for mod deactivation.

On this page

Lifecycle Hooks (Boot → Level → Shutdown)Per-Frame HooksVehicle HooksPhysics HooksCoupler HooksWorld/Environment HooksInput HooksEditor HooksFile System HooksUI/Screen Hooks (from extensions, not main.lua)Usage PatternNotesSee Also