summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugues Hiegel <hugues@hiegel.fr>2013-11-17 23:46:08 +0100
committerHugues Hiegel <hugues@hiegel.fr>2013-11-17 23:46:08 +0100
commit50436f4dc922373308d516115623f3bbc16c1cf9 (patch)
tree8272ba8f22720b0d7fd56d5b46701c308b0e45fd
parent5e8011c396600204ed1ae4fe88d29218988d5da5 (diff)
[gugus] slipro scripts cleanup
-rw-r--r--scripts/controls.lua2
-rw-r--r--scripts/gugus/sliproDigits.lua338
2 files changed, 174 insertions, 166 deletions
diff --git a/scripts/controls.lua b/scripts/controls.lua
index de6b889..bef952b 100644
--- a/scripts/controls.lua
+++ b/scripts/controls.lua
@@ -44,7 +44,7 @@ function controlsEvent(deviceType, ctrlType, ctrlPos, value, funcIndex, targetDe
local oldTcks = GetTicks()
- local delay = 600
+ local delay = 333
if funcIndex ~= -1 then
if IsSLIFunction("maxgear", funcIndex) and mMaxGearFeedbackAllowed then
-- max gear switch
diff --git a/scripts/gugus/sliproDigits.lua b/scripts/gugus/sliproDigits.lua
index bcc205b..7a155ec 100644
--- a/scripts/gugus/sliproDigits.lua
+++ b/scripts/gugus/sliproDigits.lua
@@ -2,7 +2,7 @@
-- Left and Right Panel functions
-- ============================================================
-function custom_leftDigitsEvent(swFunction)
+function leftDigitsEvent(swFunction)
swValue = swFunction + 1
local lPanel = ""
@@ -40,7 +40,7 @@ function custom_leftDigitsEvent(swFunction)
-- get current simulation name
local sim = GetContextInfo("simulation")
- --print ( "swValue: " .. swValue .. "\n")
+ --print ( "swValue: " .. swValue )
-- check postion and compute left panel string
if swValue == 1 then
@@ -60,7 +60,7 @@ function custom_leftDigitsEvent(swFunction)
elseif fuel >= 1 then
lPanel = string.format("F%1.1f:%3.0f", fuel, spd)
else
- lPanel = string.format("F.%2d:%3.0f", fuel * 100, spd)
+ lPanel = string.format("F.%02d:%3.0f", fuel * 100, spd )
end
end
elseif swValue == 3 then
@@ -102,11 +102,19 @@ function custom_leftDigitsEvent(swFunction)
local tl = GetContextInfo("lapscount")
if tl < 1 then tl = 0 end
-- if more than 99 laps
- if inf >= 100 or tl >= 100 then
- lPanel = string.format("%03d:%03d", inf, tl)
+ local laps
+ local total
+ if inf >= 100 then
+ laps = string.format("%03d", inf )
+ else
+ laps = string.format("L%02d", inf)
+ end
+ if tl >= 100 then
+ total = string.format("%03d", tl)
else
- lPanel = string.format("L%02d:t%02d", inf, tl)
+ total = string.format("t%02d", tl)
end
+ lPanel = laps .. ":" .. total
end
elseif swValue == 7 then
-- water temp
@@ -163,9 +171,9 @@ function custom_leftDigitsEvent(swFunction)
lPanel = string.format("PFr:%2.1f", inf / 6.88)
end
elseif swValue == 15 then
- inf = getcarinfo("wheelpressrearleft")
+ inf = GetCarInfo("wheelpressrearleft")
if inf ~= nil then
- lpanel = string.format("prl:%2.1f", inf / 6.88)
+ lPanel = string.format("PrL:%2.1f", inf / 6.88)
end
elseif swValue == 16 then
inf = GetCarInfo("wheelpressrearright")
@@ -240,16 +248,16 @@ function custom_leftDigitsEvent(swFunction)
end
if remainlapsintank == 0 then
- sRemainLaps = " "
+ sRemainLaps = "L--"
elseif remainlapsintank >= 100 then
- sRemainLaps = ":L99"
+ sRemainLaps = "L99"
elseif remainlapsintank >= 10 then
- sRemainLaps = string.format(":L%2d", math.floor(remainlapsintank))
- else
- sRemainLaps = string.format(":L%1.1f", remainlapsintank)
+ sRemainLaps = string.format("L%02d", math.floor(remainlapsintank))
+ elseif remainlapsintank >= 10 then
+ sRemainLaps = string.format("L%1.1f", remainlapsintank)
end
- lPanel = string.format("%s%s", sFuel, sRemainLaps)
+ lPanel = sFuel .. ":" .. sRemainLaps
end
elseif swValue == 26 then
@@ -330,7 +338,7 @@ end
-function custom_rightDigitsEvent(swFunction)
+function rightDigitsEvent(swFunction)
swValue = swFunction + 1
local hr = 0
@@ -384,7 +392,7 @@ function custom_rightDigitsEvent(swFunction)
end
end
- --print ( "swValue: " .. swValue .. "\n")
+ --print ( "swValue: " .. swValue )
-- get sim name
local sim = GetContextInfo("simulation")
@@ -404,27 +412,27 @@ function custom_rightDigitsEvent(swFunction)
local ts = GetContextInfo("partialcount")
local sector = GetCarInfo("sector")
if ts ~= nil and ts > 0 then
- if swValue == 4 then
- lpt = GetPartialTimeInfo("currentpartial", sector)
- elseif swValue == 5 then
- diffFlag = true
- lpt = GetPartialTimeInfo("vsbestlap", sector)
- elseif swValue == 6 then
- diffFlag = true
- lpt = GetPartialTimeInfo("vsoptimallap", sector)
- elseif swValue == 7 then
- diffFlag = true
- lpt = GetPartialTimeInfo("vsoptimalsector", sector)
- elseif swValue == 8 then
- diffFlag = true
- lpt = GetPartialTimeInfo("vssessionbestlap", sector)
- elseif swValue == 9 then
- diffFlag = true
- lpt = GetPartialTimeInfo("vssessionoptimallap", sector)
- elseif swValue == 10 then
- diffFlag = true
- lpt = GetPartialTimeInfo("vssessionoptimalsector", sector)
- end
+ if swValue == 4 then
+ lpt = GetPartialTimeInfo("currentpartial", sector)
+ elseif swValue == 5 then
+ diffFlag = true
+ lpt = GetPartialTimeInfo("vsbestlap", sector)
+ elseif swValue == 6 then
+ diffFlag = true
+ lpt = GetPartialTimeInfo("vsoptimallap", sector)
+ elseif swValue == 7 then
+ diffFlag = true
+ lpt = GetPartialTimeInfo("vsoptimalsector", sector)
+ elseif swValue == 8 then
+ diffFlag = true
+ lpt = GetPartialTimeInfo("vssessionbestlap", sector)
+ elseif swValue == 9 then
+ diffFlag = true
+ lpt = GetPartialTimeInfo("vssessionoptimallap", sector)
+ elseif swValue == 10 then
+ diffFlag = true
+ lpt = GetPartialTimeInfo("vssessionoptimalsector", sector)
+ end
else
lpt = 0.0
end
@@ -444,15 +452,15 @@ function custom_rightDigitsEvent(swFunction)
local sector = GetCarInfo("sector")
local lt = GetTimeInfo("laptime")
if sector == 1 then
- lpt = lt
+ lpt = lt
elseif sector == 2 then
- local s1 = GetTimeInfo("lastsector1")
- lpt = lt - s1
+ local s1 = GetTimeInfo("lastsector1")
+ lpt = lt - s1
else
- -- sector 3
- local s1 = GetTimeInfo("lastsector1")
- local s2 = GetTimeInfo("lastsector2")
- lpt = lt - (s1 + s2)
+ -- sector 3
+ local s1 = GetTimeInfo("lastsector1")
+ local s2 = GetTimeInfo("lastsector2")
+ lpt = lt - (s1 + s2)
end
elseif swValue == 14 then
-- best sector 1
@@ -470,9 +478,9 @@ function custom_rightDigitsEvent(swFunction)
-- position
local pos = GetContextInfo("position")
if pos >= 100 then
- rPanel = string.format(" P%03d ", pos )
+ rPanel = string.format(" P%03d ", pos )
else
- rPanel = string.format(" P%02d ", pos )
+ rPanel = string.format(" P%02d ", pos )
end
SetRightDigits( rPanel )
return 1
@@ -495,15 +503,15 @@ function custom_rightDigitsEvent(swFunction)
-- explod time
hr, mn, sc, hd, ms = timeDispatcher(lpt)
if hr == 0 then
- if mn <= 10 then
- rPanel = string.format( " %1d.%02d.%1d", mn, sc, ms)
- else
- rPanel = string.format( " %2d.%02d.%1d", mn, sc, ms)
- end
+ if mn <= 10 then
+ rPanel = string.format( " -%1d.%02d.%1d", mn, sc, ms)
+ else
+ rPanel = string.format( "-%2d.%02d.%1d", mn, sc, ms)
+ end
elseif hr < 10 then
- rPanel = string.format( "%1d:%02d.%02d.%1d", hr, mn, sc, ms)
+ rPanel = string.format( "%1d:%02d.%02d.%1d", hr, mn, sc, ms)
else
- rPanel = string.format( " %02d.%02d.%1d", hr, mn, sc)
+ rPanel = string.format( "-%02d.%02d.%1d", hr, mn, sc)
end
SetRightDigits( rPanel )
return 1
@@ -513,7 +521,7 @@ function custom_rightDigitsEvent(swFunction)
lpt = GetTimeInfo("systemtime")
-- explod time
hr, mn, sc, hd, ms = timeDispatcher(lpt)
- rPanel = string.format( " %02d.%02d ", hr, mn)
+ rPanel = string.format( "%02dh%02d ", hr, mn)
SetRightDigits( rPanel )
return 1
@@ -537,15 +545,15 @@ function custom_rightDigitsEvent(swFunction)
-- explod time
hr, mn, sc, hd, ms = timeDispatcher(lpt)
if hr == 0 then
- if mn <= 10 then
- rPanel = string.format( " %1d.%02d.%1d", mn, sc, ms)
- else
- rPanel = string.format( " %2d.%02d.%1d", mn, sc, ms)
- end
+ if mn <= 10 then
+ rPanel = string.format( " %1d.%02d.%1d", mn, sc, ms)
+ else
+ rPanel = string.format( " %2d.%02d.%1d", mn, sc, ms)
+ end
elseif hr < 10 then
- rPanel = string.format( "%1d:%02d.%02d.%1d", hr, mn, sc, ms)
+ rPanel = string.format( "%1d:%02d.%02d.%1d", hr, mn, sc, ms)
else
- rPanel = string.format( " %02d.%02d.%1d", hr, mn, sc)
+ rPanel = string.format( " %02d.%02d.%1d", hr, mn, sc)
end
SetRightDigits( rPanel )
return 1
@@ -553,17 +561,17 @@ function custom_rightDigitsEvent(swFunction)
-- 25.fuel
local fuel = GetCarInfo("fuel")
if fuel ~= nil then
- fuel = GetFuel(fuel, unit)
- if fuel >= 100 then
- rPanel = string.format(" F%03d ", round(fuel))
- elseif fuel >= 10 then
- rPanel = string.format(" F%02d ", round(fuel))
- else
- rPanel = string.format(" F%1.1f ", fuel)
- end
+ fuel = GetFuel(fuel, unit)
+ if fuel >= 100 then
+ rPanel = string.format(" F%03d ", round(fuel))
+ elseif fuel >= 10 then
+ rPanel = string.format(" F%02d ", round(fuel))
+ else
+ rPanel = string.format(" F%1.1f ", fuel)
+ end
- SetRightDigits( rPanel )
- return 1
+ SetRightDigits( rPanel )
+ return 1
end
elseif swValue == 26 then
@@ -641,20 +649,20 @@ function custom_rightDigitsEvent(swFunction)
--35 last sector 1, 2 and 3
local sector = GetCarInfo("sector")
if sector == 1 then
- -- sector 3
- local ls1 = GetTimeInfo("lastsector1")
- local ls2 = GetTimeInfo("lastsector2")
- local lt = GetTimeInfo("lastlaptime")
- if ls1 > 0 and ls2 > 0 then
- lpt = lt - (ls1 + ls2)
- end
+ -- sector 3
+ local ls1 = GetTimeInfo("lastsector1")
+ local ls2 = GetTimeInfo("lastsector2")
+ local lt = GetTimeInfo("lastlaptime")
+ if ls1 > 0 and ls2 > 0 then
+ lpt = lt - (ls1 + ls2)
+ end
elseif sector == 2 then
- local ls1 = GetTimeInfo("lastsector1")
- lpt = ls1
+ local ls1 = GetTimeInfo("lastsector1")
+ lpt = ls1
else
- -- sector 3
- local ls2 = GetTimeInfo("lastsector2")
- lpt = ls2
+ -- sector 3
+ local ls2 = GetTimeInfo("lastsector2")
+ lpt = ls2
end
elseif swValue == 36 then
@@ -669,107 +677,107 @@ function custom_rightDigitsEvent(swFunction)
local sector = GetCarInfo("sector")
diffFlag = true
if mDiffSectorDelay == nil or mDiffOldSector == nil or mDiffOldSector ~= sector then
- -- 8s delay, increase it if needed
- mDiffSectorDelay = GetTicks() + 8000
- mDiffOldSector = sector
+ -- 8s delay, increase it if needed
+ mDiffSectorDelay = GetTicks() + 8000
+ mDiffOldSector = sector
end
-- init backup vars
if mOld_lt == nil then
- mOld_ls1 = 0.00000
- mOld_ls2 = 0.00000
- mOld_lt = 0.00000
- mDelta_lpt = 0.00000
- mDelta_lptb = 0.00000
+ mOld_ls1 = 0.00000
+ mOld_ls2 = 0.00000
+ mOld_lt = 0.00000
+ mDelta_lpt = 0.00000
+ mDelta_lptb = 0.00000
end
-- display delta by default
lpt = GetTimeInfo("realdifflast")
if mDiffSectorDelay > GetTicks() then
- -- display sector
- if sector == 1 then
- -- sector 3
- local lt = GetTimeInfo("lastlaptime")
-
- -- if ls1 > 0 and ls2 > 0 and lt > 0 and mOld_ls1 > 0 and mOld_ls2 > 0 and mOld_lt > 0 then
- -- delta sector 3
- --lpt = (lt - (ls1 + ls2)) - (mOld_lt - (mOld_ls1 + mOld_ls2))
- if lt > 0 and mOld_lt > 0 then
- if lt ~= mOld_lt then
- mDelta_lpt = lt - mOld_lt
- print(mDelta_lpt, lt, mOld_lt)
- end
- lpt = mDelta_lpt
- end
+ -- display sector
+ if sector == 1 then
+ -- sector 3
+ local lt = GetTimeInfo("lastlaptime")
+
+ -- if ls1 > 0 and ls2 > 0 and lt > 0 and mOld_ls1 > 0 and mOld_ls2 > 0 and mOld_lt > 0 then
+ -- delta sector 3
+ --lpt = (lt - (ls1 + ls2)) - (mOld_lt - (mOld_ls1 + mOld_ls2))
+ if lt > 0 and mOld_lt > 0 then
+ if lt ~= mOld_lt then
+ mDelta_lpt = lt - mOld_lt
+ print(mDelta_lpt, lt, mOld_lt)
+ end
+ lpt = mDelta_lpt
+ end
- mOld_lt = lt
+ mOld_lt = lt
- elseif sector == 2 then
- -- sector 1
- local ls1 = GetTimeInfo("lastsector1")
- if ls1 > 0 and mOld_ls1 > 0 then
- lpt = ls1 - mOld_ls1
- end
- mOld_ls2 = GetTimeInfo("lastsector2")
- print(lpt, ls1 , mOld_ls1, mOld_ls2)
+ elseif sector == 2 then
+ -- sector 1
+ local ls1 = GetTimeInfo("lastsector1")
+ if ls1 > 0 and mOld_ls1 > 0 then
+ lpt = ls1 - mOld_ls1
+ end
+ mOld_ls2 = GetTimeInfo("lastsector2")
+ print(lpt, ls1 , mOld_ls1, mOld_ls2)
- else
- -- sector 2
- local ls2 = GetTimeInfo("lastsector2")
- if ls2 > 0 and mOld_ls2 > 0 then
- lpt = ls2 - mOld_ls2
- end
- mOld_ls1 = GetTimeInfo("lastsector1")
- print(lpt, ls2 , mOld_ls1, mOld_ls2)
- end
+ else
+ -- sector 2
+ local ls2 = GetTimeInfo("lastsector2")
+ if ls2 > 0 and mOld_ls2 > 0 then
+ lpt = ls2 - mOld_ls2
+ end
+ mOld_ls1 = GetTimeInfo("lastsector1")
+ print(lpt, ls2 , mOld_ls1, mOld_ls2)
+ end
end
elseif swValue == 38 then
- -- real time delta vs best + best sector diff 1, 2 and 3
-
- -- get sector
- local sector = GetCarInfo("sector")
- -- set flags
- diffFlag = true
-
- -- set delay
- if mDiffSectorDelay == nil or mDiffOldSector == nil or mDiffOldSector ~= sector then
- -- 8s delay, increase it if needed
- mDiffSectorDelay = GetTicks() + 8000
- mDiffOldSector = sector
- end
+ -- real time delta vs best + best sector diff 1, 2 and 3
- -- init backup vars
- if mOld_bt == nil then
- mOld_bs1 = 0.00000
- mOld_bs2 = 0.00000
- mOld_bt = 0.00000
- mDelta_lpt = 0.00000
- mDelta_lptb = 0.00000
- end
+ -- get sector
+ local sector = GetCarInfo("sector")
+ -- set flags
+ diffFlag = true
- -- display delta by default
- lpt = GetTimeInfo("realdiffbest")
+ -- set delay
+ if mDiffSectorDelay == nil or mDiffOldSector == nil or mDiffOldSector ~= sector then
+ -- 8s delay, increase it if needed
+ mDiffSectorDelay = GetTicks() + 8000
+ mDiffOldSector = sector
+ end
- if mDiffSectorDelay > GetTicks() then
- -- display sector diff during delay
- if sector == 1 then
- -- sector 3
- local bt = GetTimeInfo("bestlaptime")
-
- --if bs1 > 0 and bs2 > 0 and bt > 0 and mOld_bs1 > 0 and mOld_bs2 > 0 and mOld_bt > 0 then
- -- delta sector 3
- -- lpt = (bt - (bs1 + bs2)) - (mOld_bt - (mOld_bs1 + mOld_bs2))
- if bt > 0 and mOld_bt > 0 then
- if bt ~= mOld_bt then
- mDelta_lptb = bt - mOld_bt
- print(mDelta_lpt, bt, mOld_bt)
+ -- init backup vars
+ if mOld_bt == nil then
+ mOld_bs1 = 0.00000
+ mOld_bs2 = 0.00000
+ mOld_bt = 0.00000
+ mDelta_lpt = 0.00000
+ mDelta_lptb = 0.00000
+ end
+
+ -- display delta by default
+ lpt = GetTimeInfo("realdiffbest")
+
+ if mDiffSectorDelay > GetTicks() then
+ -- display sector diff during delay
+ if sector == 1 then
+ -- sector 3
+ local bt = GetTimeInfo("bestlaptime")
+
+ --if bs1 > 0 and bs2 > 0 and bt > 0 and mOld_bs1 > 0 and mOld_bs2 > 0 and mOld_bt > 0 then
+ -- delta sector 3
+ -- lpt = (bt - (bs1 + bs2)) - (mOld_bt - (mOld_bs1 + mOld_bs2))
+ if bt > 0 and mOld_bt > 0 then
+ if bt ~= mOld_bt then
+ mDelta_lptb = bt - mOld_bt
+ print(mDelta_lpt, bt, mOld_bt)
+ end
+ lpt = mDelta_lptb
end
- lpt = mDelta_lptb
- end
- mOld_bt = bt
+ mOld_bt = bt
elseif sector == 2 then
-- sector 1
@@ -838,9 +846,9 @@ function custom_rightDigitsEvent(swFunction)
if lpt == -1 or (mn + sc + ms) == 0.0000 then
mDeltaTimeBackup = " --.---"
elseif mn > 0 then
- mDeltaTimeBackup = string.format( "%s%2d.%02d.%01d", c, mn, sc, ms)
+ mDeltaTimeBackup = string.format( "%s%02d.%02d.%1d", c, mn, sc, ms)
else
- mDeltaTimeBackup = string.format( "%s%2d.%03d", c, sc, ms)
+ mDeltaTimeBackup = string.format( "%s%02d.%03d", c, sc, ms)
end
rPanel = mDeltaTimeBackup