Core Command Handler
Handles `beamng:` URL scheme commands for mod management, map loading, toolchain, debugger control, and other async tasks triggered via protocol URLs or startup arguments.
Handles beamng: URL scheme commands for mod management, map loading, toolchain, debugger control, and other async tasks triggered via protocol URLs or startup arguments.
Overview
The command handler processes beamng:v1/command/data protocol URLs. Commands arrive via OS-level URL scheme registration or startup arguments (-command "beamng:...") and are dispatched to the appropriate extension. Commands received before UI is ready are cached and replayed once onUiReady fires.
Public Functions
| Function | Signature | Description |
|---|---|---|
onSchemeCommand | (scheme, isStartingArg) | Parse and dispatch a scheme URL |
onFirstUpdate | () | Process startup -command arguments |
onUiReady | () | Flush cached commands from before UI init |
onSerialize | () | Save reload flag |
onDeserialized | (d) | Restore reload flag (skip startup cmd on GE reload) |
URL Format
beamng:v1/command/data
│ │ │
│ │ └── Optional data payload (URL-encoded)
│ └────────── Command name
└────────────── Version stringSupported Commands
| Command | Version | Description |
|---|---|---|
showMod | v1 | Open mod details in repository UI |
subscriptionMod | v1 | Subscribe to a mod |
downloadMod | v1 | Download and install a mod |
updateZipMod | v1 | Replace a zip mod with a new version |
openMap | v1 | Load a map (JSON config) - uses core_loadMapCmd |
loadSnapshot | v1 | Load a game snapshot - uses core_snapshot |
tech_utils | v1 | Call a function on tech_utils extension |
core_input_actions | v1 | Trigger input actions (e.g., triggerDownUp/toggleCamera) |
startToolchainServer | any | Load networking_editorToolchain extension |
startDebugServer | any | Start the Lua debug server |
stopDebugServer | any | Stop the Lua debug server |
attachDebugger | any | Attach the Lua debugger |
detachDebugger | any | Detach the Lua debugger |
Startup Argument Processing
-- Parse startup args for -command "beamng:..."
local cmdArgs = Engine.getStartingArgs()
for i = 1, #cmdArgs do
if cmdArgs[i] == '-command' then
local arg = cmdArgs[i + 1]:stripcharsFrontBack('"\'')
if arg:startswith('beamng:') then
onSchemeCommand(arg:sub(8), true) -- strip 'beamng:'
end
end
endCommand Caching
-- Commands received before UI ready are cached
if not uiReady then
table.insert(cachedSchemes, {sc = scheme, startArg = isStartingArg})
return
end
-- Flushed in onUiReady()Mod Commands
-- Download and install a mod from repository
beamng:v1/downloadMod/MKA5UZHYS/6902/spanishpoliceroamerpack.zip
-- Handler:
extensions.core_repository.installMod(data, filename, 'mods/repo/')Key Notes
- URL data is unescaped (
%20→ space) before parsing ignoreStartupCmdflag prevents re-executing startup commands on GE Lua reloadopenMaploadscore_loadMapCmdwith manual unload mode for queued navigationcore_input_actionssupports arbitrary function calls with/-separated params- Unknown commands log an error but don't crash
Module State
| Variable | Type | Default |
|---|---|---|
onExtensionLoaded | function | nop |
M.onExtensionLoaded- Hook: extension loaded (nop).M.onSchemeCommand(scheme, isStartingArg)- Handles URI scheme commands.M.onFirstUpdate()- Hook: first update tick.M.onUiReady()- Hook: UI is ready.M.onSerialize()- Serializes command handler state.M.onDeserialized(data)- Restores command handler state.
Core Checkpoints
Manages vehicle checkpoint saving and restoration for scenario races. Tracks waypoint progress, saves vehicle position/direction at each checkpoint, and handles automated AI vehicle resets when stuck.
Coupler Camera Modifier
Adjusts orbit camera distance and target when two vehicles are coupled (e.g. truck + trailer), centering the view between them. Automatically restores original camera settings on detach or when vehicl