local sim = ac.getSim() local mesh = ac.findMeshes('sign_lman_24hrs_lemans_001_diff') mesh:setMaterialProperty('ksEmissive', rgb(1, 1, 1)) local color1 = rgbm.colors.black local color2 = rgbm.colors.white -- local color3 = rgbm. local function delta(timestamp) if (timestamp==nil or timestamp <= 0) then return "--.---" end -- return string.format("%+.0f", timestamp/1000.0) return string.format("%+.1f", timestamp/1000.0) end local function laptime(timestamp) if (timestamp==nil or timestamp <= 0) then return "--.---" end --local function pad(n, z) z = z || 2; return ('00' + n).slice(-z); end local milliseconds = timestamp % 1000 timestamp = (timestamp - milliseconds) / 1000 local seconds = timestamp % 60 timestamp = (timestamp - seconds) / 60 local minutes = timestamp % 60 local hours = (timestamp - minutes) / 60 --local ms = tostring(milliseconds):pad(3, "0", -1) local ms = string.format("%03d", milliseconds) local ss = tostring(seconds):pad(2, "0", -1) local hh = tostring(hours):pad(2, "0", -1) local mm = tostring(minutes):pad(1, "0", -1) return mm..":"..ss -- if (hours > 0) then -- local mm = tostring(minutes):pad(1, "0", -1) -- return hh..":"..mm..":"..ss.."."..ms -- elseif (minutes > 0) then -- local mm = tostring(minutes):pad(1, "0", -1) -- return mm..":"..ss.."."..ms -- else -- local mm = tostring(minutes):pad(1, "0", -1) -- return mm..":"..ss.."."..ms -- end end local currID = 0 local Cyellow = rgbm(192/255,162/255,0, 1) local Cblue = rgbm(60/255,61/255,192/255, 1) local Cred = rgbm(192/255,0,0, 1) local Pyellow1 = vec2(5, 1) local Pyellow2 = vec2(5+1388/2, 1) local Pblue1 = vec2(147, 1) local Pblue2 = vec2(147+1388/2, 1) local Pblack1 = vec2(288, 1) local Pblack2 = vec2(288+1388/2, 1) local Pred1 = vec2(5, 132) local Pred2 = vec2(5+1388/2, 132) local Plivery1 = vec2((5), 132) -- local Plivery1 = vec2((688-4-192), 132) local Plivery2 = vec2(5 + 1388/2, 132) local Ryellow = vec2(140, 128) local Rblue = vec2(141, 128) local Rblack = vec2(406, 128) local Rred = vec2(688, 124) -- local font = 'clock_digits' -- local font = 'Arial' local vletsize1 = vec2(84, 192) local vletsize2 = vec2(64, 192) local vletsize3 = vec2(54, 192) local vletsize4 = vec2(28, 192) -- local vletsizeL = vec2(192, 192) local vletsizeL = vec2(128, 128) local vletsizeL2 = vec2(128+13, 128) local font = 'ArialBlack4' -- local vletsize1 = vec2(44, 92) -- local vletsize2 = vec2(24, 92) local vletp = vec2(0, 0) local first = true local mesh = ac.findMeshes('sign_lman_michelintotem_001_lightgeo_lod0tm_SUB2') mesh:applyShaderReplacements("PROP_...=offsetDSpeed,0.1,0") local seconds2wait = 5 local seconds = 0.0 local liveries = {} local mode = 0 function GetLivery(car) local skinname = ac.getCarSkinID(car.index) local carname = ac.getCarID(car.index).."_"..skinname for i=1, #liveries do if liveries[i]['name']==carname then return liveries[i]['livery'] end end local livfile="" if skinname~="" then livfile = ac.getFolder(ac.FolderID.ContentCars) .. '/' .. ac.getCarID(car.index) .. '/skins/' .. skinname .. "/livery.png" livfile = string.gsub(livfile, "\\", "/") if not io.fileExists(livfile) then ac.debug("livfile not found!!!!!!", skinname .. " .. ".. livfile) livfile="" else ac.debug("livfile found.", skinname .. " .. ".. livfile) end end table.insert(liveries, {['name']=carname, ['livery']=livfile}) return liveries[#liveries]['livery'] end function script.update(dt) local carcount=ac.getSim().carsCount -- display.rect({pos=Pyellow1, size=Ryellow, color=Cyellow }) -- display.rect({pos=Pyellow2, size=Ryellow, color=Cyellow }) seconds = seconds - dt if seconds<=0.0 then seconds = seconds2wait local posC = 0 local num = 1 if currID % 2 == 0 then -- clear if currID >= -1 then display.rect({pos=Pyellow1, size=Ryellow, color=Cyellow }) display.rect({pos=Pblue1, size=Rblue, color=Cblue }) display.rect({pos=Pblack1, size=Rblack, color=rgbm.colors.black }) display.rect({pos=Pred1, size=Rred, color=Cred }) end if currID == 0 and first then display.rect({pos=Pyellow2, size=Ryellow, color=Cyellow }) display.rect({pos=Pblue2, size=Rblue, color=Cblue }) display.rect({pos=Pblack2, size=Rblack, color=rgbm.colors.black }) display.rect({pos=Pred2, size=Rred, color=Cred }) if not first then posC = 0 num = 0 else end else if currID>0 then posC = 0 num = 0 end end else if currID==-1 then display.rect({pos=Pyellow1, size=Ryellow, color=Cyellow }) display.rect({pos=Pblue1, size=Rblue, color=Cblue }) display.rect({pos=Pblack1, size=Rblack, color=rgbm.colors.black }) display.rect({pos=Pred1, size=Rred, color=Cred }) else if currID~=0 then display.rect({pos=Pyellow2, size=Ryellow, color=Cyellow }) display.rect({pos=Pblue2, size=Rblue, color=Cblue }) display.rect({pos=Pblack2, size=Rblack, color=rgbm.colors.black }) display.rect({pos=Pred2, size=Rred, color=Cred }) end end if currID>0 then posC = 1 num = 0 end end -- if mode == 0 then if sim.raceFlagType==ac.FlagType.Caution or sim.raceFlagType==ac.FlagType.Ambulance then -- local teamName = "Safety Car!" -- local teamName = "FULL COURSE YELLOW" local teamName = "F C Y !" vletp.x=25 vletp.y=150-10 display.text{ pos=vletp, letter=vletsize4, text=teamName, font=font, spacing = 10, color = color2 } vletp.x=25+1388/2 vletp.y=150-10 display.text{ pos=vletp, letter=vletsize4, text=teamName, font=font, spacing = 10, color = color2 } -- elseif true then elseif sim.raceFlagType==ac.FlagType.Stop then local teamName = "BLACK FLAG !" vletp.x=25 vletp.y=150-10 display.text{ pos=vletp, letter=vletsize4, text=teamName, font=font, spacing = 10, color = color2 } vletp.x=25+1388/2 vletp.y=150-10 display.text{ pos=vletp, letter=vletsize4, text=teamName, font=font, spacing = 10, color = color2 } else local firstCar = ac.getCar.leaderboard(0) for carpos=currID, currID+num do local currcar = ac.getCar.leaderboard(carpos) local prevcar = nil if carpos>0 then prevcar = ac.getCar.leaderboard(carpos-1) end if firstCar and currcar and not (carpos==2 and currID==1 and first) then local teamName = currcar:driverTeam() -- string.upper(ac.getDriverTeam(carpos)) if not teamName or teamName == "" then teamName = currcar:driverName() end if string.find(teamName, "%(") then teamName = string.trim(string.split(teamName, "(")[1]) end if #teamName>17 then teamName = string.sub(teamName, 1, 17) end local lapT = " * "..laptime(currcar.bestLapTimeMs) if currcar.isInPit or currcar.isInPitlane then lapT = "-PITS-" elseif currcar.bestLapTimeMs<=0.0 or mode == 1 then lapT = "-leader-" if prevcar~=nil then -- local dist = currcar:getPosition():distance(firstCar:getPosition()) -- local dist = currcar.position:distance(prevcar.position) local dist = currcar.position:distance(firstCar.position) lapT = "-"..tostring(math.floor(dist)).. "m" -- lapT = " " .. delta(currcar.estimatedLapTimeMs - firstCar.estimatedLapTimeMs) -- lapT = laptime(car.lapTimeMs - lastCarLaptime) end end -- 1388x256 -- -- car-position local Scarpos = tostring(carpos+1) if #Scarpos>1 then vletp.x=16+(posC*1388/2) vletp.y=25-10 display.text{ pos=vletp, letter=vletsize3, text=Scarpos, font=font, spacing = 10, color = color1 } else vletp.x=27+(posC*1388/2) vletp.y=25-10 display.text{ pos=vletp, letter=vletsize1, text=Scarpos, font=font, spacing = 10, color = color1 } end -- livery or driver number -- if false then local img = GetLivery(currcar) if img~=nil and img~="" then vletp.x=27+(posC*1388/2)+128-8 vletp.y=1 if currID % 2 == 0 then -- display.image({image=img, pos=Plivery1, size=vletsizeL}) display.image({image=img, pos=vletp, size=vletsizeL2}) else -- display.image({image=img, pos=Plivery2, size=vletsizeL}) display.image({image=img, pos=vletp, size=vletsizeL2}) end else local drvnumber = tostring(currcar:driverNumber()) if #drvnumber==2 then vletp.x=27+(posC*1388/2)+135 vletp.y=25-10 display.text{ pos=vletp, letter=vletsize3, text=drvnumber, font=font, spacing = 10, color = color2 } elseif #drvnumber>2 then vletp.x=27+(posC*1388/2)+135 vletp.y=25-10 display.text{ pos=vletp, letter=vletsize4, text=drvnumber, font=font, spacing = 10, color = color2 } else vletp.x=27+(posC*1388/2)+158 vletp.y=25-10 display.text{ pos=vletp, letter=vletsize1, text=drvnumber, font=font, spacing = 10, color = color2 } end end -- best/delta time vletp.x=27+(posC*1388/2)+288 vletp.y=25-10 display.text{ pos=vletp, letter=vletsize4, text=lapT, font=font, spacing = 10, color = rgbm.colors.white } -- team name/ driver name vletp.x=25+(posC*1388/2) vletp.y=150-10 display.text{ pos=vletp, letter=vletsize4, text=teamName, font=font, spacing = 10, color = color2 } posC=posC+1 end prevcar = currcar end end if first then first = false currID = currID + 1 end currID = currID + 1 if currID>=carcount then currID = -1 first = true -- mode = mode+1 -- if mode>1 then -- mode = 0 -- end end ac.debug("currID", currID) end end