summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugues Hiegel <hugues@hiegel.fr>2013-11-25 10:01:40 +0100
committerHugues Hiegel <hugues@hiegel.fr>2013-11-25 10:01:40 +0100
commitca6a4684364f5566b7ac8ba175850580a0ffe5f1 (patch)
tree0722c561ab123fa4c024ff477a1a75971ba652a9
parent88b3be0a36c2d09b2b65c04d1c1d334f24f3f0f8 (diff)
[gugus] left/right : another way of using « QI »
-rw-r--r--scripts/gugus/slipro.lua367
1 files changed, 250 insertions, 117 deletions
diff --git a/scripts/gugus/slipro.lua b/scripts/gugus/slipro.lua
index 5a49851..4bb1f8b 100644
--- a/scripts/gugus/slipro.lua
+++ b/scripts/gugus/slipro.lua
@@ -1,8 +1,16 @@
+require("scripts/gugus/sector")
+
-- ============================================================
-- Left and Right Panel functions
-- ============================================================
+-----------------------
+-- left : 0.0.0:00:0 --
+-- right: 0:00.0.0:0 --
+-----------------------
+
+
function leftDigitsEvent(swFunction)
swValue = swFunction + 1
@@ -18,13 +26,13 @@ function leftDigitsEvent(swFunction)
local qi = false
qi = GetContextInfo("quickinfobutton")
if qi == nil or qi == 0 then qi = false end
- if qi then
- -- get index for left panel
- local qiLeft = GetContextInfo("quickinfoleft")
- if qiLeft == nil then qiLeft = 1 end
- -- force position to match QI preference
- swValue = qiLeft
- end
+ --if qi then
+ -- -- get index for left panel
+ -- local qiLeft = GetContextInfo("quickinfoleft")
+ -- if qiLeft == nil then qiLeft = 1 end
+ -- -- force position to match QI preference
+ -- swValue = qiLeft
+ --end
-- check if PIT Feedback ON
local pf = false
@@ -49,19 +57,53 @@ function leftDigitsEvent(swFunction)
lPanel = string.format(" %3.0f", spd )
elseif swValue == 2 then
- -- fuel:speed
- local fuel = GetCarInfo("fuel")
- if fuel ~= nil then
- fuel = GetFuel(fuel, unit)
- if fuel >= 100 then
- -- special case for Euro Truck :)
- lPanel = string.format("%03d:%3.0f", round(fuel)%1000, spd)
- elseif fuel >= 10 then
- lPanel = string.format("F%02d:%3.0f", round(fuel), spd)
- elseif fuel >= 1 then
- lPanel = string.format("F%1.1f:%3.0f", fuel, spd)
- else
- lPanel = string.format("F.%02d:%3.0f", fuel * 100, spd )
+ if qi then
+ local fuel = GetCarInfo("fuel")
+ local remainlapsintank = GetCarInfo("remainlapsintank")
+
+ local sFuel = " "
+ local sRemainLaps = " "
+
+ if fuel ~= nil then
+ fuel = GetFuel(fuel, unit)
+ if fuel >= 100 then
+ -- specific for euro truck :)
+ sFuel = string.format("%03d", round(fuel) % 1000 )
+ elseif fuel >= 10 then
+ sFuel = string.format("F%02d", round(fuel) )
+ elseif fuel >= 1 then
+ sFuel = string.format("F%1.1f", fuel )
+ else
+ sFuel = string.format("F.%02d", fuel * 100 )
+ end
+
+ if remainlapsintank == 0 then
+ sRemainLaps = "L--"
+ elseif remainlapsintank >= 100 then
+ sRemainLaps = "L99"
+ elseif remainlapsintank >= 10 then
+ sRemainLaps = string.format("L%02d", math.floor(remainlapsintank))
+ else
+ sRemainLaps = string.format("L%1.1f", remainlapsintank)
+ end
+
+ lPanel = sFuel .. ":" .. sRemainLaps
+ end
+ else
+ -- fuel:speed
+ local fuel = GetCarInfo("fuel")
+ if fuel ~= nil then
+ fuel = GetFuel(fuel, unit)
+ if fuel >= 100 then
+ -- special case for Euro Truck :)
+ lPanel = string.format("%03d:%3.0f", round(fuel)%1000, spd)
+ elseif fuel >= 10 then
+ lPanel = string.format("F%02d:%3.0f", round(fuel), spd)
+ elseif fuel >= 1 then
+ lPanel = string.format("F%1.1f:%3.0f", fuel, spd)
+ else
+ lPanel = string.format("F.%02d:%3.0f", fuel * 100, spd )
+ end
end
end
elseif swValue == 3 then
@@ -76,13 +118,30 @@ function leftDigitsEvent(swFunction)
end
elseif swValue == 4 then
-- laps completed:speed
- inf = GetContextInfo("laps")
- if inf ~= nil then
- -- if more than 99 laps
- if inf >= 100 then
- lPanel = string.format("%03d:%3.0f", inf, spd)
+ local laps = GetContextInfo("laps")
+ if qi then
+ local tl = GetContextInfo("lapscount")
+ if tl ~= 0 then
+ -- if more than 99 laps
+ if tl >= 100 then
+ if laps > 999 then laps = 999 end
+ lPanel = string.format("r%02d:%03d", tl - laps, tl )
+ else
+ laps = string.format("r%02d:L%02d", tl - laps, tl)
+ end
else
- lPanel = string.format("L%02d:%3.0f", inf, spd)
+ laps = string.format("L%02d:t--", laps)
+ end
+ else
+ if laps ~= nil then
+ -- if more than 99 laps
+ if laps >= 100 then
+ lPanel = string.format("%03d:%3.0f", laps, spd)
+ else
+ lPanel = string.format("L%02d:%3.0f", laps, spd)
+ end
+ else
+ lPanel = string.format("L--:%3.0f", spd)
end
end
elseif swValue == 5 then
@@ -105,23 +164,23 @@ function leftDigitsEvent(swFunction)
local laps = "L--"
local total = "t--"
- if tl == 0 then
- -- if more than 99 laps
+ if qi and tl ~= 0 then
+ inf = tl - inf
+ -- display remaining laps
+
if inf >= 100 then
if inf > 999 then inf = 999 end
laps = string.format("%03d", inf )
else
- laps = string.format("L%02d", inf)
+ laps = string.format("r%02d", inf)
end
else
- inf = tl - inf
- -- display remaining laps
-
+ -- if more than 99 laps
if inf >= 100 then
if inf > 999 then inf = 999 end
laps = string.format("%03d", inf )
else
- laps = string.format("r%02d", inf)
+ laps = string.format("L%02d", inf)
end
end
@@ -294,9 +353,10 @@ function leftDigitsEvent(swFunction)
local sSector = " "
local sector = GetCarInfo("sector")
+ if qi then sector = mOldSector end
if sector ~= nil then
- if sector > 9 then
- sSector = string.format("S.%02d", sector)
+ if sector > 9 or sector < 0 then
+ sSector = string.format("S%02d", sector)
else
sSector = string.format(" S.%1d", sector)
end
@@ -417,12 +477,12 @@ function rightDigitsEvent(swFunction)
local qi = false
qi = GetContextInfo("quickinfobutton")
if qi == nil or qi == 0 then qi = false end
- if qi then
- -- get index for right panel
- local qiRight = GetContextInfo("quickinforight")
- if qiRight == nil then qiRight = 1 end
- swValue = qiRight
- end
+ --if qi then
+ -- -- get index for right panel
+ -- local qiRight = GetContextInfo("quickinforight")
+ -- if qiRight == nil then qiRight = 1 end
+ -- swValue = qiRight
+ --end
-- get current display unit metric or imperial
unit = GetContextInfo("speedmetric")
@@ -444,16 +504,35 @@ function rightDigitsEvent(swFunction)
local sim = GetContextInfo("simulation")
if sim ~= nil then
if swValue == 1 then
- -- current lap time
- lpt = GetTimeInfo("laptime")
+ if qi then
+ lpt = GetTimeInfo("lastlaptime")
+ else
+ -- current lap time
+ lpt = GetTimeInfo("laptime")
+ end
elseif swValue == 2 then
-- best lap time (PB)
- lpt = GetTimeInfo("bestlaptime")
+ if qi then
+ lpt = 0.0
+ local Bs1 = mBestSectors[1]
+ local Bs2 = mBestSectors[2]
+ local Bs3 = mBestSectors[3]
+ if Bs3 ~= 0.0 and Bs2 ~= 0.0 and Bs1 ~= 0.0 then
+ lpt = Bs1 + Bs2 + Bs3
+ end
+ else
+ lpt = GetTimeInfo("bestlaptime")
+ end
elseif swValue == 3 then
- -- last lap time
- lpt = GetTimeInfo("lastlaptime")
+ if qi then
+ diffTimeFlag = true
+ lpt = GetTimeInfo("realdifflast")
+ else
+ -- last lap time
+ lpt = GetTimeInfo("lastlaptime")
+ end
elseif swValue >= 4 and swValue <= 10 and isAppIRacing(sim) then
-- iRacing partials
@@ -487,33 +566,45 @@ function rightDigitsEvent(swFunction)
elseif swValue == 11 then
-- real time diff vs your best
- diffTimeFlag = true
- lpt = GetTimeInfo("realdiffbest")
+ if qi then
+ lpt = GetTimeInfo("bestlaptime")
+ else
+ diffTimeFlag = true
+ lpt = GetTimeInfo("realdiffbest")
+ end
elseif swValue == 12 then
-- real time diff vs your last
- diffTimeFlag = true
- lpt = GetTimeInfo("realdifflast")
+ if qi then
+ lpt = GetTimeInfo("lastlaptime")
+ else
+ diffTimeFlag = true
+ lpt = GetTimeInfo("realdifflast")
+ end
elseif swValue == 13 then
-- current sector time
- local sector = GetCarInfo("sector")
- lt = GetTimeInfo("laptime")
- if sector == 1 then
- lpt = lt
- elseif sector == 2 then
- lpt = lt - GetTimeInfo("sector1")
+ if qi then
+ lpt = GetPreviousSectorTime()
else
- -- sector 3
- lpt = lt - GetTimeInfo("sector1") - GetTimeInfo("sector2")
+ lpt = GetCurrentSectorTime()
end
+
elseif swValue == 14 then
-- best sector 1
- lpt = GetTimeInfo("bestsector1")
+ if qi then
+ lpt = GetTimeInfo("bestsector1")
+ else
+ lpt = mBestSectors[1]
+ end
elseif swValue == 15 then
-- best sector 2
- lpt = GetTimeInfo("bestsector2")
+ if qi then
+ lpt = GetTimeInfo("bestsector2")
+ else
+ lpt = mBestSectors[3]
+ end
elseif swValue == 16 then
-- last sector 1
@@ -549,21 +640,40 @@ function rightDigitsEvent(swFunction)
return 1
elseif swValue == 21 then
- -- time remaining if available
- lpt = GetTimeInfo("timeremaining")
-
- -- 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)
+ if qi then
+ -- time elapsed if available
+ lpt = GetTimeInfo("timetotalelapsed")
+
+ -- 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
+ elseif hr < 10 then
+ rPanel = string.format( "%1d:%02d.%02d.%1d", hr, mn, sc, ms)
else
- rPanel = string.format( "-%2d.%02d.%1d", mn, sc, ms)
+ rPanel = string.format( " %02d.%02d.%1d", hr, mn, sc)
end
- elseif hr < 10 then
- rPanel = string.format( "%1d:%02d.%02d.%1d", hr, mn, sc, ms)
else
- rPanel = string.format( "-%02d.%02d.%1d", hr, mn, sc)
+ -- time remaining if available
+ lpt = GetTimeInfo("timeremaining")
+
+ -- 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
+ elseif hr < 10 then
+ rPanel = string.format( "%1d:%02d.%02d.%1d", hr, mn, sc, ms)
+ else
+ rPanel = string.format( "-%02d.%02d.%1d", hr, mn, sc)
+ end
end
SetRightDigits( rPanel )
return 1
@@ -591,24 +701,44 @@ function rightDigitsEvent(swFunction)
return 1
elseif swValue == 24 then
- -- time elapsed if available
- lpt = GetTimeInfo("timetotalelapsed")
-
- -- 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)
+ if qi then
+ -- time remaining if available
+ lpt = GetTimeInfo("timeremaining")
+
+ -- 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
+ elseif hr < 10 then
+ rPanel = string.format( "%1d:%02d.%02d.%1d", hr, mn, sc, ms)
else
- rPanel = string.format( " %2d.%02d.%1d", mn, sc, ms)
+ rPanel = string.format( "-%02d.%02d.%1d", hr, mn, sc)
end
- elseif hr < 10 then
- rPanel = string.format( "%1d:%02d.%02d.%1d", hr, mn, sc, ms)
else
- rPanel = string.format( " %02d.%02d.%1d", hr, mn, sc)
+ -- time elapsed if available
+ lpt = GetTimeInfo("timetotalelapsed")
+
+ -- 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
+ elseif hr < 10 then
+ rPanel = string.format( "%1d:%02d.%02d.%1d", hr, mn, sc, ms)
+ else
+ rPanel = string.format( " %02d.%02d.%1d", hr, mn, sc)
+ end
end
SetRightDigits( rPanel )
return 1
+
elseif swValue == 25 then
-- 25.fuel
local fuel = GetCarInfo("fuel")
@@ -652,9 +782,9 @@ function rightDigitsEvent(swFunction)
local sect = GetCarInfo("sector")
-- check if sector > 9
if sect >9 then
- rPanel = string.format(" S%02d ", sect)
+ rPanel = string.format(" S%02d ", sect)
else
- rPanel = string.format(" S%01d ", sect)
+ rPanel = string.format(" S%01d ", sect)
end
SetRightDigits( rPanel )
return 1
@@ -699,20 +829,7 @@ function rightDigitsEvent(swFunction)
elseif swValue == 35 then
--35 last sector 1, 2 and 3
- local sector = GetCarInfo("sector")
- if sector == 1 then
- -- sector 3
- local ls3 = GetTimeInfo("lastsector3")
- lpt = ls3
-
- elseif sector == 2 then
- local ls1 = GetTimeInfo("lastsector1")
- lpt = ls1
- else
- -- sector 3
- local ls2 = GetTimeInfo("lastsector2")
- lpt = ls2
- end
+ lpt = GetPreviousSectorTime()
elseif swValue == 36 then
--36.rpm
@@ -724,15 +841,20 @@ function rightDigitsEvent(swFunction)
elseif swValue == 37 then
-- real time delta vs last + sector splits
diffTimeFlag = true
-
- lpt = RealTimeDiff_SectorSplits(false, 42)
-
+ if qi then
+ lpt = mSectorSplit_Vs_LastSector
+ else
+ lpt = RealTimeDiff_SectorSplits(false, 42)
+ end
elseif swValue == 38 then
-- real time delta vs best + sector splits
diffTimeFlag = true
-
- lpt = RealTimeDiff_SectorSplits(true, true)
+ if qi then
+ lpt = mSectorSplit_Vs_BestLap
+ else
+ lpt = RealTimeDiff_SectorSplits(true, true)
+ end
elseif swValue == 39 then
@@ -740,8 +862,12 @@ function rightDigitsEvent(swFunction)
lpt = GetTimeInfo("lastsector3")
elseif swValue == 40 then
- -- last sector 3
- lpt = GetTimeInfo("bestsector3")
+ -- best sector 3
+ if qi then
+ lpt = GetTimeInfo("bestsector3")
+ else
+ lpt = mBestSectors[3]
+ end
elseif swValue == 41 then
-- current sector 1 (rFactor)
@@ -758,18 +884,25 @@ function rightDigitsEvent(swFunction)
elseif swValue == 44 then
-- real time delta vs best + best sector splits
diffTimeFlag = true
-
- lpt = RealTimeDiff_SectorSplits(true, false)
+ if qi then
+ lpt = mSectorSplit_Vs_BestSector
+ else
+ lpt = RealTimeDiff_SectorSplits(true, false)
+ end
elseif swValue == 45 then
- -- virtual best lap time
- lpt = 0.0
- local Bs1 = mBestSectors[1]
- local Bs2 = mBestSectors[2]
- local Bs3 = mBestSectors[3]
- if Bs3 ~= 0.0 and Bs2 ~= 0.0 and Bs1 ~= 0.0 then
- lpt = Bs1 + Bs2 + Bs3
+ if qi then
+ lpt = GetCurrentSectorBestTime()
+ else
+ -- virtual best lap time
+ lpt = 0.0
+ local Bs1 = mBestSectors[1]
+ local Bs2 = mBestSectors[2]
+ local Bs3 = mBestSectors[3]
+ if Bs3 ~= 0.0 and Bs2 ~= 0.0 and Bs1 ~= 0.0 then
+ lpt = Bs1 + Bs2 + Bs3
+ end
end
else
@@ -826,7 +959,7 @@ function rightDigitsEvent(swFunction)
elseif mn < 10 then
mDeltaTimeBackup = string.format( "%1d:%02d.%03d", mn, sc, ms)
elseif hr > 0 then
- mDeltaTimeBackup = string.format( " %02d.%02d ", hr, mn)
+ mDeltaTimeBackup = string.format( "%1d:%02d.%02d.%1d ", hr, mn, sc, (hd/10))
else
mDeltaTimeBackup = string.format( " %02d.%02d.%01d", mn, sc, ms)
end