RLS Studios
ProjectsPatreonCommunityDocsAbout
Join Patreon
BeamNG Modding Docs

Guides

Reference

Server CommandsGE UtilitiesGame Engine MainNavigation GraphScreenshot CaptureServerServer ConnectionSpawnpoint ManagerSimulation TimeVehicle SpawningSuspension Frequency Tester
Gameplay AchievementGameplay CityDiscoverForce FieldGarage ModeMarker InteractionParking SystemGameplay Playmode MarkersGameplay PoliceGameplay RallyGameplay Rally LoopGameplay Raw POIsGameplay Skidpad TestSpeed Trap LeaderboardsSpeed Traps and CamerasGameplay StatisticsTaxi Ride SystemTraffic SystemVehicle PerformanceWalking
Rally Audio ManagerRally Camera Path PlayerRally ClientRally Cut CaptureRally EnumsRally Extension HelperRally GeometryRally ManagerRecce ManagerRecce AppRecce SettingsRally Settings ManagerSnap-to-RoadTraffic Exclusion ZonesRally UtilityRally Vehicle CaptureRally Vehicle Tracker
Rally Loop PenaltiesRally AttemptsRally Event LogRally Loop ManagerRoad Section Penalty KeeperRally Schedule UtilitiesSpeeding DetectorStaged Countdown TestStaged Countdown Utilities

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 Extensionsgameplayrallyloop

Rally Loop Manager

Core manager class for rally loop gameplay. Orchestrates the entire rally event: mission sequencing, schedule calculation, wall clock / epoch time management, time control penalties, timecard recordin

Core manager class for rally loop gameplay. Orchestrates the entire rally event: mission sequencing, schedule calculation, wall clock / epoch time management, time control penalties, timecard recording, speeding detection, and UI data streaming. This is the largest and most central rally loop module.


Constructor

local C = require('gameplay/rally/loop/rallyLoopManager')
-- Instantiated internally; receives (missionId, missionDir)

Public API (Key Methods)

Lifecycle & State

MethodSignatureReturnsDescription
init(missionId, missionDir)nilFull initialization: settings, schedule, events, clock
onUpdate(dtReal, dtSim, dtRaw)nilPer-frame tick: advances clock, updates penalty keepers, speeding detector
onGuiUpdate(dtReal, dtSim, dtRaw)nilGUI update tick (lightweight)

Mission Sequencing

MethodSignatureReturnsDescription
getCurrentMissionId()string|nilCurrent mission in the sequence
getNextMissionId()string|nilAdvances index, returns next mission ID
startNextMission()booleanTransfers execution to next mission via startFromWithinMission
restartRallyLoop()nilRestarts the entire rally loop from the beginning
getRallyLoopMissionId()stringReturns the parent loop mission ID

Clock & Time

MethodSignatureReturnsDescription
getEpochTime()numberRally epoch time (0 = rally start, negative = before start)
getWallClockTimeSecs()numberAbsolute time of day in seconds
getWallClockDay()numberCurrent day number (1-based)
setClockPaused(paused)nilPauses/resumes rally clock
adjustClock(seconds)nilManually offsets clock

Schedule & Events

MethodSignatureReturnsDescription
calculateSchedule(includeDebugData?)nilBuilds full schedule from mission sequence
getSchedule()tableReturns schedule array
getEvents()tableReturns events array
recordTimeCardEntry(entryName, stageTimeSecs?)booleanRecords a checkpoint arrival with penalty calculation
advanceToNextEvent()nilMoves to next event in sequence
calculateStartLineTime(tcArrivalTime)numberSmart rescheduling of SS start based on TC arrival

Penalties & Speeding

MethodSignatureReturnsDescription
getTotalPenalty()numberTotal penalty seconds from event log
getTotalTime()numberTotal rally time (stage + penalty)
shouldPenalizeSpeeding()booleanTrue when NOT in a special stage
isInRoadSection()booleanTrue if current mission is a liaison road section
isInSpecialStage()booleanTrue if current mission is a competitive SS

Formatting

MethodSignatureReturnsDescription
formatStageTime(seconds)stringDynamic format: S.T, M:SS.T, or H:MM:SS.T
formatDuration(seconds)stringM:SS format
formatTimeFromSecondsString(secs, incSec, incTenth)stringWall clock formatted string (12h or 24h)

Internals

Mission Sequence

Built from flowgraph variables in this order:

  1. serviceOut (leaving service park)
  2. For each stage 1-4: stage{n}_rallyRoadSection → stage{n}_rallyStage
  3. return_rallyRoadSection (return liaison)
  4. serviceIn (arriving at service park)

Schedule Calculation

  • Rally start time: environment time rounded to next minute + configurable delay
  • Road sections: time allocation × 2.0 buffer, rounded to next minute
  • Special stages: TC→start line delay (1 min planned), stage time × 1.0 buffer
  • All times stored in rally epoch (0 = rally start)

Event Types

TypeDescription
tcTime control checkpoint (penalizable)
ss_startSpecial stage start line
ss_stopSpecial stage stop control
service_inService park arrival

Data Streaming

Updates in-place tables (streamData, rallyClockData, scheduleData, timecardData) for GC-efficient UI streaming via guihooks.trigger.

Key Dependencies

  • RallyEventLog - event logging
  • Penalties - time control penalty calculation
  • RoadSectionPenaltyKeeper - route deviation penalties
  • SpeedingDetector - speed limit enforcement
  • ScheduleUtils - time rounding utilities
  • RallySettings - NGRC mode detection

How It Works

  1. Init: Reads flowgraph variables → builds mission sequence → calculates full schedule with times → initializes clock in rally epoch
  2. Runtime: Clock advances each frame; penalty keepers and speeding detector update; UI data tables refreshed in-place
  3. Checkpoint: recordTimeCardEntry validates event match → calculates timing penalty → logs to event log → checks for start line rescheduling → updates timecard UI
  4. Mission transfer: startNextMission advances sequence index and calls startFromWithinMission for seamless transitions

Usage Example

-- Accessed via the rally loop flowgraph; not typically called directly
local mgr = rallyLoopManager  -- class instance

-- Check current state
if mgr:isInSpecialStage() then
  -- competitive stage, no speed limits
end

-- Record checkpoint arrival
mgr:recordTimeCardEntry("tc_waypoint_name", stageTimeSecs)

-- Get formatted rally time
local totalTime = mgr:formatStageTime(mgr:getTotalTime())

See Also

  • Rally Loop Penalties - Related reference
  • Rally Attempts - Related reference
  • Rally Event Log - Related reference
  • Gameplay Systems Guide - Guide

Rally Event Log

Class-based event logger for rally loop gameplay. Records all events (timecards, penalties, recoveries, flips) and maintains aggregated totals. Events are grouped by `eventGroup` for per-stage queryin

Road Section Penalty Keeper

Class-based tracker for rally liaison route deviation penalties. Monitors route recalculation frequency and applies escalating time penalties when the driver deviates from the prescribed road section

On this page

ConstructorPublic API (Key Methods)Lifecycle & StateMission SequencingClock & TimeSchedule & EventsPenalties & SpeedingFormattingInternalsMission SequenceSchedule CalculationEvent TypesData StreamingKey DependenciesHow It WorksUsage ExampleSee Also