API ReferenceGE Extensionsgameplayrallyloop
Rally Loop Penalties
Calculates time control penalties for rally loop events. Determines if a driver arrived early, on-time, or late at a checkpoint and computes penalty amounts (+10 per minute deviation).
Calculates time control penalties for rally loop events. Determines if a driver arrived early, on-time, or late at a checkpoint and computes penalty amounts (+10 per minute deviation).
Public API
| Function | Signature | Returns | Description |
|---|---|---|---|
M.calculateEarlyPenalty | (minutesEarly) | number | Returns minutesEarly * 10 penalty |
M.calculateLatePenalty | (minutesLate) | number | Returns minutesLate * 10 penalty |
M.getTimingStatus | (actualTime, scheduledTime) | table | Evaluates timing and returns status with penalties |
Constants
| Field | Value | Description |
|---|---|---|
M.resetPenaltySeconds | 120 | Time penalty for vehicle reset (2 minutes) |
M.flipPenaltySeconds | 15 | Time penalty for vehicle flip |
Internals
getTimingStatus Return Table
{
status = "early"|"on-time"|"late",
totalPenalty = number, -- sum of all penalty amounts
hasPenalty = boolean,
penalties = { -- array of structured penalty objects
{
type = "time_control_early"|"time_control_late",
amount = number,
data = {
minutesEarly/minutesLate = number,
actualMinute = number,
scheduledMinute = number
}
}
}
}Timing Logic
- Converts both times to integer minutes via
math.floor(time / 60) - Early:
actualMinute < scheduledMinute→ penalty = |diff| × 10 - On-time:
actualMinute == scheduledMinute→ no penalty - Late:
actualMinute > scheduledMinute→ penalty = diff × 10 - If either time is
nil, returns "on-time" with zero penalty
How It Works
- Both actual and scheduled times are epoch seconds
- Integer minute comparison determines early/on-time/late
- Penalty is 10 seconds per minute of deviation (both early and late)
- Structured penalty data includes i18n-friendly fields for UI display
- Constants provide fixed penalties for reset (2 min) and flip (15s) events
Usage Example
local Penalties = require('gameplay/rally/loop/penalties')
-- Check arrival timing
local result = Penalties.getTimingStatus(actualEpochSecs, scheduledEpochSecs)
if result.hasPenalty then
log('W', '', 'Penalty: ' .. result.totalPenalty .. ' (' .. result.status .. ')')
end
-- Access penalty constants
local resetPenalty = Penalties.resetPenaltySeconds -- 120
local flipPenalty = Penalties.flipPenaltySeconds -- 15See Also
- Rally Attempts - Related reference
- Rally Event Log - Related reference
- Rally Loop Manager - Related reference
- Gameplay Systems Guide - Guide
Rally Driveline Utility
Utility constants for the rally driveline spline system. Provides default values for spline width, RDP simplification tolerance, and subdivision parameters.
Rally Attempts
Creates and saves mission attempt records for rally loop completions and DNFs. Integrates with the mission progress system to record timing data, vehicle info, and stage times.