summaryrefslogtreecommitdiff
path: root/scripts/gugus
diff options
context:
space:
mode:
authorHugues Hiegel <hugues@hiegel.fr>2013-11-22 01:54:55 +0100
committerHugues Hiegel <hugues@hiegel.fr>2013-11-22 01:54:55 +0100
commit121d1785256c617e98726a29b0fd9c96e2c04c38 (patch)
tree1b708bd99dd2351fcb92a8c4bd7d64c25d06bd25 /scripts/gugus
parent0701f2c5c60ed4d448597654e43fe460ac8dd962 (diff)
[gugus] *REAL* best sector times + some split sector times stuff.
Diffstat (limited to 'scripts/gugus')
-rw-r--r--scripts/gugus/dev.lua38
-rw-r--r--scripts/gugus/sector.lua130
-rw-r--r--scripts/gugus/session.lua7
-rw-r--r--scripts/gugus/slipro.lua42
4 files changed, 146 insertions, 71 deletions
diff --git a/scripts/gugus/dev.lua b/scripts/gugus/dev.lua
index ba4061b..3e7360b 100644
--- a/scripts/gugus/dev.lua
+++ b/scripts/gugus/dev.lua
@@ -1,46 +1,14 @@
---require("scripts/gugus/sector")
-
--- hint : i don’t care if this is correctly initialized at each session.
-mCurrentSector = nil
function custom_deviceReport(deviceType)
-- sim paused?
local paused = GetContextInfo("paused")
- if !paused then
- local sector = GetCarInfo("sector")
- if mCurrentSector == nil or mCurrentSector ~= sector then
-
- local s1 = GetTimeInfo("sector1")
- local s2 = GetTimeInfo("sector2")
- local s3 = GetTimeInfo("sector3")
-
- local ls1 = GetTimeInfo("lastsector1")
- local ls2 = GetTimeInfo("lastsector2")
- local ls3 = GetTimeInfo("lastsector3")
-
- local bs1 = GetTimeInfo("bestsector1")
- local bs2 = GetTimeInfo("bestsector2")
- local bs3 = GetTimeInfo("bestsector3")
-
- print ("")
- print ("--- lap "..GetContextInfo("laps").." ----------------------------------------")
- print ("sector " ..mCurrentSector.." -> "..sector.." [curr] " .. s1 .. " - " .. s2 .. " - " .. s3)
- print ("sector " ..mCurrentSector.." -> "..sector.." [last] " ..ls1 .. " - " ..ls2 .. " - " ..ls3)
- print ("sector " ..mCurrentSector.." -> "..sector.." [best] " ..bs1 .. " - " ..bs2 .. " - " ..bs3)
- print ("-----------------------------------------------------------------------------")
-
- --ls = GetTimeInfo(string.format("sector%d", mCurrentSector))
- --if mCurrentOptimalSectorTimes[sector] ~= 0.0 and mCurrentOptimalSectorTimes[sector] > ls then
- -- mCurrentOptimalSectorTimes[sector] = ls
- --end
-
- mCurrentSector = sector
- end
+ if paused == false then
+ SectorUpdate()
end
return 2
end
-print ("gugus> + sector")
+print ("gugus> + dev")
diff --git a/scripts/gugus/sector.lua b/scripts/gugus/sector.lua
index 356a40a..66eda91 100644
--- a/scripts/gugus/sector.lua
+++ b/scripts/gugus/sector.lua
@@ -1,10 +1,128 @@
-mCurrentSector = nil
---mOptimalSectorTimes = nil
---mCurrentOptimalSectorTimes=nil
+mOldSector = -1
-function initSectorTimes()
- mCurrentSector = nil
- --mCurrentOptimalSectorTimes = {0.0, 0.0, 0.0}
+mBestSectors = {0.00, 0.00, 0.00}
+mLastSectors = {0.00, 0.00, 0.00}
+
+mSectorSplit_Vs_LastSector = 0.0
+mSectorSplit_Vs_BestSector = 0.0
+mSectorSplit_Vs_BestLap = 0.0
+mSectorSplit = nil
+
+function SectorUpdate()
+ local sector = GetCarInfo("sector")
+ local laps = GetContextInfo("laps")
+ if mSectorSplit == nil or mOldSector ~= sector then
+ mSectorSplit = GetTicks() + mSectorSplitDelay
+
+ local s1 = GetTimeInfo("sector1")
+ local s2 = GetTimeInfo("sector2")
+ local s3 = GetTimeInfo("sector3")
+
+ local ls1 = GetTimeInfo("lastsector1")
+ local ls2 = GetTimeInfo("lastsector2")
+ local ls3 = GetTimeInfo("lastsector3")
+
+ local Ls1 = mLastSectors[1]
+ local Ls2 = mLastSectors[2]
+ local Ls3 = mLastSectors[3]
+
+ local bs1 = GetTimeInfo("bestsector1")
+ local bs2 = GetTimeInfo("bestsector2")
+ local bs3 = GetTimeInfo("bestsector3")
+
+ local Bs1 = mBestSectors[1]
+ local Bs2 = mBestSectors[2]
+ local Bs3 = mBestSectors[3]
+
+ --local lt = GetTimeInfo("laptime")
+ local llt = GetTimeInfo("lastlaptime")
+ local blt = GetTimeInfo("bestlaptime")
+ local Blt = Bs1 + Bs2 + Bs3
+ local Llt = Ls1 + Ls2 + Ls3
+
+ if laps > 0 then
+ if mOldSector == 1 then
+ if Bs1 == 0 then mBestSectors[1] = math.min(bs1, ls1)
+ else mBestSectors[1] = math.min(Bs1, bs1, ls1)
+ end
+ elseif mOldSector == 2 then
+ if Bs2 == 0 then mBestSectors[2] = math.min(bs2, ls2)
+ else mBestSectors[2] = math.min(Bs2, bs2, ls2)
+ end
+ else -- mOldSector == 3
+ if Bs3 == 0 then mBestSectors[3] = math.min(bs3, ls3)
+ else mBestSectors[3] = math.min(Bs3, bs3, ls3)
+ end
+ end
+ end
+
+ mSectorSplit_Vs_LastSector = 0.0
+ mSectorSplit_Vs_BestSector = 0.0
+ mSectorSplit_Vs_BestLap = 0.0
+
+ if mOldSector == 1 or (mOldSector > 1 and mSectorSplitCumulate) then
+ mSectorSplit_Vs_LastSector = mSectorSplit_Vs_LastSector + s1 - Ls1
+ mSectorSplit_Vs_BestSector = mSectorSplit_Vs_BestSector + s1 - Bs1
+ mSectorSplit_Vs_BestLap = mSectorSplit_Vs_BestLap + s1 - bs1
+ end
+ if mOldSector == 2 or (mOldSector > 2 and mSectorSplitCumulate) then
+ mSectorSplit_Vs_LastSector = mSectorSplit_Vs_LastSector + s2 - Ls2
+ mSectorSplit_Vs_BestSector = mSectorSplit_Vs_BestSector + s2 - Bs2
+ mSectorSplit_Vs_BestLap = mSectorSplit_Vs_BestLap + s2 - bs2
+ end
+ if mOldSector == 3 then
+ mSectorSplit_Vs_LastSector = mSectorSplit_Vs_LastSector + s3 - Ls3
+ mSectorSplit_Vs_BestSector = mSectorSplit_Vs_BestSector + s3 - Bs3
+ mSectorSplit_Vs_BestLap = mSectorSplit_Vs_BestLap + s3 - bs3
+ end
+
+ if mOldSector == 1 then
+ print (" sector " ..mOldSector)
+ elseif mOldSector == 2 then
+ print (" sector " ..mOldSector)
+ else -- mOldSector == 3
+ print (" sector " ..mOldSector)
+ end
+ print ("[curr] " .. s1 .. " " .. s2 .. " " .. s3 )
+ print ("[last] " ..ls1 .. " " ..ls2 .. " " ..ls3 )
+ print ("[Last] " ..Ls1 .. " " ..Ls2 .. " " ..Ls3 .. " | " .. (mSectorSplit_Vs_LastSector) )
+ print ("[best] " ..bs1 .. " " ..bs2 .. " " ..bs3 .. " | " .. (mSectorSplit_Vs_BestLap ) )
+ print ("[Best] " ..Bs1 .. " " ..Bs2 .. " " ..Bs3 .. " | " .. (mSectorSplit_Vs_BestSector) )
+
+ if sector == 1 then
+ mLastSectors = { ls1 , ls2 , ls3 }
+ -- new lap
+ print ("")
+ print (" last best")
+ print ("[lapt] " .. llt .. " - " .. blt )
+ print ("[sect] " .. (ls1+ls2+ls3) .. " - " .. (bs1+bs2+bs3) )
+ print ("[comp] " .. Llt .. " - " .. Blt )
+
+ print ("--- lap "..(laps - 1).." --------------------------------")
+ end
+
+ mOldSector = sector
+ end
end
+
+-- return delta time vs last/best time + sector splits
+function RealTimeDiff_SectorSplits(Best, Lap)
+
+ local lpt = 0.0
+
+ if mSectorSplit ~= nil and mSectorSplit > GetTicks() then
+ if Best and Lap then lpt = mSectorSplit_Vs_BestLap
+ elseif Best then lpt = mSectorSplit_Vs_BestSector
+ else lpt = mSectorSplit_Vs_LastSector
+ end
+ else
+ -- display delta by default
+ if Best then lpt = GetTimeInfo("realdiffbest")
+ else lpt = GetTimeInfo("realdifflast")
+ end
+ end
+
+ return lpt
+end
diff --git a/scripts/gugus/session.lua b/scripts/gugus/session.lua
index 920d54f..3e7039a 100644
--- a/scripts/gugus/session.lua
+++ b/scripts/gugus/session.lua
@@ -2,8 +2,11 @@
--require("scripts/gugus/sector")
function custom_enterSessionEvent(devType)
- --initSectorTimes()
- mCurrentSector = nil
+ mCurrentSector = -1
+ mLastSectors = {0.0, 0.0, 0.0}
+ if GetContextInfo("laps") <= 0 then
+ mBestSectors = {0.0, 0.0, 0.0}
+ end
-- type your custom script on session start, here
print ()
diff --git a/scripts/gugus/slipro.lua b/scripts/gugus/slipro.lua
index 5c0ff18..3c06cf2 100644
--- a/scripts/gugus/slipro.lua
+++ b/scripts/gugus/slipro.lua
@@ -505,7 +505,7 @@ function rightDigitsEvent(swFunction)
lpt = lt - GetTimeInfo("sector1")
else
-- sector 3
- lpt = lt - GetTimeInfo("sector1") + GetTimeInfo("sector2")
+ lpt = lt - GetTimeInfo("sector1") - GetTimeInfo("sector2")
end
elseif swValue == 14 then
-- best sector 1
@@ -722,17 +722,17 @@ function rightDigitsEvent(swFunction)
return 1
elseif swValue == 37 then
- -- real time delta vs last + last sector diff 1, 2 and 3
+ -- real time delta vs last + sector splits
diffTimeFlag = true
- lpt = GetDeltaLastTime(false)
+ lpt = RealTimeDiff_SectorSplits(false, 42)
elseif swValue == 38 then
- -- real time delta vs best + last sector diff 1, 2 and 3
+ -- real time delta vs best + sector splits
diffTimeFlag = true
- lpt = GetDeltaBestTime(false)
+ lpt = RealTimeDiff_SectorSplits(true, true)
elseif swValue == 39 then
@@ -756,35 +756,21 @@ function rightDigitsEvent(swFunction)
lpt = GetTimeInfo("sector3")
elseif swValue == 44 then
- -- rfactor real time delta vs last + last sector diff 1, 2 and 3
+ -- real time delta vs best + best sector splits
diffTimeFlag = true
- lpt = GetDeltaLastTime(true)
+ lpt = RealTimeDiff_SectorSplits(true, false)
elseif swValue == 45 then
- -- rFactor real time delta vs best + last sector diff 1, 2 and 3
- diffTimeFlag = true
-
- lpt = GetDeltaBestTime(true)
-
- elseif swValue == 46 then
-- virtual best lap time
- bs1 = GetTimeInfo("bestsector1")
- ls1 = GetTimeInfo("lastsector1")
- if ls1 < bs1 then s1 = ls1 else s1 = bs1 end
-
- bs2 = GetTimeInfo("bestsector2")
- ls2 = GetTimeInfo("lastsector2")
- if ls2 < bs2 then s2 = ls2 else s2 = bs2 end
-
- bs3 = GetTimeInfo("bestsector3")
- ls3 = GetTimeInfo("lastsector3")
- if ls3 < bs3 then s3 = ls3 else s3 = bs3 end
-
- --print ( ls1 , " + " , ls2, " + ", ls3 )
- --print ( bs1 , " + " , bs2, " + ", bs3 )
- lpt = s1 + s2 + s3
+ 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
-- none