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

Lap Times

Lap and segment timing system for races. Tracks current time, lap/segment splits, best times, and diffs. Streams formatted timing data to the UI via `guihooks.queueStream`.

Lap and segment timing system for races. Tracks current time, lap/segment splits, best times, and diffs. Streams formatted timing data to the UI via guihooks.queueStream.


Public Functions

FunctionSignatureDescription
M.initialize()Resets all timing state to defaults
M.formatTime(seconds, addSign) → stringFormats seconds as MM:SS.mmm (optional ± sign)
M.getDiffFlavor(val) → stringReturns "better", "worse", or "same" for a time diff
M.setConfiguration(config)Sets totalLaps, totalSegments, closedCircuit
M.onRaceStart(meta)Initializes timing from race metadata
M.onRaceStop()Sets status to stopped, flags all streams
M.updateFastFromRace(race, playerId)Updates fast-changing data (current time, lap/segment durations)
M.updateSlowFromRace(race, playerId)Updates slow-changing data (historical times, bests, diffs)
M.updateStaticFromRace(race, playerId)Updates static metadata (lap count, segment count)
M.updatePlacementFromRace(race, playerId)Updates placement/position data
M.onUpdate(dtReal, dtSim, dtRaw)Sends flagged stream data to UI
M.newRaceStart(race)Hook for new race system - configures from race object
M.newRaceStop()Hook for new race system - stops timing

UI Streams

Stream KeyUpdate RateContent
lapTimes_fastPer frame (when flagged)Current time, lap time, segment time, formatted strings
lapTimes_slowOn segment/lap completionHistorical laps, segments, best times, diffs
lapTimes_staticOn race start/config changeTotal laps, segments, circuit type
lapTimes_placementOn position changeVehicle placements and order

Usage Example

-- Initialize and configure
core_lapTimes.initialize()
core_lapTimes.setConfiguration({
  totalLaps = 3,
  totalSegments = 8,
  closedCircuit = true
})

-- Format a time value
local formatted = core_lapTimes.formatTime(93.456)
-- Result: "01:33.456"

-- Format with sign (for diffs)
local diff = core_lapTimes.formatTime(-1.234, true)
-- Result: "-00:01.234"

-- Get flavor for UI coloring
local flavor = core_lapTimes.getDiffFlavor(-0.5)
-- Result: "better"

Data Flow

  1. Race system calls updateFastFromRace every frame and updateSlowFromRace on segment/lap events
  2. These functions populate stream data tables and set dirty flags
  3. onUpdate checks flags and sends streams via guihooks.queueStream
  4. UI subscribes to stream keys for real-time display

Notes

  • The combinedTimes field in slow stream data interleaves segments and laps chronologically.
  • Best times are tracked per-segment-index across all laps.
  • Legacy hooks (onRaceWaypointReached, onRaceResult) exist but are no-ops.
  • Status values: "stopped", "started", "paused", "complete".

See Also

  • globals - guihooks.queueStream for UI streaming

Job System

Coroutine-based job system for running background tasks without blocking the game. Jobs yield control back to the engine periodically, allowing frame rendering to continue during long operations.

Levels

Level discovery, metadata, and loading system. Scans `/levels/` for available maps, enriches data with previews/spawn points/mod info, and provides the API for starting levels.

On this page

Public FunctionsUI StreamsUsage ExampleData FlowNotesSee Also