summaryrefslogtreecommitdiff
path: root/scripts/fanatec.lua
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/fanatec.lua')
-rw-r--r--[-rwxr-xr-x]scripts/fanatec.lua176
1 files changed, 107 insertions, 69 deletions
diff --git a/scripts/fanatec.lua b/scripts/fanatec.lua
index 90e44f1..46d944c 100755..100644
--- a/scripts/fanatec.lua
+++ b/scripts/fanatec.lua
@@ -1,8 +1,8 @@
--- Fanatec Lua Script v1.0
+-- Fanatec Lua Script v1.4
-- Copyright (c)2012-2013 by Zappadoc - All Rights Reserved.
-- this script builds all functions associated with
-- digits panels of Fanatec device
--- last change by Zappadoc - 2013-02
+-- last change by Zappadoc - 2013-09
-- ============================================================
-- Digits Panel functions
@@ -78,12 +78,24 @@ function fanatecDigitsEvent(swFunction)
swValue = 11
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 function if car pits
+ local pit = GetCarInfo("inpits")
+ if pit > 0 then
+ swValue = 41
+ end
+ end
+
-- check postion and compute panel string
if swValue == 1 then
-- oldGear is intialized in gearEvent (see gear.lua)
if oldGear ~= nil then
-- gear
- local g = GetCarInfo("gear")
+ --local g = GetCarInfo("gear")
-- get neutral
local n = string.char(GetContextInfo("neutral"))
@@ -94,11 +106,11 @@ function fanatecDigitsEvent(swFunction)
-- set neutral, reverse or current gear
- if g == 0 then
+ if oldGear == 0 then
-- if neutral and using custom OSP record then add a dot to gear digit
SetFanatecGear(n, ospcustom_on)
- elseif g < 0 then
+ elseif oldGear < 0 then
-- reverse
SetFanatecGear(r, false)
@@ -108,9 +120,10 @@ function fanatecDigitsEvent(swFunction)
-- return 0
-- end
- SetFanatecGear(string.char(g), false)
+ SetFanatecGear(string.char(oldGear), false)
end
+
return 1
end
@@ -198,19 +211,27 @@ function fanatecDigitsEvent(swFunction)
elseif swValue == 10 then
-- best lap time
- timeFlag = true
+ --timeFlag = true
+ --dlt = true
lpt = GetTimeInfo("bestlaptime")
-
+ mFanatecText = DisplayFormatTime(lpt,mRefreshLapTimeRate,2,0,3)
+
+ SetFanatecDigits( mFanatecText )
+ return 1
elseif swValue == 11 then
-- last lap time
- timeFlag = true
+ --timeFlag = true
+ --dlt = true
lpt = GetTimeInfo("lastlaptime")
-
+ mFanatecText = DisplayFormatTime(lpt,mRefreshLapTimeRate,2,0,3)
+ SetFanatecDigits( mFanatecText )
+ return 1
elseif swValue >= 12 and swValue <= 18 and isAppIRacing(sim) then
- timeFlag = true
+ --timeFlag = true
-- iRacing partials
local ts = GetContextInfo("partialcount")
local sector = GetCarInfo("sector")
+ if sector == nil then sector = 0 end
if ts ~= nil and ts > 0 then
if swValue == 12 then
lpt = GetPartialTimeInfo("currentpartial", sector)
@@ -230,21 +251,33 @@ function fanatecDigitsEvent(swFunction)
else
lpt = 0.0
end
-
+ mFanatecText = DisplayFormatTime(lpt,mDeltaTimeDelay,2,1,3)
+ SetFanatecDigits( mFanatecText )
+ return 1
elseif swValue == 19 then
-- real time diff vs your best
- timeFlag = true
+ --timeFlag = true
lpt = GetTimeInfo("realdiffbest")
-
+ mFanatecText = DisplayFormatTime(lpt,mDeltaTimeDelay,2,1,3)
+ SetFanatecDigits( mFanatecText )
+ return 1
elseif swValue == 20 then
-- real time diff vs your last
- timeFlag = true
+ --timeFlag = true
lpt = GetTimeInfo("realdifflast")
+ mFanatecText = DisplayFormatTime(lpt,mDeltaTimeDelay,2,1,3)
+ SetFanatecDigits( mFanatecText )
+ return 1
elseif swValue == 21 then
- -- logo
- fPanel = "SMX"
-
+ -- get an average consumption of fuel per lap and gives the remaining laps
+ local remainintank = GetCarInfo("remainlapsintank")
+ if remainintank >= 100 then
+ fPanel = string.format("%3.0f", math.floor (remainintank))
+ else
+ fPanel = string.format("L%2.0f", math.floor(remainintank))
+ end
+
elseif swValue == 22 then
-- rpm
isSlowUpdate = true
@@ -382,78 +415,83 @@ function fanatecDigitsEvent(swFunction)
if isAppRFactor(sim) or sim == "GTR2.exe" then inf = KtoC(inf) end
fPanel = string.format("%3.0f", inf)
end
-
+
+ elseif swValue == 41 then
+ -- PIT
+ fPanel = "PIt"
+
+ elseif swValue == 42 then
+ -- sc
+ local sc = GetContextInfo("safetycare")
+ if sc == 1 then
+ fPanel = " SC"
+ else
+ fPanel = " "
+ end
+
else
fPanel = " "
end
- if timeFlag and lpt ~= nil then
+ -- the function below has been replaced with generic time display function in global.lua
- -- set char of negative number
- local c = ""
- if lpt < 0 then c = "-" end
+ -- if timeFlag and lpt ~= nil then
- -- explod time
- hr, mn, sc, hd, ms = timeDispatcher(lpt)
+ -- -- explod time
+ -- hr, mn, sc, hd, ms = timeDispatcher(lpt)
- --print("lpt: " .. lpt .. " m: " .. mn .. " - s: " .. sc .. " - ms: " .. ms .."\n" )
+
+ -- print("lpt:" .. lpt .. " mn:" .. mn .. " sc:" .. sc .. " hd:" .. hd .. " ms:" .. ms .."\n" )
- -- update display every mDeltaTimeDelay time
- if GetTicks() > (mDeltaTimeDelay + mDeltaTimeOldTicks ) then
- mDeltaTimeOldTicks = GetTicks()
+ -- -- update display every mDeltaTimeDelay time
+ -- -- current ticks > old backuped value
+ -- if GetTicks() > mDeltaTimeOldTicks then
+ -- -- store ticks + delay
+ -- mDeltaTimeOldTicks = GetTicks() + ( 2 * mDeltaTimeDelay)
- if lpt == -1 or (mn + sc + ms) == 0.0000 then
- mDeltaTimeBackup = "-.--"
+ -- if lpt == -1 or (mn + sc + ms) == 0.00 then
+ -- mDeltaTimeBackup = "-.--"
- -- > 9mn
- elseif mn > 9 then
- if c == "" then
- mDeltaTimeBackup = string.format( "%2d.%1d", mn, sc)
- else
- mDeltaTimeBackup = string.format( "%s%2d", c, mn)
- end
+ -- elseif mn > 0 or sc >= 10 then
- -- < 10mn
- elseif mn > 0 and mn < 10 then
- if c == "" then
- mDeltaTimeBackup = string.format( "%1d.%02d", mn, sc)
- else
- mDeltaTimeBackup = string.format( "%s %1d", c, mn)
- end
+ -- if dlt and mn <100 then
+ -- -- display time and mn < 100
+ -- if mn >=10 then
+ -- -- mn > 10
+ -- mDeltaTimeBackup = string.format( "%2d.%01d", mn, sc)
+ -- else
+ -- mDeltaTimeBackup = string.format( "%1d.%02d", mn, sc)
+ -- end
+ -- else
+ -- -- delta > 9.99s or lap time > 100mn
+ -- mDeltaTimeBackup = " . "
+ -- end
- else
- -- mn == 0 ; sc > 9
- if sc > 9 then
- if c == "" then
- mDeltaTimeBackup = string.format( "%2d.%1d", sc, ms)
- else
- mDeltaTimeBackup = string.format( "%s%2d.", c, sc)
- end
- else
- -- sc < 10
- if c == "" then
- mDeltaTimeBackup = string.format( "%1d.%02d", sc, ms)
- else
- mDeltaTimeBackup = string.format( "%s%1d.%1d", c, sc, ms)
- end
- end
- end
- end
+ -- else
+ -- -- delta
+ -- if lpt < 0 then
+ -- -- negative value
+ -- mDeltaTimeBackup = string.format( "-%01d.%01d ", sc, round(hd))
+ -- else
+ -- mDeltaTimeBackup = string.format( "%01d.%02d", sc, round(hd))
+ -- end
+ -- end
+ -- end
- --print(fPanel,mDeltaTimeBackup)
- fPanel = mDeltaTimeBackup
- end
+ -- fPanel = mDeltaTimeBackup
+ -- end
- if isSlowUpdate then
-
+ if isSlowUpdate then
+ -- request slow display update
if GetTicks() > ( mDeltaTimeDelay + mDeltaTimeOldTicks ) then
mDeltaTimeOldTicks = GetTicks()
mFanatecText = fPanel
- -- print(GetTicks() .. mFanatecText .."\n")
end
else
+ -- normal display update
mFanatecText = fPanel
end
+
-- send string to sli manager
SetFanatecDigits( mFanatecText )
return 1