summaryrefslogtreecommitdiff
path: root/scripts/slipro.lua
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/slipro.lua')
-rw-r--r--[-rwxr-xr-x]scripts/slipro.lua258
1 files changed, 232 insertions, 26 deletions
diff --git a/scripts/slipro.lua b/scripts/slipro.lua
index ed4cd63..df4833c 100755..100644
--- a/scripts/slipro.lua
+++ b/scripts/slipro.lua
@@ -1,8 +1,8 @@
--- SLIPRO Lua Script v3
+-- SLIPRO Lua Script v3.3.2
-- Copyright (c)2012-2013 by Zappadoc - All Rights Reserved.
-- this script builds all functions associated with
-- left and right panels of SLIPRO device
--- last change by Zappadoc - 2013-02
+-- last change by Zappadoc - 2013-09
-- ============================================================
-- Left and Right Panel functions
@@ -45,6 +45,19 @@ function leftDigitsEvent(swFunction)
-- force position to match QI preference
swValue = qiLeft
end
+
+ -- check if PIT Feedback ON
+ local pf = false
+ pf = GetContextInfo("pitfeedback")
+ if pf == nil or pf == 0 then pf = false end
+ if pf then
+ -- force position to PIT/SPEED function if car pits
+ local pit = GetCarInfo("inpits")
+ if pit > 0 then
+ swValue = 35
+ end
+ end
+
-- get current simulation name
local sim = GetContextInfo("simulation")
@@ -209,9 +222,10 @@ function leftDigitsEvent(swFunction)
lPanel = string.format(" P%02d ", pos )
elseif swValue == 22 then
- -- logo
- lPanel = "SLIMAX"
-
+ -- get an average consumption of fuel per lap and gives the remaining laps
+ local remainintank = GetCarInfo("remainlapsintank")
+ lPanel = string.format(" FL%3.0f", math.floor(remainintank) )
+
elseif swValue == 23 then
-- rpm
local rpm = GetCarInfo("rpm")
@@ -290,6 +304,19 @@ function leftDigitsEvent(swFunction)
local kers = GetCarInfo("kers")
lPanel = string.format("%3d:%3.0f", round((kers/1000)/4), spd)
+ elseif swValue == 35 then
+ -- PIT
+ lPanel = " PIt "
+
+ elseif swValue == 36 then
+ -- sc
+ local sc = GetContextInfo("safetycare")
+ if sc == 1 then
+ lPanel = " SCAR "
+ else
+ lPanel = " OFF "
+ end
+
else
lPanel = "-:--.---"
end
@@ -338,7 +365,7 @@ function rightDigitsEvent(swFunction)
local dlt = false
dlt = GetContextInfo("displaylaptime")
if dlt == nil then dlt = false end
- if dlt then
+ if dlt and swValue ~= 37 and swValue ~= 38 then
swValue = 3
end
@@ -355,6 +382,20 @@ function rightDigitsEvent(swFunction)
-- get current display unit metric or imperial
unit = GetContextInfo("speedmetric")
+ -- check if PIT Feedback ON
+ local pf = false
+ pf = GetContextInfo("pitfeedback")
+ if pf == nil or pf == 0 then pf = false end
+ if pf then
+ -- force position to SPEED function
+ local pit = GetCarInfo("inpits")
+ if pit > 0 then
+ swValue = 20
+ end
+ end
+
+ --print ( "swValue: " .. swValue .. "\n")
+
-- get sim name
local sim = GetContextInfo("simulation")
if sim ~= nil then
@@ -445,16 +486,17 @@ function rightDigitsEvent(swFunction)
SetRightDigits( rPanel )
return 1
elseif swValue == 19 then
- -- logo
- rPanel = "SLIMAX"
- SetRightDigits( rPanel )
- return 1
+ -- get an average consumption of fuel per lap and gives the remaining laps
+ local remainintank = GetCarInfo("remainlapsintank")
+ rPanel = string.format(" FL%3.0f", math.floor(remainintank) )
+
elseif swValue == 20 then
-- speed on right panel
local spd = GetCarInfo("speed")
rPanel = string.format(" %3d ", spd )
SetRightDigits( rPanel )
return 1
+
elseif swValue == 21 then
-- time remaining if available
lpt = GetTimeInfo("timeremaining")
@@ -468,6 +510,7 @@ function rightDigitsEvent(swFunction)
end
SetRightDigits( rPanel )
return 1
+
elseif swValue == 22 then
-- PC system time
lpt = GetTimeInfo("systemtime")
@@ -476,6 +519,7 @@ function rightDigitsEvent(swFunction)
rPanel = string.format( " %02d.%02d ", hr, mn)
SetRightDigits( rPanel )
return 1
+
elseif swValue == 23 then
-- rpm:gear
local rpm = GetCarInfo("rpm")
@@ -488,6 +532,7 @@ function rightDigitsEvent(swFunction)
SetRightDigits( rPanel )
end
return 1
+
elseif swValue == 24 then
-- time elapsed if available
lpt = GetTimeInfo("timetotalelapsed")
@@ -609,6 +654,140 @@ function rightDigitsEvent(swFunction)
lpt = ls2
end
+ elseif swValue == 36 then
+ --36.rpm
+ local rpm = GetCarInfo("rpm")
+ rPanel = string.format("%5d ", rpm)
+ SetRightDigits( rPanel )
+ return 1
+
+ elseif swValue == 37 then
+ -- real time delta vs last + last sector diff 1, 2 and 3
+ 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
+ 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
+ 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
+
+ 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)
+
+ 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 + last 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
+
+ -- 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
+
+ mOld_bt = bt
+
+ elseif sector == 2 then
+ -- sector 1
+ local bs1 = GetTimeInfo("bestsector1")
+ if bs1 > 0 and mOld_bs1 > 0 then
+ lpt = bs1 - mOld_bs1
+ end
+ print(lpt, bs1 )
+ mOld_bs2 = GetTimeInfo("bestsector2")
+
+ else
+ -- sector 2
+ local bs2 = GetTimeInfo("bestsector2")
+ if bs2 > 0 and mOld_bs2 > 0 then
+ lpt = bs2 - mOld_bs2
+ end
+ print(lpt, bs2 )
+ mOld_bs1 = GetTimeInfo("bestsector1")
+ end
+ end
+
else
-- none
rPanel = "-:--.---"
@@ -619,18 +798,40 @@ function rightDigitsEvent(swFunction)
if lpt == nil then return 0 end
+ local refreshRate = mRefreshLapTimeRate
+ if diffFlag then
+ refreshRate = mDeltaTimeDelay
+ end
+
+ -- check if diff time is ready
+ local diffOK = GetTimeInfo("realdifftimeready")
+ if diffFlag and diffOK == false then
+ diffFlag = false
+ rPanel = " nPEF "
+
+ mOld_ls1 = 0.00000
+ mOld_ls2 = 0.00000
+ mOld_lt = 0.00000
+ mDelta_lpt = 0.00000
+ mDelta_lptb = 0.00000
+
+ SetRightDigits( rPanel )
+ return 1
+ end
+
local c = " "
if lpt < 0 then
c = "-"
end
-- explod time
hr, mn, sc, hd, ms = timeDispatcher(lpt)
+
-- print("lpt: " .. lpt .. " m: " .. mn .. " - s: " .. sc .. " - ms: " .. ms .. )
+ if GetTicks() > ( refreshRate + mDeltaTimeOldTicks ) then
+ mDeltaTimeOldTicks = GetTicks()
- if diffFlag then
- --
- if GetTicks() > (mDeltaTimeDelay + mDeltaTimeOldTicks ) then
- mDeltaTimeOldTicks = GetTicks()
+ if diffFlag then
+ --
if lpt == -1 or (mn + sc + ms) == 0.0000 then
mDeltaTimeBackup = " --.---"
elseif mn > 0 then
@@ -638,20 +839,25 @@ function rightDigitsEvent(swFunction)
else
mDeltaTimeBackup = string.format( "%s%2d.%03d", c, sc, ms)
end
- end
- rPanel = mDeltaTimeBackup
- else
- if lpt == -1 or (mn + sc + ms) == 0.0000 then
- rPanel = "-:--.---"
- elseif mn < 10 then
- rPanel = string.format( "%1d:%02d.%03d", mn, sc, ms)
- elseif hr > 0 then
- rPanel = string.format( " %02d.%02d ", hr, mn)
- else
- rPanel = string.format( " %02d.%02d.%01d", mn, sc, ms)
- end
+ rPanel = mDeltaTimeBackup
+
+ else
+ --if mTimeBackup == nil then mTimeBackup = 0.0000 end
+ if lpt == -1 or (mn + sc + ms) == 0.0000 then
+ mDeltaTimeBackup = "-:--.---"
+ elseif mn < 10 then
+ mDeltaTimeBackup = string.format( "%1d:%02d.%03d", mn, sc, ms)
+ elseif hr > 0 then
+ mDeltaTimeBackup = string.format( " %02d.%02d ", hr, mn)
+ else
+ mDeltaTimeBackup = string.format( " %02d.%02d.%01d", mn, sc, ms)
+ end
+
+
+ end
end
+ rPanel = mDeltaTimeBackup
-- send time to sli manager
SetRightDigits( rPanel )
return 1