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

Staged Countdown Test

Class-based test mode implementation for the staged countdown system. Simulates rally epoch timing and scheduled event scheduling without requiring a full rally loop manager. Used for testing countdow

Class-based test mode implementation for the staged countdown system. Simulates rally epoch timing and scheduled event scheduling without requiring a full rally loop manager. Used for testing countdown behavior in isolation.


Constructor

local StagedCountdownTest = require('gameplay/rally/loop/stagedCountdownTest')
local test = StagedCountdownTest()

Public API

MethodSignatureReturnsDescription
init()nilReads environment time, calculates initial scheduled event
calculateScheduledEventTime()nilSets next event to upcoming minute boundary (skips if <15s away)
reschedule(slotSizeMinutes, rescheduleCount, maxReschedules, defaultWarningTimes, warningsTriggered)success, newTimeReschedules to next minute boundary + slot offset
getWallClockTime()number|nilCurrent wall clock in seconds of day

Internals

State

FieldDescription
epochSimulated rally epoch time (starts at 0)
environmentStartTimeSecsEnvironment time of day converted to seconds
scheduledEventTimeNext event time in epoch seconds

Environment Time Conversion

Same formula as rallyLoopManager:

local timeIn24 = tod.time * 24
local adjustedHours = (timeIn24 + 12) % 24  -- noon = 0 in tod system
self.environmentStartTimeSecs = adjustedHours * 3600

Scheduling Logic

  1. Computes current wall clock: environmentStartTimeSecs + epoch
  2. Finds next minute boundary: math.ceil(currentWallClock / 60) * 60
  3. If less than 15 seconds until that boundary, skips to the minute after
  4. Converts back to epoch: targetWallClock - environmentStartTimeSecs

Rescheduling

When called by the countdown node after a reschedule request:

  1. Converts old scheduled time to wall clock
  2. Finds next minute boundary after old time
  3. Adds slotSizeMinutes * 60 seconds
  4. Converts back to epoch
  5. Marks any warning times that are already in the past as triggered

How It Works

  1. On init, reads core_environment.getTimeOfDay() to establish environment start time
  2. Calculates first scheduled event at the next comfortable minute boundary
  3. External code advances test.epoch each frame
  4. Countdown node reads test.scheduledEventTime and test.epoch to determine countdown state
  5. If reschedule is needed (vehicle not staged), calls reschedule() to push to next slot

Usage Example

local StagedCountdownTest = require('gameplay/rally/loop/stagedCountdownTest')
local test = StagedCountdownTest()

-- Simulate time advancement
test.epoch = test.epoch + dtSim

-- Check if event is approaching
local timeUntil = test.scheduledEventTime - test.epoch

-- Reschedule if needed
local ok, newTime = test:reschedule(1, 0, 3, {10, 5, 3}, {})

See Also

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

Speeding Detector

Class-based speed monitoring system for rally road sections. Samples vehicle speed into a ring buffer, computes a rolling average, and applies stochastic speeding penalties with configurable probabili

Staged Countdown Utilities

Shared utility functions for the staged countdown system. Provides debug drawing helpers (plane visualization, vehicle-to-plane distance, vehicle point), vehicle freeze/unfreeze controls, and ImGui de

On this page

ConstructorPublic APIInternalsStateEnvironment Time ConversionScheduling LogicReschedulingHow It WorksUsage ExampleSee Also