summaryrefslogtreecommitdiff
path: root/scripts/gugus
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/gugus')
-rw-r--r--scripts/gugus/digits.lua376
-rw-r--r--scripts/gugus/functions.lua584
2 files changed, 960 insertions, 0 deletions
diff --git a/scripts/gugus/digits.lua b/scripts/gugus/digits.lua
new file mode 100644
index 0000000..27bde1d
--- /dev/null
+++ b/scripts/gugus/digits.lua
@@ -0,0 +1,376 @@
+
+require("scripts/gugus/functions")
+
+-- ============================================================
+-- Left and Right Panel functions
+-- ============================================================
+
+-----------------------
+-- left : 0.0.0:00:0 --
+-- right: 0:00.0.0:0 --
+-----------------------
+
+function leftDigitsEvent(swFunction)
+ lPanel = DigitsEvent(swFunction, "L")
+ if lPanel == nil then lPanel = "-.--.---" end
+ SetLeftDigits( lPanel )
+ return 1
+end
+function rightDigitsEvent(swFunction)
+ rPanel = DigitsEvent(swFunction, "R")
+ if rPanel == nil then rPanel = "-:--.---" end
+ SetRightDigits( rPanel )
+ return 1
+end
+
+function DigitsEvent(swFunction, where)
+ local swValue = swFunction + 1
+ local displaylaptime = GetContextInfo("displaylaptime")
+ local displaysectorsplit = mSectorSplit < GetTicks()
+
+ local lr = ""
+ if where == "R" then
+ lr = "."
+ else
+ lr = ":"
+ end
+
+ local Output = nil
+
+ qi = GetContextInfo("quickinfobutton")
+ if qi then
+ -- 1.speed [ 3.rpm/gear ]
+ if swValue == 1 then qi = false ; swValue = 3
+ -- 8.laps/total [ 9.remaining laps / total ]
+ elseif swValue == 8 then qi = false ; swValue = 9
+ elseif swValue == 9 then qi = false ; swValue = 8
+ -- 11.fuel/speed [ 12.fuel / remaining laps with fuel ]
+ elseif swValue == 11 then qi = false ; swValue = 12
+ -- 13.water temp [ 14.oil temp ]
+ elseif swValue == 13 then qi = false ; swValue = 14
+ elseif swValue == 14 then qi = false ; swValue = 13
+ -- lap/sector times
+ -- 36.current lap time [ 39.last lap time ]
+ elseif swValue == 36 then qi = false ; swValue = 39
+ -- 38.current lap time + best sector splits [ current sector time ]
+ elseif swValue == 37 then qi = false ; swValue = 47
+ -- 39.best lap time [ virtual best lap time ]
+ elseif swValue == 38 then qi = false ; swValue = 52
+ elseif swValue == 39 then qi = false ; swValue = 49
+ elseif swValue == 40 then qi = false ; swValue = 49
+ elseif swValue == 41 then qi = false ; swValue = 47
+ elseif swValue == 45 then qi = false ; swValue = 49
+ elseif swValue == 46 then qi = false ; swValue = 49
+ elseif swValue == 47 then qi = false ; swValue = 49
+ elseif swValue == 48 then qi = false ; swValue = 47
+ end
+ end
+ local NotQI = qi == false
+
+ -- 1.speed [ rpm/gear ]
+ if swValue == 1 then
+ Output = GetString("speed", where)
+
+ -- 2.rpm
+ elseif swValue == 2 then
+ Output = GetString("rpm", where)
+
+ -- 3.rpm/gear
+ elseif swValue == 3 then
+ Output = GetString("rpm", where .. "l") .. ":" .. GetString("gear", where .. "r")
+
+ -- 4.position/speed
+ elseif swValue == 4 then
+ Output = GetString("position", where .. "l") .. lr.. GetString("speed", where .. "r")
+
+ -- 5.sector/speed
+ elseif swValue == 5 then
+ Output = GetString("sector", where .. "l") .. lr .. GetString("speed", where .. "r")
+
+ -- 6.laps/sector
+ elseif swValue == 6 then
+ Output = GetString("laps", where .. "l") .. lr .. GetString("sector", where .. "r")
+
+ -- 7.laps/position
+ elseif swValue == 7 then
+ Output = GetString("laps", where .. "l") .. lr .. GetString("position", where .. "r")
+
+ -- 8.laps/total [ remaining laps / total ]
+ elseif swValue == 8 then
+ Output = GetString("laps", where .. "l") .. lr .. GetString("totallaps", where .. "r")
+
+ -- 9.remaining laps/total [ laps / total ]
+ elseif swValue == 9 then
+ Output = GetString("remaininglaps", where .. "l") .. lr .. GetString("totallaps", where .. "r")
+
+ -- 10.fuel
+ elseif swValue == 10 then
+ Output = GetString("fuel", where)
+
+ -- 11.fuel/speed
+ elseif swValue == 11 then
+ Output = GetString("fuel", where .. "l") .. lr .. GetString("speed", where .. "r")
+
+ -- 12.fuel/remaining laps with fuel
+ elseif swValue == 12 then
+ Output = GetString("fuel", where .. "l") .. lr .. GetString("remaininglapsintank", where .. "r")
+
+ -- 13.water temp [ oil temp ]
+ elseif swValue == 13 then
+ Output = GetString("watertemp", where)
+
+ -- 14.oil temp [ water temp ]
+ elseif swValue == 14 then
+ Output = GetString("oiltemp", where)
+
+ -- 15.wheels temp FL [ RL ]
+ elseif swValue == 15 then
+ if NotQI then
+ Output = GetString("wtfl", where)
+ else
+ Output = GetString("wtrl", where)
+ end
+
+ -- 16.wheels temp FR [ RR ]
+ elseif swValue == 16 then
+ if NotQI then
+ Output = GetString("wtfr", where)
+ else
+ Output = GetString("wtrr", where)
+ end
+
+ -- 17.wheels temp L/R FRONT [ L/R REAR ]
+ elseif swValue == 17 then
+ if NotQI then
+ Output = GetString("wtfl", where .. "l") .. lr .. GetString("wtfr", where .. "r")
+ else
+ Output = GetString("wtrl", where .. "l") .. lr .. GetString("wtrr", where .. "r")
+ end
+
+ -- 18.wheels temp L/R FRONT [ wheels press L/R FRONT ]
+ elseif swValue == 18 then
+ if NotQI then
+ Output = GetString("wtfl", where .. "l") .. lr .. GetString("wtfr", where .. "r")
+ else
+ Output = GetString("wpfl", where .. "l") .. lr .. GetString("wpfr", where .. "r")
+ end
+
+ -- 19.wheels temp L/R REAR [ wheels press L/R REAR ]
+ elseif swValue == 19 then
+ if NotQI then
+ Output = GetString("wtrl", where .. "l") .. lr .. GetString("wtrr", where .. "r")
+ else
+ Output = GetString("wprl", where .. "l") .. lr .. GetString("wprr", where .. "r")
+ end
+
+ -- 20.wheels/brake temp left FRONT [ REAR ]
+ elseif swValue == 20 then
+ if NotQI then
+ Output = GetString("wtfl", where .. "l") .. lr .. GetString("btfl", where .. "r")
+ else
+ Output = GetString("wtrl", where .. "l") .. lr .. GetString("btrl", where .. "r")
+ end
+
+ -- 21.brake/wheels temp right FRONT [ REAR ]
+ elseif swValue == 21 then
+ if NotQI then
+ Output = GetString("btfr", where .. "l") .. lr .. GetString("wtfr", where .. "r")
+ else
+ Output = GetString("btrr", where .. "l") .. lr .. GetString("wtrr", where .. "r")
+ end
+
+ -- 22.wheels temp FL/ press FL [ RL/RL ]
+ elseif swValue == 22 then
+ if NotQI then
+ Output = GetString("wtfl", where .. "l") .. lr .. GetString("wpfl", where .. "r")
+ else
+ Output = GetString("wtrl", where .. "l") .. lr .. GetString("wprl", where .. "r")
+ end
+
+ -- 23.wheels press FR/ temp FR [ RR/RR ]
+ elseif swValue == 23 then
+ if NotQI then
+ Output = GetString("wpfr", where .. "l") .. lr .. GetString("wtfr", where .. "r")
+ else
+ Output = GetString("wprr", where .. "l") .. lr .. GetString("wtrr", where .. "r")
+ end
+
+ -- 24.wheels press FL [ RL ]
+ elseif swValue == 24 then
+ if NotQI then
+ Output = GetString("wpfl", where)
+ else
+ Output = GetString("wprl", where)
+ end
+
+ -- 25.wheels press FR [ RR ]
+ elseif swValue == 25 then
+ if NotQI then
+ Output = GetString("wpfr", where)
+ else
+ Output = GetString("wprr", where)
+ end
+
+ -- 26.wheels press L/R FRONT [ L/R REAR ]
+ elseif swValue == 26 then
+ if NotQI then
+ Output = GetString("wpfl", where .. "l") .. lr .. GetString("wpfr", where .. "r")
+ else
+ Output = GetString("wprl", where .. "l") .. lr .. GetString("wprr", where .. "r")
+ end
+
+ -- 27.brakes temp FL [ RL ]
+ elseif swValue == 27 then
+ if NotQI then
+ Output = GetString("btfl", where)
+ else
+ Output = GetString("btrl", where)
+ end
+
+ -- 28.brakes temp FR [ RR ]
+ elseif swValue == 28 then
+ if NotQI then
+ Output = GetString("btfr", where)
+ else
+ Output = GetString("btrr", where)
+ end
+
+ -- 29.brakes temp L/R FRONT [ L/R REAR ]
+ elseif swValue == 29 then
+ if NotQI then
+ Output = GetString("btfl", where .. "l") .. lr .. GetString("btfr", where .. "r")
+ else
+ Output = GetString("btrl", where .. "l") .. lr .. GetString("btrr", where .. "r")
+ end
+
+ -- 30.track percent [ track size ]
+ elseif swValue == 30 then
+ if NotQI then
+ Output = GetString("trackpercent", where)
+ else
+ Output = GetString("tracksize", where)
+ end
+
+ -- 31.total distance
+ elseif swValue == 31 then
+ Output = GetString("distance", where)
+
+ -- 32.kers
+ elseif swValue == 32 then
+
+ -- 33.kers max
+ elseif swValue == 33 then
+
+ -- 34.kers percent
+ elseif swValue == 34 then
+
+ -- 35.drs
+ elseif swValue == 35 then
+
+ -- 36.current lap time [ last lap time ]
+ elseif swValue == 36 then
+ Output = GetTimeString("laptime", where)
+
+ -- 37.current lap time + sector splits [ current sector time ]
+ elseif swValue == 37 then
+ if displaysectorsplit == false then
+ Output = GetTimeString("laptime", where)
+ else
+ Output = GetTimeString("lastsectorsplitVSlast", where)
+ end
+
+ -- 38.current lap time + best sector splits [ current sector time ]
+ elseif swValue == 38 then
+ if displaysectorsplit == false then
+ Output = GetTimeString("laptime", where)
+ else
+ Output = GetTimeString("lastsectorsplitVSbest", where)
+ end
+
+ -- 39.best lap time [ virtual best lap time ]
+ elseif swValue == 39 then
+ Output = GetTimeString("bestlaptime", where)
+
+ -- 40.best lap time + best sector splits [ virtual best lap time ]
+ elseif swValue == 40 then
+ if displaysectorsplit == false then
+ Output = GetTimeString("bestlaptime", where)
+ else
+ Output = GetTimeString("lastsectorsplitVSbest", where)
+ end
+
+ -- 41.last lap time [ last sector ]
+ elseif swValue == 41 then
+
+ -- 42.last lap time + sector splits [ last sector ]
+ elseif swValue == 42 then
+
+ -- 43.real time diff vs best [ bestlap time ]
+ elseif swValue == 43 then
+
+ -- 44.real time diff vs best + best sector split [ best sector time ]
+ elseif swValue == 44 then
+
+ -- 45.real time diff vs best + bestlap sector split [ bestlap sector time ]
+ elseif swValue == 45 then
+
+ -- 46.real time diff vs last [ last lap time ]
+ elseif swValue == 46 then
+
+ -- 47.real time diff vs last + sector split [ last sector time ]
+ elseif swValue == 47 then
+
+ -- 48.last sector time [ last sector best time ]
+ elseif swValue == 48 then
+ Output = GetTimeString("lastsector", where)
+
+ -- 49.sector split [ last sector time ]
+ elseif swValue == 49 then
+
+ -- 50.last sector best time
+ elseif swValue == 50 then
+ Output = GetTimeString("lastsectorbest", where)
+
+ -- 51.best sector split [ best sector time ]
+ elseif swValue == 51 then
+ Output = GetTimeString("lastsectorsplitVSbest", where)
+
+ -- 52.virtual best lap time (best sectors) [ best lap time ]
+ elseif swValue == 52 then
+ Output = GetTimeString("virtualbestlap", where)
+
+ -- 53.time remaining [ time elapsed ]
+ elseif swValue == 53 then
+ Output = GetTimeString("timeremaining", where)
+
+ -- 54.time elapsed [ time remaining ]
+ elseif swValue == 54 then
+ Output = GetTimeString("timeelapsed", where)
+
+ -- 55.system time
+ elseif swValue == 55 then
+ Output = GetTimeString("clock", where)
+
+ -- 56.PIT
+ elseif swValue == 56 then
+ if GetContextInfo("inpits") then
+ Output = " Pits "
+ else
+ Output = " "
+ end
+
+ -- 57.Safety Car
+ elseif swValue == 57 then
+ if GetContextInfo("safetycar") then
+ Output = "Safety"
+ else
+ Output = " "
+ end
+
+ end
+
+ return Output
+end
+
+
+print ( "gugus> + slipro digits" )
diff --git a/scripts/gugus/functions.lua b/scripts/gugus/functions.lua
new file mode 100644
index 0000000..81ffcf6
--- /dev/null
+++ b/scripts/gugus/functions.lua
@@ -0,0 +1,584 @@
+-- ============================================================
+-- Left and Right Panel functions
+-- ============================================================
+
+--require ("scripts/gugus/sector.lua")
+
+ --------------------------------
+ -- 0.0.0:00:0 [0.] 0:00.0.0:0 --
+ -- Ll : Lr [0.] Rl . Rr --
+ -- L [0.] R --
+ --------------------------------
+
+mDebug = GetTicks()
+
+function GetWheelTemp(what)
+ local sim = GetContextInfo("simulation")
+ local unit = GetContextInfo("speedmetric")
+
+ local temp = 0
+ if what == "wtfl" then temp = GetCarInfo("wheeltempfrontleft")
+ elseif what == "wtfr" then temp = GetCarInfo("wheeltempfrontright")
+ elseif what == "wtrr" then temp = GetCarInfo("wheeltemprearright")
+ elseif what == "wtrl" then temp = GetCarInfo("wheeltemprearleft")
+ elseif what == "btfl" then temp = GetCarInfo("braketempfrontleft")
+ elseif what == "btfr" then temp = GetCarInfo("braketempfrontright")
+ elseif what == "btrr" then temp = GetCarInfo("braketemprearright")
+ elseif what == "btrl" then temp = GetCarInfo("braketemprearleft")
+ end
+
+ if isAppRFactor(sim) or sim == "GTR2.exe" then temp = KtoC(temp) end
+ -- convert from C to K if needed
+ return GetTemp(temp, unit)
+end
+
+function GetWheelPressure(what)
+
+ local press = 0
+ if what == "wpfl" then press = GetCarInfo("wheelpressfrontleft")
+ elseif what == "wpfr" then press = GetCarInfo("wheelpressfrontright")
+ elseif what == "wprr" then press = GetCarInfo("wheelpressrearright")
+ elseif what == "wprl" then press = GetCarInfo("wheelpressrearleft")
+ end
+
+ return press / 6.88
+end
+
+function GetString(what, where)
+ -- where should be one of : L, R, Ll, Lr, Rl, Rr
+
+ local fullSize = false
+ if where == "R" or where == "L" then fullSize = true end
+
+ local Output = " "
+ if fullSize then Output = " " end
+
+ -- GENERAL
+
+ -- speed
+ if what == "speed" then
+ if fullSize then
+ Output = string.format(" %3d", GetCarInfo("speed"))
+ else
+ Output = string.format("%3d", GetCarInfo("speed"))
+ end
+ -- rpm
+ elseif what == "rpm" then
+ if fullSize then
+ Output = string.format(" %5d", GetCarInfo("rpm"))
+ else
+ Output = string.format("%5d", GetCarInfo("rpm"))
+ end
+ -- gear
+ elseif what == "gear" then
+ Output = string.format("%d", GetCarInfo("gear"))
+ elseif what == "pos" then
+ Output = string.format("P%02d", GetContextInfo("position"))
+ -- sector
+ elseif what == "sector" then
+ if where == "Ll" or where == "Rl" then
+ Output = string.format("S%1d ", GetCarInfo("sector"))
+ elseif where == "Lr" or where == "Rr" then
+ Output = string.format(" S%1d", GetCarInfo("sector"))
+ else -- fullSize
+ Output = string.format(" S%1d ", GetCarInfo("sector"))
+ end
+
+ -- LAPS
+ -- laps completed
+ elseif what == "laps" then
+ local laps = GetContextInfo("laps")
+ if fullSize then
+ Output = string.format("L %3d ", laps)
+ else
+ if laps > 99 then
+ Output = string.format("%03d", laps)
+ else
+ Output = string.format("L%02d", laps)
+ end
+ end
+ -- total laps
+ elseif what == "totallaps" then
+ local totallaps = GetContextInfo("lapscount")
+ if fullSize then
+ if totallaps ~= 0 then
+ Output = string.format("t %3d ", totallaps)
+ else
+ Output = "t -- "
+ end
+ else
+ if totallaps > 99 then
+ Output = string.format("%03d", totallaps)
+ elseif totallaps ~= 0 then
+ Output = string.format("t%02d", totallaps)
+ else
+ Output = "t--"
+ end
+ end
+ -- remaining laps
+ elseif what == "remainlaps" then
+ tl = GetContextInfo("lapscount")
+ l = GetContextInfo("laps")
+ if fullSize then
+ if tl ~= 0 then
+ Output = string.format("r %3d ", tl - l)
+ else
+ Output = "r -- "
+ end
+ else
+ if tl ~= 0 then
+ Output = string.format("r%03d", tl - l)
+ else
+ Output = "r--"
+ end
+ end
+
+ -- FUEL
+ -- fuel
+ elseif what == "fuel" then
+ fuel = GetFuel(GetCarInfo("fuel"), GetContextInfo("speedmetric"))
+ if fullSize then
+ if fuel >= 100 then
+ Output = string.format ( "F. %4d", fuel )
+ elseif fuel >= 10 then
+ Output = string.format ( "F. %2.1f", fuel )
+ else
+ Output = string.format ( "F. %1.1f", fuel )
+ end
+ else
+ if fuel >= 100 then
+ -- specific for euro truck :)
+ if fuel >= 999 then
+ Output = "999"
+ else
+ Output = string.format("%03d", round(fuel) % 1000 )
+ end
+ elseif fuel >= 10 then
+ Output = string.format("F%2d", math.floor(fuel) )
+ elseif fuel >= 1 then
+ if where == "Rl" then
+ -- no dot after second digit
+ Output = string.format("F %d", fuel )
+ else
+ Output = string.format("F%1.1f", fuel )
+ end
+ else
+ if where == "Lr" then
+ -- no dot after first digit..
+ Output = string.format("F .%d", fuel * 100 )
+ else
+ Output = string.format("F.%02d", fuel * 100 )
+ end
+ end
+ end
+ -- remaining laps with fuel
+ elseif what == "remainlapswithfuel" then
+ local rl = GetCarInfo("remainlapsintank")
+ if rl ~= 0 then
+ if rl > 99 then
+ Output = "r99"
+ else
+ Output = string.format("r%02d", GetCarInfo("remainlapsintank"))
+ end
+ else
+ Output = "r--"
+ end
+
+
+ -- ENGINE TEMP
+ -- water temp
+ elseif what == "water" then
+ wt = GetTemp(GetCarInfo("watertemp"), GetContextInfo("speedmetric"))
+ if fullSize then
+ Output = string.format("w %3d°", wt)
+ else
+ Output = string.format("%3d", wt)
+ end
+ -- oil temp
+ elseif what == "oil" then
+ oil = GetTemp(GetCarInfo("oiltemp"), GetContextInfo("speedmetric"))
+ if fullSize then
+ Output = string.format("o %3d°", oil)
+ else
+ Output = string.format("%3d", oil)
+ end
+
+
+ -- WHEEL TEMP
+ -- WHEEL PRESS
+ -- BRAKE TEMP
+ elseif what == "wtfl" or what == "wtfr" or what == "wtrl" or what == "wtrr"
+ or what == "btfl" or what == "btfr" or what == "btrl" or what == "btrr" then
+ if fullSize then
+ Output = string.format("%s.%3d", what, GetWheelTemp(what))
+ else
+ Output = string.format("%3d", GetWheelTemp(what))
+ end
+
+ elseif what == "wpfl" or what == "wpfr" or what == "wprl" or what == "wprr" then
+ if fullSize then
+ Output = string.format("%s.%3d", what, GetWheelPressure(what))
+ else
+ Output = string.format("%3d", GetWheelPressure(what))
+ end
+
+ -- DISTANCES
+ -- track size
+ elseif what == "track" then
+ track = GetContextInfo("tracksize") / 1000
+ if fullSize then
+ Output = string.format(" %2.3f", track)
+ else
+ if track >= 10. then
+ if where ~= "Rl" then
+ Output = string.format("%2.1f", track)
+ else
+ Output = string.format(" %2d", track)
+ end
+ else
+ if where ~= "Lr" then
+ Output = string.format("%1.2f", track)
+ else
+ Output = string.format(" %1.1f", track)
+ end
+ end
+ end
+ -- total distance
+ elseif what == "trip" then
+ distance = GetContextInfo("lapdistance") / 1000
+ if fullSize then
+ Output = string.format(" %2.3f", distance)
+ else
+ if distance >= 10. then
+ if where ~= "Rl" then
+ Output = string.format("%2.1f", distance)
+ else
+ Output = string.format(" %2d", distance)
+ end
+ else
+ if where ~= "Lr" then
+ Output = string.format("%1.2f", distance)
+ else
+ Output = string.format(" %1.1f", distance)
+ end
+ end
+ end
+ -- track %
+ elseif what == "trackpercent" then
+ track = GetContextInfo("lapdistance")
+ distance = GetContextInfo("lapdistance")
+ progress = (distance % track) * 100 / track
+ if fullSize then
+ Output = string.format(" %3.1f", progress)
+ else
+ Output = string.format("%3d", progress)
+ end
+
+ --
+ -- Formula 1
+ --
+ -- kers
+ elseif swValue == 27 then Output = GetCarInfo("kers")
+ -- kers max
+ elseif swValue == 28 then Output = GetCarInfo("kersmax")
+ -- kers percent
+ elseif swValue == 29 then Output = round(GetCarInfo("kers") * 100 / GetCarInfo("kersmax"))
+
+ -- drs
+ elseif swValue == 30 then Output = GetCarInfo("drs")
+
+ -- PIT
+ elseif what == "inpit" then
+ Output = GetContextInfo("inpits")
+ -- Safety Car
+ elseif what == "safetycar" then
+ Output = GetCarInfo("safetycar")
+
+ end
+
+ return Output
+end
+
+function GetTimeString(what, where)
+ -- most commonly used vars
+ local time = nil
+ local splitTime = false
+ local Output = " "
+
+ local fullSize = where == "L" or where == "R"
+ if fullSize then Output = " " end
+
+ --
+ -- TIMES
+ --
+
+ -- current lap time
+ if what == "currentlap" then time = GetTimeInfo("laptime")
+ -- best lap time
+ elseif what == "bestlaptime" then time = GetTimeInfo("bestlaptime")
+ -- last lap time
+ elseif what == "lastlaptime" then time = GetTimeInfo("lastlaptime")
+
+ -- virtual best lap time (best sectors)
+ elseif what == "virtualbestlap" then
+ if mBestSectors[1] ~= 0 and mBestSectors[2] ~= 0 and mBestSectors[3] ~= 0 then
+ time = mBestSectors[1] + mBestSectors[2] + mBestSectors[3]
+ end
+
+ -- current sector (1, 2 and 3)
+ elseif what == "currentsector" then
+ time = GetSectorTime("", 0)
+ -- previous sector (3, 1 and 2)
+ elseif what == "lastsector" then
+ time = GetSectorTime("", -1)
+ -- previous best sector (3, 1 and 2)
+ elseif what == "lastsectorbest" then
+ time = GetSectorTime("BEST", -1)
+ -- lastlap sector (1, 2 and 3)
+ elseif what == "lastlapsector" then
+ time = GetSectorTime("last", 0)
+ -- bestlap sector (1, 2 and 3)
+ elseif what == "bestlapsector" then
+ time = GetSectorTime("best", 0)
+ -- sector split
+ elseif what == "bestsector" then
+ time = GetSectorTime("BEST", 0)
+ -- sector split
+ elseif what == "lastsectorsplitVSlast" then
+ time = GetSectorSplit("last", -1)
+ splitTime = true
+ -- best lap sector split
+ elseif what == "lastsectorsplitVSbestlap" then
+ time = GetSectorSplit("best", -1)
+ splitTime = true
+ -- best sector split
+ elseif what == "lastsectorsplitVSbest" then
+ time = GetSectorSplit("BEST", -1)
+ splitTime = true
+
+ elseif what == "currentsectorsplitVSlast" then
+ time = GetSectorSplit("last", 0)
+ splitTime = true
+ -- best lap sector split
+ elseif what == "currentsectorsplitVSbestlap" then
+ time = GetSectorSplit("best", 0)
+ splitTime = true
+ -- best sector split
+ elseif what == "currentsectorsplitVSbest" then
+ time = GetSectorSplit("BEST", 0)
+ splitTime = true
+
+ -- real time diff vs best
+ elseif what == "diffbest" then
+ time = GetTimeInfo("realdiffbest")
+ splitTime = true
+ -- real time diff vs last
+ elseif what == "difflast" then
+ time = GetTimeInfo("realdifflast")
+ splitTime = true
+
+ -- time remaining
+ elseif what == "timeremaining" then
+ time = GetTimeInfo("timeremaining")
+ -- time elapsed
+ elseif what == "timeelapsed" then
+ time = GetTimeInfo("timetotalelapsed")
+
+ -- system time
+ elseif what == "clock" then
+ time = GetTimeInfo("systemtime")
+ end
+
+
+ if what ~= clock then
+ Output = TimeToString(time, where, splitTime)
+ else
+ local hr, mn, sc, cs, ms = timeDispatcher(time)
+ Output = string.format( " %2d.%02d ", hr, mn)
+ end
+
+ if Output == nil then Output = "" end
+ ticks = GetTicks()
+ if mDebug ==nil or ticks < mDebug then
+ if time ~= nil then
+ if splitTime then
+ --print ("funct: ".. what.. " ["..where.."] -> " ..time.." =[split]= ".. Output )
+ else
+ --print ("funct: ".. what.. " ["..where.."] -> " ..time.." == ".. Output )
+ end
+ else
+
+ print ("funct: ".. what.. " ["..where.."] -> nil == ".. Output )
+ end
+ mDebug = ticks + 10000
+ end
+ return Output
+end
+
+function GetSectorTime(what, which)
+ local sector = GetCarInfo("sector") + which
+ if sector == 0 then sector = 3 end
+ local time = 0.
+
+ if what == "" and which == 0 then
+ time = GetTimeInfo("laptime")
+ if sector == 1 then time = time
+ elseif sector == 2 then time = time - GetTimeInfo("sector1")
+ elseif sector == 3 then time = time - GetTimeInfo("sector1") - GetTimeInfo("sector2")
+ end
+ elseif what == "BEST" then
+ time = mBestSectors[sector]
+ else
+ GetTimeInfo(string.format("%ssector%d", what, sector))
+ end
+ return time
+end
+
+function GetSectorSplit(what, which)
+ return GetSectorTime("", which) - GetSectorTime(what, which)
+end
+
+function TimeToString(time, where, splitTime)
+
+ local Output = "000"
+ if where == "R" or where == "L" then Output = "0.00.000" end
+
+ if time ~= nil then
+
+ local hr = 0
+ local mn = 0
+ local sc = 0
+ local cs = 0
+ local ms = 0
+
+ hr, mn, sc, cs, ms = timeDispatcher(time)
+
+ -- blinking second separator
+ local dot = "."
+ local colon = ":"
+ local min = "'"
+ --if cs >= 50 then
+ -- dot = ""
+ -- colon = "."
+ -- min = " "
+ --end
+
+ if splitTime == false then
+
+ if where == "R" or where == "L" then
+ if hr > 9 then
+ -- [L] HHH:MM:S
+ -- [R] HHH.MM:S
+ Output = string.format("%3d.%02d%s%d", hr, mn, colon, sc/10)
+ elseif hr > 0 then
+ if where == "R" then
+ -- [R] H:MM.SS.m
+ Output = string.format("%d:%02d%s%02d.%d", hr, mn, sc, cs/10)
+ else
+ -- [L] H.MM:SS.m
+ Output = string.format("%d.%02d:%02d.%d", hr, mn, sc, cs/10)
+ end
+ elseif mn > 0 then
+ --  MM.SS.m
+ Output = string.format(" %2d.%02d.%d", mn, sc, cs/10)
+ else
+ --  SS.mmm
+ Output = string.format(" %2d.%03d", sc, ms)
+ end
+
+ else
+ if hr > 0 then
+ -- HHh
+ Output = string.format("%2dh", hr)
+ elseif mn > 9 then
+ if where ~= "Rl" then
+ -- MM.S
+ Output = string.format("%2d%s%d", mn, dot, sc/10)
+ else
+ -- MM'
+ Output = string.format("%2d%s", mn, min)
+ end
+ elseif mn > 0 then
+ if where ~= "Lr" then
+ -- M.SS
+ Output = string.format("%d.%02d", mn, sc)
+ else
+ --  M:S
+ Output = string.format(" %d%s%d", mn, colon, sc)
+ end
+ else
+ if where ~= "Rl" then
+ -- SS.m
+ Output = string.format("%2d.%d", sc, cs/10)
+ else
+ if sc > 9 then
+ --  SS
+ Output = string.format(" %2d", sc)
+ else
+ -- S.mm
+ Output = string.format("%d.%02d", sc, cs)
+ end
+ end
+ end
+ end
+
+ else
+ -- splittimes --
+ if hr > 0 then
+ -- -HHhMM
+ Output = string.format("%3dh%02d", hr, mn)
+ elseif mn > 0 then
+ -- -MM.SS.m
+ Output = string.format("%3d.%02d.%d", mn, sc, cs/10)
+ else
+ -- -SS.mmm
+ Output = string.format("%3d.%03d", sc, ms)
+ end
+
+ end
+
+ else
+
+ if splitTime == false then
+
+ -- 0.0.0:00:0 [0.] 0:00.0.0:0 --
+ if where == "R" then
+ Output = "-:--.---"
+ elseif where == "L" then
+ Output = " -:--.-"
+ else
+ if where ~= "Rl" then
+ Output = "--.-"
+ else
+ Output = "-.--"
+ end
+ end
+
+ else
+ -- 0.0.0:00:0 [0.] 0:00.0.0:0 --
+ if where == "R" or where == "L" then
+ Output " --.---"
+ else
+ if where ~= "Rl" then
+ Output "--.-"
+ else
+ Output "-.--"
+ end
+ end
+
+ end
+ end
+
+ ticks = GetTicks()
+ if mDebug ==nil or ticks < mDebug then
+ if time == nil then time = "NIL" end
+ if Output == nil then Output = "NIL" end
+ print ( time .. " [" .. where .. "] " .. Output )
+ mDebug = ticks + 10000
+ end
+
+ return Output
+
+end
+
+print ( "gugus> + switch positions" )