local font = "electronic_highway_sign" local fontSize = vec2(42, 58) local textColor = rgbm(1, 1, 1, 1) local bestTime = 0 local bestTimeSet = false local isRace = false local raceStartTime = -1.0 local function formatBestTime(ms) if ms > 0 then local minutes = math.floor(ms / 60000) local seconds = math.floor((ms / 1000) % 60) local millis = math.floor(ms % 1000) return string.format("%d:%02d.%03d", minutes, seconds, millis) else return "--.---" end end local function formatRaceTime(seconds) local total = math.floor(seconds) local h = math.floor(total / 3600) local m = math.floor((total % 3600) / 60) local s = total % 60 return string.format("%d:%02d:%02d", h, m, s) end function update(dt) local sim = ac.getSim() isRace = sim.raceSessionType == 3 and sim.isSessionStarted local timeText = "" if isRace then if raceStartTime == -1.0 then raceStartTime = sim.currentSessionTime / 1000 end local elapsedTime = sim.currentSessionTime / 1000 - raceStartTime timeText = formatRaceTime(elapsedTime) else raceStartTime = -1.0 local leader = ac.getCar.leaderboard(0) if leader and leader.bestLapTimeMs > 0 then bestTime = leader.bestLapTimeMs bestTimeSet = true end timeText = formatBestTime(bestTimeSet and bestTime or 0) end display.text{ pos = vec2(10, 4), letter = fontSize, text = timeText, font = font, spacing = -9, color = textColor } end