Rally Schedule Utilities
Pure utility functions for rally loop scheduling and time calculations. Provides minute-boundary rounding, slot size conversion, and time comparison helpers.
Pure utility functions for rally loop scheduling and time calculations. Provides minute-boundary rounding, slot size conversion, and time comparison helpers.
Public API
| Function | Signature | Returns | Description |
|---|---|---|---|
M.roundToNextMinute | (timeSecs) | number | Rounds time up to next 60-second boundary |
M.slotMinutesToSeconds | (slotSizeMinutes) | number | Converts minutes to seconds (default 1 min = 60s) |
M.calculateNextSlotTime | (currentTime, slotSizeMinutes?, roundToMinute?) | number | Adds slot duration and optionally rounds to minute |
M.isLaterTime | (newTime, currentTime, tolerance?) | boolean | Checks if newTime > currentTime + tolerance |
Internals
roundToNextMinute
math.ceil(timeSecs / 60) * 60Always rounds up. E.g., 61 → 120, 60 → 60, 59 → 60.
calculateNextSlotTime
Combines slot addition with optional minute rounding:
local newTime = currentTime + (slotSizeMinutes * 60)
if roundToMinute then
newTime = roundToNextMinute(newTime)
endDefault: slotSizeMinutes = 1, roundToMinute = true.
isLaterTime
Simple comparison with optional tolerance buffer:
return newTime > (currentTime + tolerance)How It Works
These are stateless helper functions used by rallyLoopManager for schedule calculation:
- Rounding TC and SS start times to minute boundaries
- Computing next available time slots
- Checking whether rescheduled times are actually later than originals
Usage Example
local ScheduleUtils = require('gameplay/rally/loop/scheduleUtils')
-- Round to next minute
local nextMin = ScheduleUtils.roundToNextMinute(125) -- 180
-- Calculate next 2-minute slot
local nextSlot = ScheduleUtils.calculateNextSlotTime(100, 2) -- 240 (rounded)
-- Check if rescheduled time is actually later
if ScheduleUtils.isLaterTime(newTime, oldTime, 5) then
-- apply reschedule
endSee Also
- Rally Loop Penalties - Related reference
- Rally Attempts - Related reference
- Rally Event Log - Related reference
- Gameplay Systems Guide - Guide
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
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