summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugues Hiegel <hugues@hiegel.fr>2013-03-01 10:19:54 +0100
committerHugues Hiegel <hugues@hiegel.fr>2013-03-01 10:32:01 +0100
commit6ea53840c9cb9b99c41fbb4d87a1acac8c0889e5 (patch)
tree787f03925be4c43f288b319333004d34666a4f63
parent43da8901ecb4511b44deb06351d96b786cd418e1 (diff)
SLIMaxMgr III beta
-rwxr-xr-xscripts/controls.lua61
-rwxr-xr-xscripts/devhook.lua10
-rwxr-xr-xscripts/enter_exit_session.lua8
-rwxr-xr-xscripts/fanatec.lua462
-rwxr-xr-xscripts/fanatec_iracing.lua11
-rwxr-xr-xscripts/gear.lua67
-rwxr-xr-xscripts/global.lua39
-rwxr-xr-xscripts/global_custom_scripts.lua97
-rwxr-xr-xscripts/osp.lua317
-rwxr-xr-xscripts/shiftlights.lua925
-rwxr-xr-xscripts/slidevice.lua13
-rwxr-xr-xscripts/sliemu_iracing.lua11
-rwxr-xr-xscripts/slim_iracing.lua11
-rwxr-xr-xscripts/slimax_script_readme.txt253
-rwxr-xr-xscripts/slipro.lua34
-rwxr-xr-xscripts/slipro_iracing.lua11
-rwxr-xr-xscripts/speedlimiter.lua324
-rwxr-xr-xscripts/zdoc_scripts/iracing_common_scripts.lua83
-rwxr-xr-xscripts/zdoc_scripts/iracing_stuff.lua158
19 files changed, 2358 insertions, 537 deletions
diff --git a/scripts/controls.lua b/scripts/controls.lua
index c8bf526..e0ce14d 100755
--- a/scripts/controls.lua
+++ b/scripts/controls.lua
@@ -1,8 +1,7 @@
--- SLIMax Mgr Lua Script v2
--- Copyright (c)2011-2013 by EK and Zappadoc - All Rights Reserved.
--- Use this script to control any button or switch
+-- SLIMax Mgr Lua Script v3
+-- Copyright (c)2012-2013 by Zappadoc - All Rights Reserved.
--- param deviceIdx = (see mDeviceType table)
+-- param deviceIdx = (see GetDeviceType() )
-- param ctrlType = type of ctrl, switch (0) or button (1)
-- param ctrlPos = ctrl index, switch from 1 to 6 and button from 1 to n
-- param value = ctrl value, button down (>0) or up (==0) and switch from 1 to 12
@@ -25,11 +24,12 @@ function controlsEvent(deviceIdx, ctrlType, ctrlPos, value, funcIndex)
local loopFlag = false
local dev = ""
- dev = mDeviceType[deviceIdx]
+ dev = GetDeviceType(deviceIdx)
if dev == nil then dev = "none" end
-- switches and buttons
-- ctrl change event
local state = 0
+ local ftecStr = ""
local leftStr = ""
local rightStr = ""
@@ -98,7 +98,57 @@ function controlsEvent(deviceIdx, ctrlType, ctrlPos, value, funcIndex)
state = 1
-- set timeout
oldTcks = GetTicks() + delay
+
+ elseif dev == "FANATEC" and IsSLIFunction("ospmethod", funcIndex) and mFanatecOSPFeedbackAllowed then
+ -- fanatec speedlimitermethod feedback
+ local info = GetContextInfo("ospmethod")
+ ftecStr = ftecStr.format("P%2d", info+1)
+
+ -- set digits
+ SetFanatecDigits(ftecStr)
+ FanatecSendReport(0)
+
+ state = 1
+ -- set timeout
+ oldTcks = GetTicks() + delay
+ elseif dev == "FANATEC" and IsSLIFunction("shiftlightsmethod", funcIndex) and mFanatecShiftlightsFeedbackAllowed then
+ -- fanatec speedlimitermethod feedback
+ local info = GetContextInfo("shiftlightsmethod")
+ ftecStr = ftecStr.format("P%2d", info+1)
+ -- set digits
+ SetFanatecDigits(ftecStr)
+ FanatecSendReport(0)
+
+ state = 1
+ -- set timeout
+ oldTcks = GetTicks() + delay
+ elseif dev == "FANATEC" and IsSLIFunction("speedlimitermethod", funcIndex) and mFanatecSpeedLimiterFeedbackAllowed then
+ -- fanatec speedlimitermethod feedback
+ local info = GetContextInfo("speedlimitermethod")
+ ftecStr = ftecStr.format("P%2d", info+1)
+
+ -- set digits
+ SetFanatecDigits(ftecStr)
+ FanatecSendReport(0)
+
+ state = 1
+ -- set timeout
+ oldTcks = GetTicks() + delay
+
+ elseif IsSLIFunction("fanatecdigits", funcIndex) and mFanatecDigitsFeedbackAllowed then
+ -- fanatecdigits feedback
+ local info = GetContextInfo("fanatecdigits")
+ ftecStr = ftecStr.format("P%2d", info+1)
+
+ -- set digits
+ SetFanatecDigits(ftecStr)
+ FanatecSendReport(0)
+
+ state = 1
+ -- set timeout
+ oldTcks = GetTicks() + delay
+
elseif IsSLIFunction("rightdigits", funcIndex) and mRightDigitsFeedbackAllowed then
-- rightdigits feedback
local info = false
@@ -147,6 +197,7 @@ function controlsEvent(deviceIdx, ctrlType, ctrlPos, value, funcIndex)
oldTcks = GetTicks() + delay
end
else
+
if ctrlType == 0 then
-- switch
diff --git a/scripts/devhook.lua b/scripts/devhook.lua
index 90a8099..28c40e1 100755
--- a/scripts/devhook.lua
+++ b/scripts/devhook.lua
@@ -1,10 +1,8 @@
--- SLIMax Mgr Lua Script v2
--- Copyright (c)2011-2013 by EK and Zappadoc - All Rights Reserved.
--- Use this script to bypass any previous functions and show what
--- you want onto your device.
+-- SLIMax Mgr Lua Script v3
+-- Copyright (c)2012-2013 by Zappadoc - All Rights Reserved.
--- param = device type (integer - see mDeviceType table)
+-- param = device type (integer - see GetDeviceType() )
-- return 1 to send processed data to the device and bypass Mgr
-- return 0 to skip and give the control to Mgr
function deviceReport(devType)
@@ -21,7 +19,6 @@ function deviceReport(devType)
-- if result = 1 bypass the script below and return 1
if result <= 1 then return result end
-- if result >= 2 continue
-
-- sim paused?
local paused = GetContextInfo("paused")
@@ -30,6 +27,7 @@ function deviceReport(devType)
if paused or spdLmt == 0 then
-- reset value
SetDigitsAllowed(true)
+ SetFanatecDigitsAllowed(true)
end
diff --git a/scripts/enter_exit_session.lua b/scripts/enter_exit_session.lua
index d720070..b9b761b 100755
--- a/scripts/enter_exit_session.lua
+++ b/scripts/enter_exit_session.lua
@@ -1,8 +1,8 @@
--- SLIMax Mgr Lua Script v2
--- Copyright (c)2011-2013 by EK and Zappadoc - All Rights Reserved.
+-- SLIMax Mgr Lua Script v3
+-- Copyright (c)2012-2013 by Zappadoc - All Rights Reserved.
-- Event received when the car enter and exit the session.
--- param = device type (integer - see mDeviceType table)
+-- param = device type (integer - see GetDeviceType() )
-- enter session
function enterSessionEvent(devType)
-- call custom script
@@ -19,7 +19,7 @@ function enterSessionEvent(devType)
return 1
end
--- param = device type (integer - see mDeviceType table)
+-- param = device type (integer - see GetDeviceType() )
-- exit session
function exitSessionEvent(devType)
-- call custom script
diff --git a/scripts/fanatec.lua b/scripts/fanatec.lua
new file mode 100755
index 0000000..90e44f1
--- /dev/null
+++ b/scripts/fanatec.lua
@@ -0,0 +1,462 @@
+-- Fanatec Lua Script v1.0
+-- 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
+
+-- ============================================================
+-- Digits Panel functions
+-- ============================================================
+
+-- IN function of digits panel
+-- param: recieve from SLIMax Manager the current switch position
+function fanatecDigitsEvent(swFunction)
+ swValue = swFunction + 1
+ -- call custom script
+ local result = custom_fanatecDigitsEvent(swValue)
+ -- if result = 0 bypass the script below and return 0
+ -- if result = 1 bypass the script below and return 1
+ if result <= 1 then return result end
+ -- if result >= 2 continue
+
+ -- call global custom script
+ result = global_custom_fanatecDigitsEvent(swValue)
+ -- if result = 0 bypass the script below and return 0
+ -- if result = 1 bypass the script below and return 1
+ if result <= 1 then return result end
+ -- if result >= 2 continue
+
+ local hr = 0
+ local mn = 0
+ local sc = 0
+ local ms = 0
+ local hd = 0
+ local lpt = 0.0
+ local timeFlag = false
+ local unit = false
+ local fPanel = ""
+ local inf = ""
+ local unit = false
+ local spd = 0.0
+ local isSlowUpdate = false
+
+ -- get speed in kph or mph (use "rawspeed" to get value in meter/sec)
+ local spd = GetCarInfo("speed")
+
+ -- get current display unit metric or imperial
+ unit = GetContextInfo("speedmetric")
+
+ -- check if quick info button is down
+ local qi = false
+ qi = GetContextInfo("quickinfobutton")
+ if qi == nil or qi == 0 then qi = false end
+ if qi then
+ -- get index for fanatec panel
+ local qiF = GetContextInfo("fanatecquickinfo")
+ if qiF == nil then qiF = 1 end
+ -- force position to match QI preference
+ swValue = qiF
+ end
+
+ -- get current simulation name
+ local sim = GetContextInfo("simulation")
+
+ -- is OSP Tracking ON
+ local ospt = false
+ ospt = GetContextInfo("osptracking")
+ if ospt == nil then ospt = false end
+ if ospt then
+ -- show rpm
+ swValue = 22
+ end
+
+ -- lap finished, display lap time a few seconds
+ local dlt = false
+ dlt = GetContextInfo("displaylaptime")
+ if dlt == nil then dlt = false end
+ if dlt then
+ swValue = 11
+ 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")
+
+ -- get neutral
+ local n = string.char(GetContextInfo("neutral"))
+ -- get reverse char and convert to string
+ local r = string.char(GetContextInfo("reverse"))
+ -- get state of custom Optimal Shift Point (OSP) records
+ local ospcustom_on = GetContextInfo("ospcustom")
+
+
+ -- set neutral, reverse or current gear
+ if g == 0 then
+ -- if neutral and using custom OSP record then add a dot to gear digit
+ SetFanatecGear(n, ospcustom_on)
+
+ elseif g < 0 then
+ -- reverse
+ SetFanatecGear(r, false)
+
+ else
+ -- if gear = 'E' give the hand to SLIMax Manager
+ -- if g == 69 then
+ -- return 0
+ -- end
+
+ SetFanatecGear(string.char(g), false)
+ end
+
+ return 1
+ end
+
+ elseif swValue == 2 then
+ -- speed
+ if round(spd) > 0 then
+ fPanel = string.format("%3d", round(spd) )
+ else
+ fPanel = "___"
+ end
+
+ elseif swValue == 3 then
+ -- fuel
+ local fuel = GetCarInfo("fuel")
+ if fuel ~= nil then
+ fuel = GetFuel(fuel, unit)
+ if fuel >= 100 then
+ fPanel = string.format("%03d", round(fuel) )
+ elseif fuel >= 10 then
+ fPanel = string.format("F%02d", round(fuel))
+ else
+ fPanel = string.format("F%1.1f", fuel)
+ end
+ end
+
+ elseif swValue == 4 then
+ -- position
+ inf = GetContextInfo("position")
+ if inf ~= nil then
+ if inf >= 100 then
+ fPanel = string.format("%03d", inf)
+ else
+ fPanel = string.format("P%02d", inf)
+ end
+ end
+
+ elseif swValue == 5 then
+ -- laps completed
+ inf = GetContextInfo("laps")
+ if inf ~= nil then
+ -- if more then 99 laps
+ if inf >= 100 then
+ fPanel = string.format("%3.0f", inf)
+ else
+ fPanel = string.format("L%2.0f", inf)
+ end
+ end
+
+ elseif swValue == 6 then
+ -- sector
+ local sect = GetCarInfo("sector")
+ -- check if sector > 9
+ if sect >9 then
+ fPanel = string.format("S%2d", sect)
+ else
+ fPanel = string.format("S%1d ", sect)
+ end
+
+ elseif swValue == 7 then
+ -- total laps
+ local tl = GetContextInfo("lapscount")
+ if tl < 1 then tl = 0 end
+ -- if more then 99 laps
+ if tl >= 100 or tl >= 100 then
+ fPanel = string.format("%03d", tl)
+ else
+ fPanel = string.format("t%02d", tl)
+ end
+
+ elseif swValue == 8 then
+ -- water temp
+ inf = GetCarInfo("watertemp")
+ if inf ~= nil then
+ inf = GetTemp(inf, unit)
+ fPanel = string.format("%2.1f", inf)
+ end
+
+ elseif swValue == 9 then
+ -- oil temp
+ inf = GetCarInfo("oiltemp")
+ if inf ~= nil then
+ inf = GetTemp(inf, unit)
+ fPanel = string.format("%2.1f", inf)
+ end
+
+ elseif swValue == 10 then
+ -- best lap time
+ timeFlag = true
+ lpt = GetTimeInfo("bestlaptime")
+
+ elseif swValue == 11 then
+ -- last lap time
+ timeFlag = true
+ lpt = GetTimeInfo("lastlaptime")
+
+ elseif swValue >= 12 and swValue <= 18 and isAppIRacing(sim) then
+ timeFlag = true
+ -- iRacing partials
+ local ts = GetContextInfo("partialcount")
+ local sector = GetCarInfo("sector")
+ if ts ~= nil and ts > 0 then
+ if swValue == 12 then
+ lpt = GetPartialTimeInfo("currentpartial", sector)
+ elseif swValue == 13 then
+ lpt = GetPartialTimeInfo("vsbestlap", sector)
+ elseif swValue == 14 then
+ lpt = GetPartialTimeInfo("vsoptimallap", sector)
+ elseif swValue == 15 then
+ lpt = GetPartialTimeInfo("vsoptimalsector", sector)
+ elseif swValue == 16 then
+ lpt = GetPartialTimeInfo("vssessionbestlap", sector)
+ elseif swValue == 17 then
+ lpt = GetPartialTimeInfo("vssessionoptimallap", sector)
+ elseif swValue == 18 then
+ lpt = GetPartialTimeInfo("vssessionoptimalsector", sector)
+ end
+ else
+ lpt = 0.0
+ end
+
+ elseif swValue == 19 then
+ -- real time diff vs your best
+ timeFlag = true
+ lpt = GetTimeInfo("realdiffbest")
+
+ elseif swValue == 20 then
+ -- real time diff vs your last
+ timeFlag = true
+ lpt = GetTimeInfo("realdifflast")
+
+ elseif swValue == 21 then
+ -- logo
+ fPanel = "SMX"
+
+ elseif swValue == 22 then
+ -- rpm
+ isSlowUpdate = true
+ local rpm = GetCarInfo("rpm")
+ local r = rpm / 100.0
+ if r < 100 then
+ fPanel = string.format("%2.1f", r)
+ else
+ fPanel = string.format("%3d.", round(r))
+ end
+ elseif swValue == 23 then
+ -- track size
+ isSlowUpdate = true
+ local trcksz = GetContextInfo("tracksize")
+ local r = trcksz / 100
+ if r < 100 then
+ fPanel = string.format("%2.1f", r)
+ else
+ fPanel = string.format("%3d.", round(r))
+ end
+
+ elseif swValue == 24 then
+ -- distance percent
+ local dist = GetContextInfo("lapdistance")
+ -- track size
+ local trcksz = GetContextInfo("tracksize")
+ local p = round(dist / (trcksz / 100))
+ fPanel = string.format("%3d", p )
+
+ elseif swValue == 25 then
+ -- kers
+ local kers = GetCarInfo("kers")
+ fPanel = string.format("%3d", round(kers/1000))
+
+ elseif swValue == 26 then
+ -- kers max
+ local kmx = GetCarInfo("kersmax")
+ fPanel = string.format("%3d", round(kmx/1000))
+
+ elseif swValue == 27 then
+ -- drs
+ local drs = GetCarInfo("drs")
+ if drs == 1 then
+ fPanel = "ON "
+ else
+ fPanel = "OFF"
+ end
+
+ elseif swValue == 28 then
+ -- kers percent
+ local kers = GetCarInfo("kers")
+ fPanel = string.format("%3d", round((kers/1000)/4))
+
+ elseif swValue == 29 then
+ -- wheels temp if available
+ inf = GetCarInfo("wheeltempfrontleft")
+ if inf ~= nil then
+ -- if rFactor convert Kelvin to Celsius (see global.lua)
+ if isAppRFactor(sim) then inf = KtoC(inf) end
+ fPanel = string.format("%3.0f", inf)
+ end
+
+ elseif swValue == 30 then
+ inf = GetCarInfo("wheeltempfrontright")
+ if inf ~= nil then
+ if isAppRFactor(sim) then inf = KtoC(inf) end
+ fPanel = string.format("%3.0f", inf)
+ end
+
+ elseif swValue == 31 then
+ inf = GetCarInfo("wheeltemprearleft")
+ if inf ~= nil then
+ if isAppRFactor(sim) then inf = KtoC(inf) end
+ fPanel = string.format("%3.0f", inf)
+ end
+
+ elseif swValue == 32 then
+ inf = GetCarInfo("wheeltemprearright")
+ if inf ~= nil then
+ if isAppRFactor(sim) then inf = KtoC(inf) end
+ fPanel = string.format("%3.0f", inf)
+ end
+
+ elseif swValue == 33 then
+ -- wheels pressure if available
+ inf = GetCarInfo("wheelpressfrontleft")
+ if inf ~= nil then
+ -- convert to psi
+ fPanel = string.format("%2.1f", inf / 6.88)
+ end
+
+ elseif swValue == 34 then
+ inf = GetCarInfo("wheelpressfrontright")
+ if inf ~= nil then
+ fPanel = string.format("%2.1f", inf / 6.88)
+ end
+
+ elseif swValue == 35 then
+ inf = GetCarInfo("wheelpressrearleft")
+ if inf ~= nil then
+ fPanel = string.format("%2.1f", inf / 6.88)
+ end
+
+ elseif swValue == 36 then
+ inf = GetCarInfo("wheelpressrearright")
+ if inf ~= nil then
+ fPanel = string.format("%2.1f", inf / 6.88)
+ end
+
+ elseif swValue == 37 then
+ -- brakes temp if available
+ inf = GetCarInfo("braketempfrontleft")
+ if inf ~= nil then
+ if isAppRFactor(sim) or sim == "GTR2.exe" then inf = KtoC(inf) end
+ fPanel = string.format("%3.0f", inf)
+ end
+
+ elseif swValue == 38 then
+ inf = GetCarInfo("braketempfrontright")
+ if inf ~= nil then
+ if isAppRFactor(sim) or sim == "GTR2.exe" then inf = KtoC(inf) end
+ fPanel = string.format("%3.0f", inf)
+ end
+
+ elseif swValue == 39 then
+ inf = GetCarInfo("braketemprearleft")
+ if inf ~= nil then
+ if isAppRFactor(sim) or sim == "GTR2.exe" then inf = KtoC(inf) end
+ fPanel = string.format("%3.0f", inf)
+ end
+
+ elseif swValue == 40 then
+ inf = GetCarInfo("braketemprearright")
+ if inf ~= nil then
+ if isAppRFactor(sim) or sim == "GTR2.exe" then inf = KtoC(inf) end
+ fPanel = string.format("%3.0f", inf)
+ end
+
+ else
+ fPanel = " "
+ end
+
+ if timeFlag and lpt ~= nil then
+
+ -- set char of negative number
+ 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 .."\n" )
+
+ -- update display every mDeltaTimeDelay time
+ if GetTicks() > (mDeltaTimeDelay + mDeltaTimeOldTicks ) then
+ mDeltaTimeOldTicks = GetTicks()
+
+ if lpt == -1 or (mn + sc + ms) == 0.0000 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
+
+ -- < 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
+
+ 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
+
+ --print(fPanel,mDeltaTimeBackup)
+ fPanel = mDeltaTimeBackup
+ end
+
+ if isSlowUpdate then
+
+ if GetTicks() > ( mDeltaTimeDelay + mDeltaTimeOldTicks ) then
+ mDeltaTimeOldTicks = GetTicks()
+ mFanatecText = fPanel
+ -- print(GetTicks() .. mFanatecText .."\n")
+ end
+ else
+ mFanatecText = fPanel
+ end
+ -- send string to sli manager
+ SetFanatecDigits( mFanatecText )
+ return 1
+end
+
+
diff --git a/scripts/fanatec_iracing.lua b/scripts/fanatec_iracing.lua
new file mode 100755
index 0000000..a84c983
--- /dev/null
+++ b/scripts/fanatec_iracing.lua
@@ -0,0 +1,11 @@
+-- iRacing Combo Setup - Custom Scripts - SLIMax Manager Scripts v3
+-- Copyright ©2012-2013 by Zappadoc - All Rights Reserved.
+-- last change by Zappadoc - 2013-02
+
+-- ================================
+-- add the short desciption of your script(s) in mScript_Info global var
+mScript_Info = "A useful iRacing custom scripts to select automatically the good settings for each iracing car you drive (shiftlights, max gears, osp, et.)."
+
+-- ================================
+-- load common scripts file
+require "scripts/zdoc_scripts/iracing_common_scripts" \ No newline at end of file
diff --git a/scripts/gear.lua b/scripts/gear.lua
index d7cb61e..88dad9f 100755
--- a/scripts/gear.lua
+++ b/scripts/gear.lua
@@ -1,7 +1,7 @@
--- SLIMax Mgr Lua Script v2
--- Copyright (c)2011-2013 by EK and Zappadoc - All Rights Reserved.
+-- SLIMax Mgr Lua Script v3
+-- Copyright (c)2012-2013 by Zappadoc - All Rights Reserved.
-- gear event
--- last change by Zappadoc - 2012-04-08
+-- last change by Zappadoc - 2013-02-15
-- SLI-M, SLI-PRO Gear Event
function gearEvent(gear)
@@ -27,7 +27,7 @@ function gearEvent(gear)
if result <= 1 then return result end
local g = gear
- if oldGear == nil then oldGear = GetContextInfo("neutral") end
+ if oldGear == nil then oldGear = -1 end
-- get neutral
local n = GetContextInfo("neutral")
@@ -35,9 +35,11 @@ function gearEvent(gear)
local r = string.char(GetContextInfo("reverse"))
-- get state of custom Optimal Shift Point (OSP) records
local ospcustom_on = GetContextInfo("ospcustom")
-
+
-- optimize display, call if changed
- if oldGear ~= g or g == 0 then
+ if oldGear ~= g then
+ -- backup gear state
+ oldGear = g
-- set neutral, reverse or current gear
if g == 0 then
-- if neutral and using custom OSP record then add a dot to gear digit
@@ -46,20 +48,61 @@ function gearEvent(gear)
elseif g < 0 then
SetGearDigit(r)
else
- -- if gear = 'E' give the hand to SLIMax Manager II
+ -- if gear = 'E' give the hand to SLIMax Manager
if g == 69 then
return 0
end
SetGearDigit(string.char(g))
end
-
+ end
+
+ return 1
+end
- -- print( string.format("Gear: %d\n", gear))
+-- Fanatec Gear Event
+function gearFanatecEvent(gear)
+ -- get the rpm limit already computed by my OSP method
+ -- using OSP Factor parameter
+ -- value used in OSP, Shiftlights, car setup,... and can be overwritten
+ gOSPLimit = 0
+ gOSPLimit = GetContextInfo("osplimitrpm")
+ if gOSPLimit == nil then gOSPLimit = 0 end
+
+ -- get the red zone already computed by my SLIMax Mgr
+ -- value used in Shiftlights and can be overwritten
+ gRedZone = 0
+ gRedZone = GetCarInfo("redzone")
+ if gRedZone == nil then gRedZone = 18000 end
+
+ -- call custom script
+ local result = custom_gearEvent(gear)
+ if result <= 1 then return result end
+
+ -- call global custom script
+ result = global_custom_gearEvent(gear)
+ if result <= 1 then return result end
+
+ local g = gear
+ if oldGear == nil then oldGear = -1 end
+
+ if oldGear ~= g then
+ local rumbbleGear = GetContextInfo("gearshock")
+ local rumbbleGearDelay = GetContextInfo("gearshockdelay")
+
+ -- gear schock effect restricted to 1 to 7
+ if rumbbleGear and g > 0 then
+ if g < oldGear then
+ SetFanatecWheelMotor(0, 100, rumbbleGearDelay)
+ elseif g > oldGear then
+ SetFanatecWheelMotor(1, 100, rumbbleGearDelay)
+ end
+ end
+
+ -- backup gear state
+ oldGear = g
end
- -- backup gear state
- oldGear = g
return 1
-end \ No newline at end of file
+end
diff --git a/scripts/global.lua b/scripts/global.lua
index 2d6cf3e..39bde4a 100755
--- a/scripts/global.lua
+++ b/scripts/global.lua
@@ -412,29 +412,26 @@ function SetDeltaTimeDelay(delay)
mDeltatimeDelay = delay
end
--- get current gear (even when engine/ignition is off)
+-- get current gear
function GetCurrentGear()
- local g = GetCarInfo("gear")
- -- get neutral
- local n = GetContextInfo("neutral")
- -- get reverse char and convert to string
- local r = string.char(GetContextInfo("reverse"))
- -- get state of custom Optimal Shift Point (OSP) records
- local ospcustom_on = GetContextInfo("ospcustom")
-
- -- set neutral, reverse or current gear
- local result = g
-
- if g == 0 then
- -- if neutral and using custom OSP record then add a dot to gear digit
- if ospcustom_on then n = n + 128 end
- result = string.char(n)
- elseif g < 0 then
- -- reverse
- result = r
- end
+ local g = GetCarInfo("gear")
+ -- get neutral
+ local n = string.char(GetContextInfo("neutral"))
+ -- get reverse char and convert to string
+ local r = string.char(GetContextInfo("reverse"))
+
+ -- set neutral, reverse or current gear
+ local result = g
+
+ if g == 0 then
+ -- neutral
+ result = n
+ elseif g < 0 then
+ -- reverse
+ result = r
+ end
- return result
+ return result
end
diff --git a/scripts/global_custom_scripts.lua b/scripts/global_custom_scripts.lua
index fcdfcf7..752dce5 100755
--- a/scripts/global_custom_scripts.lua
+++ b/scripts/global_custom_scripts.lua
@@ -1,6 +1,6 @@
--- Global Custom SLIMax Manager Scripts v2.2
--- Copyright ©2011-2013 by Zappadoc - All Rights Reserved.
--- last change by Zappadoc - 2012-11
+-- Global Custom SLIMax Manager Scripts v3
+-- Copyright ©2012-2013 by Zappadoc - All Rights Reserved.
+-- last change by Zappadoc - 2013-02
-- add you global custom functions and globals variables here
-- patch the std SLIMax Events with your global custom scripts if needed
@@ -18,19 +18,18 @@
-- ================================
--- additional scripts file
+-- additional scripts file ( use 'require' statement )
-- ================================
-- custom globals
-
-- ================================
-- custom functions
-- ================================
-- custom events
-function global_custom_controlsEvent(deviceIdx, ctrlType, ctrlPos, value, funcIndex)
+function global_custom_controlsEvent(devType, ctrlType, ctrlPos, value, funcIndex)
-- type your custom controls script here (manage buttons, switches and encoders)
return 2
end
@@ -40,13 +39,27 @@ function global_custom_deviceReport(devType)
return 2
end
+function global_custom_enterSessionEvent(devType)
+ -- type your custom script on session start, here
+ return 2
+end
+
+function global_custom_exitSessionEvent(devType)
+ -- type your custom script on session ending, here
+ return 2
+end
+
+
+-- ================================
+-- SLI-PRO, SLI-M, BU0710 SUPPORT
+
function global_custom_ospMethodEvent(idx)
-- type your custom Optimal Shift Points (OSP) method here
return 2
end
function global_custom_shiftLightsMethodEvent(idx)
- -- type your custom shiftlights method here
+ -- type your custom shiftlights method here
return 2
end
@@ -66,55 +79,65 @@ function global_custom_rightDigitsEvent(swPosition)
end
function global_custom_spdLmtMethodEvent(idx)
- -- type your custom script related to speed limiter here
+ -- type your custom speedlimiter method here
return 2
end
function global_custom_gearEvent(gear)
-- type your custom gear event script here
- -- check if gear == 'E' (see ascii table )
- if gear == 69 then
+ return 2
+end
- -- toggle OFF in this example
- toggleAllLed(0)
+function global_custom_ledEvent(idx, ledFunction, state)
+ -- type your custom script on session ending, here
+ return 2
+end
- -- control gear digit display
- SetGearDigit(GetCurrentGear())
+-- ================================
+-- LOGITECH G27 SUPPORT
- -- control left panel (6 chars max)
- -- nothing display in this example
- local ldigits = " "
- SetLeftDigits( ldigits )
- -- control right panel (6 chars max)
- -- nothing display in this example
- local rdigits = " "
- SetRightDigits( rdigits )
+function global_custom_shiftLightsG27LedsMethodEvent(idx)
+ -- type your custom shiftlights method for G27 device only here
+ return 2
+end
- -- refresh SLI board
- SLISendReport(1)
+function global_custom_ospG27MethodEvent(idx)
+ -- type your custom Optimal Shift Points (OSP) method here
+ return 2
+end
- -- return 1 to bypass std behavior
- return 1
- end
+function global_custom_spdLmtG27MethodEvent(idx)
+ -- type your custom speedlimiter method here
+ return 2
+end
+
+-- ================================
+-- FANATEC WHEELS SUPPORT
+function global_custom_shiftLightsFanatecMethodEvent(idx)
+ -- type your custom shiftlights method for Fanatec device only here
return 2
end
-function global_custom_enterSessionEvent(devType)
- -- type your custom script related to session start here
+function global_custom_fanatecDigitsEvent(swPosition)
+ -- type your custom script related to Fanatec digits panel here
return 2
end
-function global_custom_exitSessionEvent(devType)
- -- type your custom script related to session stop here
+function global_custom_ospFanatecMethodEvent(idx)
+ -- type your custom Optimal Shift Points (OSP) method here
return 2
end
-function global_custom_ledEvent(idx, ledFunction, state)
- -- type your custom script related to LEDs here
+function global_custom_spdLmtFanatecMethodEvent(idx)
+ -- type your custom Optimal Shift Points (OSP) method here
return 2
end
+function global_custom_gearFanatecEvent(gear)
+ -- type your custom gear event script here
+ return 2
+end
-- ================================
-- local custom events PLACEHOLDERS
@@ -123,12 +146,20 @@ end
function custom_controlsEvent(deviceIdx, ctrlType, ctrlPos, value, funcIndex) return 2 end
function custom_deviceReport(devType) return 2 end
function custom_ospMethodEvent(idx) return 2 end
+function custom_ospG27MethodEvent(idx) return 2 end
+function custom_ospFanatecMethodEvent(idx) return 2 end
function custom_shiftLightsMethodEvent(idx) return 2 end
function custom_shiftLightsBU0710Event(idx) return 2 end
+function custom_shiftLightsG27LedsMethodEvent(idx) return 2 end
+function custom_shiftLightsFanatecMethodEvent(idx) return 2 end
function custom_leftDigitsEvent(swPosition) return 2 end
function custom_rightDigitsEvent(swPosition) return 2 end
+function custom_fanatecDigitsEvent(swPosition) return 2 end
function custom_spdLmtMethodEvent(idx) return 2 end
+function custom_spdLmtG27MethodEvent(idx) return 2 end
+function custom_spdLmtFanatecMethodEvent(idx) return 2 end
function custom_gearEvent(gear) return 2 end
+function custom_gearFanatecEvent(gear) return 2 end
function custom_enterSessionEvent(devType) return 2 end
function custom_exitSessionEvent(devType) return 2 end
function custom_ledEvent(idx, ledFunction, state) return 2 end
diff --git a/scripts/osp.lua b/scripts/osp.lua
index 03cea73..b5ff08c 100755
--- a/scripts/osp.lua
+++ b/scripts/osp.lua
@@ -1,7 +1,7 @@
--- SLIMax Mgr Lua Script v2.1
+-- SLIMax Mgr Lua Script v3
-- Copyright (c)2012-2013 by Zappadoc - All Rights Reserved.
--- Use this script to build all Optimal ShiftPoints methods (OSP)
--- last change by Zappadoc - 2012-12-17
+-- this script builds all Optimal ShiftPoints methods (OSP)
+-- last change by Zappadoc - 2013-02
function SetOSPFeedback(state)
if mOSPLED1 > 6 then
@@ -148,7 +148,316 @@ function ospMethodEvent(idx)
end
else
-- bypass (give control to manager)
- return 0
+ return 1
+ end
+ -- timebase
+ if GetTicks() > mOldOSPTickCount then
+ mOldOSPTickCount = GetTicks() + 10
+ end
+
+ return 1
+end
+
+
+-- G27 Methods Event
+function ospG27MethodEvent(idx)
+ mOSPMethod = idx
+ -- OSP Limit default value is set in gear.lua
+ if gOSPLimit == nil or gOSPLimit == 0 then gOSPLimit = GetContextInfo("osplimitrpm") end
+
+ -- call custom script (this is a good place to overwrite gOSPLimit value)
+ local result = custom_ospG27MethodEvent(mOSPMethod)
+ -- if result = 0 bypass the script below and return 0
+ -- if result = 1 bypass the script below and return 1
+ if result <= 1 then return result end
+ -- if result >= 2 continue
+
+ -- call global custom script (this is a good place to overwrite gOSPLimit value)
+ result = global_custom_ospG27MethodEvent(mOSPMethod)
+ -- if result = 0 bypass the script below and return 0
+ -- if result = 1 bypass the script below and return 1
+ if result <= 1 then return result end
+ -- if result >= 2 continue
+
+ -- check if globals initialized
+ if isGlobalInitialized == 0 then
+ isGlobalInitialized = 1
+ -- init
+ InitGlobals()
+ end
+ -- get global prefs
+ GetSLIMaxInfo()
+
+ local led = ""
+
+ -- get rpm
+ local rpm = 0
+ rpm = GetCarInfo("rpm")
+ if rpm == nil then rpm = 0 end
+
+ -- get current gear
+ local gear = 0
+ gear = GetCarInfo("gear")
+ if gear == nil then gear = 0 end
+
+ -- get max gear of current car
+ -- Alternate way to calc max gear if not available in API
+ -- Use a global mMaxGear and do the following
+ -- if gear > mMaxGear then mMaxGear = gear end local maxGear = 4
+
+ maxGear = GetCarInfo("maxgear")
+ if maxGear == nil then maxGear = 4 end
+
+ -- skip if neutral or ==maxgear
+ if gear <=0 or gear>=maxGear then
+ -- do nothing
+ return 1
+ end
+
+ -- print("MAXGear: " .. gear.."/"..maxGear.." OSP: " .. mOSPMethod .. " rpm: " .. rpm .. " - " .. gOSPLimit .. "\n")
+
+
+ -- skip if first gear not allowed
+ if not mOSPWithFirstGear and gear == 1 then
+ -- do nothing
+ return 1
+ end
+
+
+ -- rpm > osplimit so activate shiftpoints leds
+ if rpm > gOSPLimit then
+
+ mG27Leds = 0
+
+ -- no blinking allowed
+ if mNoBlink then
+ -- set all leds
+ mG27Leds = 0x1F;
+
+ else
+ if GetTicks() > mOldOSPTickCount then
+ mOSPBlink = mOSPBlink + 1
+ end
+
+ if mOSPMethod <= 1 or mOSPMethod > 3 then
+ -- methods 1 all blinking
+ if mOSPBlink >= mOSPBlinkTime then
+ mOSPBlink = 0
+ end
+
+ if mOSPBlink <= (mOSPBlinkTime / 2) then
+ mG27Leds = 0x1F;
+ end
+
+ if mOSPBlink > (mOSPBlinkTime / 2) then
+ mG27Leds = 0;
+ end
+ elseif mOSPMethod == 2 then
+ -- methods side blinking
+ if mOSPBlink >= mOSPBlinkTime then
+ mOSPBlink = 0
+ end
+
+ if mOSPBlink <= (mOSPBlinkTime / 2) then
+ mG27Leds = 0x3;
+ end
+
+ if mOSPBlink > (mOSPBlinkTime / 2) then
+ mG27Leds = 0;
+ end
+
+ elseif mOSPMethod == 3 then
+ -- methods 3 center blinking
+ if mOSPBlink >= mOSPBlinkTime then
+ mOSPBlink = 0
+ end
+
+ if mOSPBlink <= (mOSPBlinkTime / 2) then
+ mG27Leds = 0x18;
+ end
+
+ if mOSPBlink > (mOSPBlinkTime / 2) then
+ mG27Leds = 0;
+ end
+ end
+ end
+ SetG27Led(mG27Leds)
+ else
+ -- bypass (give control to manager)
+ return 1
+ end
+ -- timebase
+ if GetTicks() > mOldOSPTickCount then
+ mOldOSPTickCount = GetTicks() + 10
+ end
+
+ return 1
+end
+
+-- Fanatec OSP Methods Event
+function ospFanatecMethodEvent(idx)
+ mOSPMethod = idx
+ -- OSP Limit default value is set in gear.lua
+ if gOSPLimit == nil or gOSPLimit == 0 then gOSPLimit = GetContextInfo("osplimitrpm") end
+
+ -- call custom script (this is a good place to overwrite gOSPLimit value)
+ local result = custom_ospFanatecMethodEvent(mOSPMethod)
+ -- if result = 0 bypass the script below and return 0
+ -- if result = 1 bypass the script below and return 1
+ if result <= 1 then return result end
+ -- if result >= 2 continue
+
+ -- call global custom script (this is a good place to overwrite gOSPLimit value)
+ result = global_custom_ospFanatecMethodEvent(mOSPMethod)
+ -- if result = 0 bypass the script below and return 0
+ -- if result = 1 bypass the script below and return 1
+ if result <= 1 then return result end
+ -- if result >= 2 continue
+
+ -- check if globals initialized
+ if isGlobalInitialized == 0 then
+ isGlobalInitialized = 1
+ -- init
+ InitGlobals()
+ end
+ -- get global prefs
+ GetSLIMaxInfo()
+
+ local led = ""
+
+ -- get rpm
+ local rpm = 0
+ rpm = GetCarInfo("rpm")
+ if rpm == nil then rpm = 0 end
+
+ -- get current gear
+ local gear = 0
+ gear = GetCarInfo("gear")
+ if gear == nil then gear = 0 end
+
+ -- get max gear of current car
+ -- Alternate way to calc max gear if not available in API
+ -- Use a global mMaxGear and do the following
+ -- if gear > mMaxGear then mMaxGear = gear end local maxGear = 4
+
+ maxGear = GetCarInfo("maxgear")
+ if maxGear == nil then maxGear = 4 end
+
+ -- skip if neutral or ==maxgear
+ if gear <=0 or gear>=maxGear then
+ -- do nothing
+ return 1
+ end
+
+ -- skip if first gear not allowed
+ if not mOSPWithFirstGear and gear == 1 then
+ -- do nothing
+ return 1
+ end
+
+ -- rpm > osplimit so activate shiftpoints leds
+ if rpm > gOSPLimit then
+
+ -- no blinking allowed
+ if mNoBlink then
+ -- no led
+ else
+
+ if GetTicks() > mOldOSPTickCount then
+ mOSPBlink = mOSPBlink + 1
+ end
+
+ -- methods 1 to 4
+ if mOSPBlink >= mOSPBlinkTime then
+ mOSPBlink = 0
+ end
+
+ if mOSPBlink <= (mOSPBlinkTime / 2) then
+ if (mOSPMethod <= 0) or mOSPMethod > 4 then
+ -- blue leds blinking if method 0, ON
+ for i = 6,8 do
+ led = led.format("RPM%d",i)
+ mRPMLedTable[led] = 1
+ end
+
+ elseif mOSPMethod == 1 then
+ -- all leds blinking if method 1, ON
+ for i = 0,8 do
+ led = led.format("RPM%d",i)
+ mRPMLedTable[led] = 1
+ end
+
+ elseif mOSPMethod == 2 then
+ initLedTable(mRPMLedTable, 0)
+ -- side leds blinking if method 2, ON
+ mRPMLedTable["RPM0"] = 1
+ mRPMLedTable["RPM1"] = 1
+ mRPMLedTable["RPM7"] = 1
+ mRPMLedTable["RPM8"] = 1
+
+ elseif mOSPMethod == 3 then
+ initLedTable(mRPMLedTable, 0)
+ -- center leds blinking if method 3, ON
+ mRPMLedTable["RPM3"] = 1
+ mRPMLedTable["RPM4"] = 1
+ mRPMLedTable["RPM5"] = 1
+
+ elseif mOSPMethod == 4 then
+ initLedTable(mRPMLedTable, 0)
+ -- side fixed if method 4, ON
+ mRPMLedTable["RPM0"] = 1
+ mRPMLedTable["RPM1"] = 1
+ mRPMLedTable["RPM7"] = 1
+ mRPMLedTable["RPM8"] = 1
+ end
+ SetFanatecLed("mRPMLedTable")
+ end
+
+ if mOSPBlink > (mOSPBlinkTime / 2) then
+ if (mOSPMethod <= 0) or mOSPMethod > 4 then
+ -- blue leds blinking if method 0 , OFF
+ for i = 6,8 do
+ led = led.format("RPM%d",i)
+ mRPMLedTable[led] = 0
+ end
+
+ elseif mOSPMethod == 1 then
+ -- all leds blinking if method 1, OFF
+ for i = 0,8 do
+ led = led.format("RPM%d",i)
+ mRPMLedTable[led] = 0
+ end
+
+ elseif mOSPMethod == 2 then
+ initLedTable(mRPMLedTable, 0)
+ -- side leds blinking if method 2, OFF
+ mRPMLedTable["RPM0"] = 0
+ mRPMLedTable["RPM1"] = 0
+ mRPMLedTable["RPM7"] = 0
+ mRPMLedTable["RPM8"] = 0
+
+ elseif mOSPMethod == 3 then
+ initLedTable(mRPMLedTable, 0)
+ -- center leds blinking if method 3, OFF
+ mRPMLedTable["RPM3"] = 0
+ mRPMLedTable["RPM4"] = 0
+ mRPMLedTable["RPM5"] = 0
+
+ elseif mOSPMethod == 4 then
+ initLedTable(mRPMLedTable, 0)
+ -- side fixed if method 4, ON
+ mRPMLedTable["RPM0"] = 1
+ mRPMLedTable["RPM1"] = 1
+ mRPMLedTable["RPM7"] = 1
+ mRPMLedTable["RPM8"] = 1
+ end
+ SetFanatecLed("mRPMLedTable")
+ end
+ end
+
+ else
+ -- bypass (give control to manager)
+ return 1
end
-- timebase
if GetTicks() > mOldOSPTickCount then
diff --git a/scripts/shiftlights.lua b/scripts/shiftlights.lua
index 95e93f3..5e7f907 100755
--- a/scripts/shiftlights.lua
+++ b/scripts/shiftlights.lua
@@ -1,333 +1,592 @@
--- SLIMax Mgr Lua Script v2.3
--- Copyright (c)2011-2013 by EK and Zappadoc - All Rights Reserved.
--- Use this script to build all shiftlights methods
--- last change by Zappadoc - 2012-10-28
-
--- ==============================================================================
--- utilities functions and methods
--- ==============================================================================
--- SLI-M and SLI-PRO functions
-
--- shiftlights method from side to center
-function SideToCenterSLI(rpm, redzone, p1, p2, p3, p4 ,p5 ,p6 ,p7)
-
- local rz = redzone / 100
-
- -- side to center custom
- if rpm > (rz*p1) then mRPMLedTable.RPM0 = 1 end -- G
- if rpm > (rz*p1) then mRPMLedTable.RPM12 = 1 end -- B
-
- if rpm > (rz*p2) then mRPMLedTable.RPM1 = 1 end -- G
- if rpm > (rz*p2) then mRPMLedTable.RPM11 = 1 end -- B
-
- if rpm > (rz*p3) then mRPMLedTable.RPM2 = 1 end -- G
- if rpm > (rz*p3) then mRPMLedTable.RPM10 = 1 end -- B
-
- if rpm > (rz*p4) then mRPMLedTable.RPM3 = 1 end -- G
- if rpm > (rz*p4) then mRPMLedTable.RPM9 = 1 end -- B
-
- if rpm > (rz*p5) then mRPMLedTable.RPM8 = 1 end -- R
- if rpm > (rz*p5) then mRPMLedTable.RPM4 = 1 end -- R
-
- if rpm > (rz*p6) then mRPMLedTable.RPM5 = 1 end -- R
- if rpm > (rz*p6) then mRPMLedTable.RPM7 = 1 end -- R
-
- if rpm > (rz*p7) then mRPMLedTable.RPM6 = 1 end -- R
-
-end
-
--- progressive method
-function ProgressiveSLI(rpm, redzone, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13 )
- local rz = redzone / 13
- -- print("progessive")
- if rpm > (rz*p1) then mRPMLedTable.RPM0 = 1 end
- if rpm > (rz*p2) then mRPMLedTable.RPM1 = 1 end
- if rpm > (rz*p3) then mRPMLedTable.RPM2 = 1 end
- if rpm > (rz*p4) then mRPMLedTable.RPM3 = 1 end
-
- if rpm > (rz*p5) then mRPMLedTable.RPM4 = 1 end
- if rpm > (rz*p6) then mRPMLedTable.RPM5 = 1 end
- if rpm > (rz*p7) then mRPMLedTable.RPM6 = 1 end
- if rpm > (rz*p8) then mRPMLedTable.RPM7 = 1 end
- if rpm > (rz*p9) then mRPMLedTable.RPM8 = 1 end
-
- if rpm > (rz*p10) then mRPMLedTable.RPM9 = 1 end
- if rpm > (rz*p11) then mRPMLedTable.RPM10 = 1 end
- if rpm > (rz*p12) then mRPMLedTable.RPM11 = 1 end
- if rpm > (rz*p13) then mRPMLedTable.RPM12 = 1 end
-end
-
--- alternate green, red and blue method
-function AlternateSLI(rpm, redzone, step1, step2, step3)
-
- local rz = redzone / 13
- if rpm > (rz*step1) then
- mRPMLedTable.RPM0 = 1 -- G
- mRPMLedTable.RPM1 = 1 -- G
- mRPMLedTable.RPM2 = 1 -- G
- mRPMLedTable.RPM3 = 1 -- G
- end
- if rpm > (rz*step2) then
- mRPMLedTable.RPM4 = 1 -- R
- mRPMLedTable.RPM5 = 1 -- R
- mRPMLedTable.RPM6 = 1 -- R
- mRPMLedTable.RPM7 = 1 -- R
- mRPMLedTable.RPM8 = 1 -- R
- end
- if rpm > (rz*step3) then
- mRPMLedTable.RPM9 = 1 -- B
- mRPMLedTable.RPM10 = 1 -- B
- mRPMLedTable.RPM11 = 1 -- B
- mRPMLedTable.RPM12 = 1 -- B
- end
-end
-
-function PercentageSLI(rpm, redzone, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13 )
- local onePercent = redzone / 100
- if p1>0 and rpm >= (p1*onePercent) then mRPMLedTable.RPM0 = 1 end -- G
- if p2>0 and rpm >= (p2*onePercent) then mRPMLedTable.RPM1 = 1 end -- G
- if p3>0 and rpm >= (p3*onePercent) then mRPMLedTable.RPM2 = 1 end -- G
- if p4>0 and rpm >= (p4*onePercent) then mRPMLedTable.RPM3 = 1 end -- G
- if p5>0 and rpm >= (p5*onePercent) then mRPMLedTable.RPM4 = 1 end -- R
- if p6>0 and rpm >= (p6*onePercent) then mRPMLedTable.RPM5 = 1 end -- R
- if p7>0 and rpm >= (p7*onePercent) then mRPMLedTable.RPM6 = 1 end -- R
- if p8>0 and rpm >= (p8*onePercent) then mRPMLedTable.RPM7 = 1 end -- R
- if p9>0 and rpm >= (p9*onePercent) then mRPMLedTable.RPM8 = 1 end -- R
- if p10>0 and rpm >= (p10*onePercent) then mRPMLedTable.RPM9 = 1 end -- B
- if p11>0 and rpm >= (p11*onePercent) then mRPMLedTable.RPM10 = 1 end -- B
- if p12>0 and rpm >= (p12*onePercent) then mRPMLedTable.RPM11 = 1 end -- B
- if p13>0 and rpm >= (p13*onePercent) then mRPMLedTable.RPM12 = 1 end -- B
- -- print("RPM:".. rpm .. " Percentage:" .. onePercent .. " RZ:" .. gRedZone .. " P13:" .. mRPMLedTable.RPM12.. "\n")
-end
-
--- fixed rpm method, set rpm for each led (NOT RECOMMENDED)
-function RpmSLI(rpm, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13 )
- if p1>0 and rpm >= p1 then mRPMLedTable.RPM0 = 1 end -- G
- if p2>0 and rpm >= p2 then mRPMLedTable.RPM1 = 1 end -- G
- if p3>0 and rpm >= p3 then mRPMLedTable.RPM2 = 1 end -- Y
- if p4>0 and rpm >= p4 then mRPMLedTable.RPM3 = 1 end -- Y
- if p5>0 and rpm >= p5 then mRPMLedTable.RPM4 = 1 end -- R
- if p6>0 and rpm >= p6 then mRPMLedTable.RPM5 = 1 end -- R
- if p7>0 and rpm >= p7 then mRPMLedTable.RPM6 = 1 end -- G
- if p8>0 and rpm >= p8 then mRPMLedTable.RPM7 = 1 end -- G
- if p9>0 and rpm >= p9 then mRPMLedTable.RPM8 = 1 end -- Y
- if p10>0 and rpm >= p10 then mRPMLedTable.RPM9 = 1 end -- Y
- if p11>0 and rpm >= p11 then mRPMLedTable.RPM10 = 1 end -- R
- if p12>0 and rpm >= p12 then mRPMLedTable.RPM11 = 1 end -- R
- if p13>0 and rpm >= p13 then mRPMLedTable.RPM12 = 1 end -- R
-end
-
--- progressive method but with rpm value for eah led
-function ProgressiveFixedSLI(rpm, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13)
- -- progressive method with thresholds as parameters
- if rpm > p1 then mRPMLedTable.RPM0 = 1 end
- if rpm > p2 then mRPMLedTable.RPM1 = 1 end
- if rpm > p3 then mRPMLedTable.RPM2 = 1 end
- if rpm > p4 then mRPMLedTable.RPM3 = 1 end
-
- if rpm > p5 then mRPMLedTable.RPM4 = 1 end
- if rpm > p6 then mRPMLedTable.RPM5 = 1 end
- if rpm > p7 then mRPMLedTable.RPM6 = 1 end
- if rpm > p8 then mRPMLedTable.RPM7 = 1 end
- if rpm > p9 then mRPMLedTable.RPM8 = 1 end
-
- if rpm > p10 then mRPMLedTable.RPM9 = 1 end
- if rpm > p11 then mRPMLedTable.RPM10 = 1 end
- if rpm > p12 then mRPMLedTable.RPM11 = 1 end
- if rpm > p13 then mRPMLedTable.RPM12 = 1 end
-end
--- --------------------------------------------
--- BU0710 functions
-
--- progressive method for BU0710
-function ProgressiveBU0710(rpm, redzone, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11 )
- local rz = redzone / 10.0
- if rpm > (rz * p1) then mBU0710Leds = 0x1 end -- G
- if rpm > (rz * p2) then mBU0710Leds = 0x2 end -- G
- if rpm > (rz * p3) then mBU0710Leds = 0x3 end -- G
- if rpm > (rz * p4) then mBU0710Leds = 0x4 end -- Y
- if rpm > (rz * p5) then mBU0710Leds = 0x5 end -- Y
- if rpm > (rz * p6) then mBU0710Leds = 0x6 end -- Y
- if rpm > (rz * p7) then mBU0710Leds = 0x7 end -- R
- if rpm > (rz * p8) then mBU0710Leds = 0x8 end -- R
- if rpm > (rz * p9) then mBU0710Leds = 0x9 end -- R
- if rpm > (rz * p10) then mBU0710Leds = 0xA end -- R
- if rpm > (rz * p11) then mBU0710Leds = 0xB end -- RRRR
-end
-
--- percentage method for BU0710
-function PercentageBU0710(rpm, redzone, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11 )
- local onePercent = redzone / 100
- if rpm > (p1 * onePercent) then mBU0710Leds = 0x1 end -- G
- if rpm > (p2 * onePercent) then mBU0710Leds = 0x2 end -- G
- if rpm > (p3 * onePercent) then mBU0710Leds = 0x3 end -- G
- if rpm > (p4 * onePercent) then mBU0710Leds = 0x4 end -- Y
- if rpm > (p5 * onePercent) then mBU0710Leds = 0x5 end -- Y
- if rpm > (p6 * onePercent) then mBU0710Leds = 0x6 end -- Y
- if rpm > (p7 * onePercent) then mBU0710Leds = 0x7 end -- R
- if rpm > (p8 * onePercent) then mBU0710Leds = 0x8 end -- R
- if rpm > (p9 * onePercent) then mBU0710Leds = 0x9 end -- R
- if rpm > (p10 * onePercent) then mBU0710Leds = 0xA end -- R
- if rpm > (p11 * onePercent) then mBU0710Leds = 0xB end -- RRRR
-end
-
--- fixed rpm method for BU0710 (NOT RECOMMENDED)
-function RpmBU0710(rpm, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11 )
- if rpm > p1 then mBU0710Leds = 0x1 end -- G
- if rpm > p2 then mBU0710Leds = 0x2 end -- G
- if rpm > p3 then mBU0710Leds = 0x3 end -- G
- if rpm > p4 then mBU0710Leds = 0x4 end -- Y
- if rpm > p5 then mBU0710Leds = 0x5 end -- Y
- if rpm > p6 then mBU0710Leds = 0x6 end -- Y
- if rpm > p7 then mBU0710Leds = 0x7 end -- R
- if rpm > p8 then mBU0710Leds = 0x8 end -- R
- if rpm > p9 then mBU0710Leds = 0x9 end -- R
- if rpm > p10 then mBU0710Leds = 0xA end -- R
- if rpm > p11 then mBU0710Leds = 0xB end -- RRRR
-end
-
-function GetKersPercent()
- -- get kers value
- local kers_level = GetCarInfo("kers")
- local k_percent = 0
- if kers_level ~= nil and kers_level > 0 then
- k_percent = round((kers_level/1000) / 4 )
- end
- return k_percent
-end
--- ==============================================================================
-
- -- SLI-M, SLI-PRO ShiftLights Methods Event
-function shiftLightsMethodEvent(idx)
- -- get red zone (red zone default value is initialized in gear.lua )
- if gRedZone == nil or gRedZone == 0 then gRedZone = GetCarInfo("redzone") end
-
- -- call custom script
- local result = custom_shiftLightsMethodEvent(idx)
- -- if result = 0 bypass the script below and return 0
- -- if result = 1 bypass the script below and return 1
- if result <= 1 then return result end
- -- if result >= 2 continue
-
- -- call global custom script
- result = global_custom_shiftLightsMethodEvent(idx)
- -- if result = 0 bypass the script below and return 0
- -- if result = 1 bypass the script below and return 1
- if result <= 1 then return result end
- -- if result >= 2 continue
-
- -- get rpm
- local rpm = 0
- rpm = GetCarInfo("rpm")
- if rpm == nil then rpm = 0 end
-
- -- init leds (see global.lua)
- initLedTable(mRPMLedTable, 0)
-
- if idx == 0 then
- -- progressive method 0
- ProgressiveSLI(rpm, gRedZone, 7.5, 8, 8.5, 9, 9.5, 10, 10.5, 11, 11.5, 12, 12.5, 12.8, 12.98 )
-
- elseif idx == 1 then
- -- alternate method 1
- AlternateSLI(rpm, gRedZone, 11.0, 12.0, 12.9)
-
- elseif idx == 2 then
- -- percentage method 2
- PercentageSLI(rpm, gRedZone, RPM_PERCENT_VALUES[1], RPM_PERCENT_VALUES[2], RPM_PERCENT_VALUES[3], RPM_PERCENT_VALUES[4], RPM_PERCENT_VALUES[5], RPM_PERCENT_VALUES[6], RPM_PERCENT_VALUES[7], RPM_PERCENT_VALUES[8], RPM_PERCENT_VALUES[9], RPM_PERCENT_VALUES[10], RPM_PERCENT_VALUES[11], RPM_PERCENT_VALUES[12], RPM_PERCENT_VALUES[13] )
-
- elseif idx == 3 then
- -- abs rpm method 3 (not recommended)
- RpmSLI(rpm, RPM_ABSOLUTE_VALUES[1], RPM_ABSOLUTE_VALUES[2], RPM_ABSOLUTE_VALUES[3], RPM_ABSOLUTE_VALUES[4], RPM_ABSOLUTE_VALUES[5], RPM_ABSOLUTE_VALUES[6], RPM_ABSOLUTE_VALUES[7], RPM_ABSOLUTE_VALUES[8], RPM_ABSOLUTE_VALUES[9], RPM_ABSOLUTE_VALUES[10], RPM_ABSOLUTE_VALUES[11], RPM_ABSOLUTE_VALUES[12], RPM_ABSOLUTE_VALUES[13] )
-
- elseif idx == 4 then
- -- side to center method 4
- SideToCenterSLI(rpm, gRedZone, 94.5, 95, 96, 97 ,98 ,99 ,99.5 )
-
- elseif idx == 5 then
- -- KERS + RPM
-
- -- get kers value
- local k_percent = GetKersPercent()
-
- -- without first 4 green leds
- AlternateSLI(rpm, gRedZone, 100, 11.6, 12.9)
-
- -- KERS feedback on green leds
- -- print("KERS: " .. kers_level .. " - " .. k_percent .. "\n")
-
- if k_percent > 0 then mRPMLedTable.RPM0 = 1 end
- if k_percent >= 25 then mRPMLedTable.RPM1 = 1 end
- if k_percent >= 50 then mRPMLedTable.RPM2 = 1 end
- if k_percent >= 75 then mRPMLedTable.RPM3 = 1 end
-
- elseif idx == 6 then
- -- Revers KERS + RPM
-
- -- get kers value
- local k_percent = GetKersPercent()
-
- -- without first 4 green leds
- AlternateSLI(rpm, gRedZone, 0, 11.6, 12.9)
-
- -- KERS feedback on green leds
- -- print("KERS: " .. kers_level .. " - " .. k_percent .. "\n")
-
- if k_percent > 0 then mRPMLedTable.RPM3 = 0 end
- if k_percent >= 25 then mRPMLedTable.RPM2 = 0 end
- if k_percent >= 50 then mRPMLedTable.RPM1 = 0 end
- if k_percent >= 75 then mRPMLedTable.RPM0 = 0 end
-
- else
- return 0
- end
-
- local tName = "mRPMLedTable"
- SetRPMLed(tName)
- return 1
-end
-
--- BU0710 ShiftLights Methods Event
-function shiftLightsBU0710Event(idx)
-
- -- get red zone (red zone default value is initialized in gear.lua )
- if gRedZone == nil or gRedZone == 0 then gRedZone = GetCarInfo("redzone") end
-
- -- call custom script
- local result = custom_shiftLightsBU0710Event(idx)
- -- if result = 0 bypass the script below and return 0
- -- if result = 1 bypass the script below and return 1
- if result <= 1 then return result end
- -- if result >= 2 continue
-
- -- call global custom script
- result = global_custom_shiftLightsBU0710Event(idx)
- -- if result = 0 bypass the script below and return 0
- -- if result = 1 bypass the script below and return 1
- if result <= 1 then return result end
- -- if result >= 2 continue
-
- local rpm = GetCarInfo("rpm")
- if rpm == nil then rpm = 0 end
-
- -- init leds (see global.lua)
- mBU0710Leds = 0
-
- if (idx <= 1) or (idx >= 4) then
- -- progressive methods 1 or 4
- ProgressiveBU0710(rpm, gRedZone, 4.0, 6.0, 7.0, 7.5, 8.0, 8.5, 9.0, 9.3, 9.5, 9.7, 9.9 )
-
- elseif (idx == 2) then
- -- percentage method 2
- PercentageBU0710(rpm, gRedZone, 84, 88, 90, 92, 93, 94, 95, 96, 97, 98, 99 )
-
- elseif (idx == 3) then
- -- abs method 3 (not recommended)
- RpmBU0710(rpm, 15823, 16354, 16410, 16675, 17252, 17545, 17823, 18354, 18510, 18655, 18675 )
-
- else
- return 0
- end
- SetBU0710Led(mBU0710Leds)
- return 1
-end \ No newline at end of file
+-- SLIMax Mgr Lua Script v3
+-- Copyright (c)2012-2013 by Zappadoc - All Rights Reserved.
+-- this script builds all shiftlights methods
+-- last change by Zappadoc - 2013-02
+
+-- ==============================================================================
+-- utilities functions and methods
+-- ==============================================================================
+-- SLI-M and SLI-PRO functions
+
+-- shiftlights method from side to center
+function SideToCenterSLI(rpm, redzone, p1, p2, p3, p4 ,p5 ,p6 ,p7)
+
+ local rz = redzone / 100
+
+ -- side to center custom
+ if rpm > (rz*p1) then mRPMLedTable.RPM0 = 1 end -- G
+ if rpm > (rz*p1) then mRPMLedTable.RPM12 = 1 end -- B
+
+ if rpm > (rz*p2) then mRPMLedTable.RPM1 = 1 end -- G
+ if rpm > (rz*p2) then mRPMLedTable.RPM11 = 1 end -- B
+
+ if rpm > (rz*p3) then mRPMLedTable.RPM2 = 1 end -- G
+ if rpm > (rz*p3) then mRPMLedTable.RPM10 = 1 end -- B
+
+ if rpm > (rz*p4) then mRPMLedTable.RPM3 = 1 end -- G
+ if rpm > (rz*p4) then mRPMLedTable.RPM9 = 1 end -- B
+
+ if rpm > (rz*p5) then mRPMLedTable.RPM8 = 1 end -- R
+ if rpm > (rz*p5) then mRPMLedTable.RPM4 = 1 end -- R
+
+ if rpm > (rz*p6) then mRPMLedTable.RPM5 = 1 end -- R
+ if rpm > (rz*p6) then mRPMLedTable.RPM7 = 1 end -- R
+
+ if rpm > (rz*p7) then mRPMLedTable.RPM6 = 1 end -- R
+
+end
+
+-- progressive method
+function ProgressiveSLI(rpm, redzone, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13 )
+ local rz = redzone / 13
+ -- print("progessive")
+ if rpm > (rz*p1) then mRPMLedTable.RPM0 = 1 end
+ if rpm > (rz*p2) then mRPMLedTable.RPM1 = 1 end
+ if rpm > (rz*p3) then mRPMLedTable.RPM2 = 1 end
+ if rpm > (rz*p4) then mRPMLedTable.RPM3 = 1 end
+
+ if rpm > (rz*p5) then mRPMLedTable.RPM4 = 1 end
+ if rpm > (rz*p6) then mRPMLedTable.RPM5 = 1 end
+ if rpm > (rz*p7) then mRPMLedTable.RPM6 = 1 end
+ if rpm > (rz*p8) then mRPMLedTable.RPM7 = 1 end
+ if rpm > (rz*p9) then mRPMLedTable.RPM8 = 1 end
+
+ if rpm > (rz*p10) then mRPMLedTable.RPM9 = 1 end
+ if rpm > (rz*p11) then mRPMLedTable.RPM10 = 1 end
+ if rpm > (rz*p12) then mRPMLedTable.RPM11 = 1 end
+ if rpm > (rz*p13) then mRPMLedTable.RPM12 = 1 end
+end
+
+-- alternate green, red and blue method
+function AlternateSLI(rpm, redzone, step1, step2, step3)
+
+ local rz = redzone / 13
+ if rpm > (rz*step1) then
+ mRPMLedTable.RPM0 = 1 -- G
+ mRPMLedTable.RPM1 = 1 -- G
+ mRPMLedTable.RPM2 = 1 -- G
+ mRPMLedTable.RPM3 = 1 -- G
+ end
+ if rpm > (rz*step2) then
+ mRPMLedTable.RPM4 = 1 -- R
+ mRPMLedTable.RPM5 = 1 -- R
+ mRPMLedTable.RPM6 = 1 -- R
+ mRPMLedTable.RPM7 = 1 -- R
+ mRPMLedTable.RPM8 = 1 -- R
+ end
+ if rpm > (rz*step3) then
+ mRPMLedTable.RPM9 = 1 -- B
+ mRPMLedTable.RPM10 = 1 -- B
+ mRPMLedTable.RPM11 = 1 -- B
+ mRPMLedTable.RPM12 = 1 -- B
+ end
+end
+
+function PercentageSLI(rpm, redzone, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13 )
+ local onePercent = redzone / 100
+ if p1>0 and rpm >= (p1*onePercent) then mRPMLedTable.RPM0 = 1 end -- G
+ if p2>0 and rpm >= (p2*onePercent) then mRPMLedTable.RPM1 = 1 end -- G
+ if p3>0 and rpm >= (p3*onePercent) then mRPMLedTable.RPM2 = 1 end -- G
+ if p4>0 and rpm >= (p4*onePercent) then mRPMLedTable.RPM3 = 1 end -- G
+ if p5>0 and rpm >= (p5*onePercent) then mRPMLedTable.RPM4 = 1 end -- R
+ if p6>0 and rpm >= (p6*onePercent) then mRPMLedTable.RPM5 = 1 end -- R
+ if p7>0 and rpm >= (p7*onePercent) then mRPMLedTable.RPM6 = 1 end -- R
+ if p8>0 and rpm >= (p8*onePercent) then mRPMLedTable.RPM7 = 1 end -- R
+ if p9>0 and rpm >= (p9*onePercent) then mRPMLedTable.RPM8 = 1 end -- R
+ if p10>0 and rpm >= (p10*onePercent) then mRPMLedTable.RPM9 = 1 end -- B
+ if p11>0 and rpm >= (p11*onePercent) then mRPMLedTable.RPM10 = 1 end -- B
+ if p12>0 and rpm >= (p12*onePercent) then mRPMLedTable.RPM11 = 1 end -- B
+ if p13>0 and rpm >= (p13*onePercent) then mRPMLedTable.RPM12 = 1 end -- B
+end
+
+-- fixed rpm method, set rpm for each led (NOT RECOMMENDED)
+function RpmSLI(rpm, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13 )
+ if p1>0 and rpm >= p1 then mRPMLedTable.RPM0 = 1 end -- G
+ if p2>0 and rpm >= p2 then mRPMLedTable.RPM1 = 1 end -- G
+ if p3>0 and rpm >= p3 then mRPMLedTable.RPM2 = 1 end -- Y
+ if p4>0 and rpm >= p4 then mRPMLedTable.RPM3 = 1 end -- Y
+ if p5>0 and rpm >= p5 then mRPMLedTable.RPM4 = 1 end -- R
+ if p6>0 and rpm >= p6 then mRPMLedTable.RPM5 = 1 end -- R
+ if p7>0 and rpm >= p7 then mRPMLedTable.RPM6 = 1 end -- G
+ if p8>0 and rpm >= p8 then mRPMLedTable.RPM7 = 1 end -- G
+ if p9>0 and rpm >= p9 then mRPMLedTable.RPM8 = 1 end -- Y
+ if p10>0 and rpm >= p10 then mRPMLedTable.RPM9 = 1 end -- Y
+ if p11>0 and rpm >= p11 then mRPMLedTable.RPM10 = 1 end -- R
+ if p12>0 and rpm >= p12 then mRPMLedTable.RPM11 = 1 end -- R
+ if p13>0 and rpm >= p13 then mRPMLedTable.RPM12 = 1 end -- R
+end
+
+-- progressive method but with rpm value for eah led
+function ProgressiveFixedSLI(rpm, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13)
+ -- progressive method with thresholds as parameters
+ if rpm > p1 then mRPMLedTable.RPM0 = 1 end
+ if rpm > p2 then mRPMLedTable.RPM1 = 1 end
+ if rpm > p3 then mRPMLedTable.RPM2 = 1 end
+ if rpm > p4 then mRPMLedTable.RPM3 = 1 end
+
+ if rpm > p5 then mRPMLedTable.RPM4 = 1 end
+ if rpm > p6 then mRPMLedTable.RPM5 = 1 end
+ if rpm > p7 then mRPMLedTable.RPM6 = 1 end
+ if rpm > p8 then mRPMLedTable.RPM7 = 1 end
+ if rpm > p9 then mRPMLedTable.RPM8 = 1 end
+
+ if rpm > p10 then mRPMLedTable.RPM9 = 1 end
+ if rpm > p11 then mRPMLedTable.RPM10 = 1 end
+ if rpm > p12 then mRPMLedTable.RPM11 = 1 end
+ if rpm > p13 then mRPMLedTable.RPM12 = 1 end
+end
+
+-- --------------------------------------------
+-- --------------------------------------------
+-- BU0710 functions
+
+-- progressive method for BU0710
+function ProgressiveBU0710(rpm, redzone, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11 )
+ local rz = redzone / 10.0
+ if rpm > (rz * p1) then mBU0710Leds = 0x1 end -- G
+ if rpm > (rz * p2) then mBU0710Leds = 0x2 end -- G
+ if rpm > (rz * p3) then mBU0710Leds = 0x3 end -- G
+ if rpm > (rz * p4) then mBU0710Leds = 0x4 end -- Y
+ if rpm > (rz * p5) then mBU0710Leds = 0x5 end -- Y
+ if rpm > (rz * p6) then mBU0710Leds = 0x6 end -- Y
+ if rpm > (rz * p7) then mBU0710Leds = 0x7 end -- R
+ if rpm > (rz * p8) then mBU0710Leds = 0x8 end -- R
+ if rpm > (rz * p9) then mBU0710Leds = 0x9 end -- R
+ if rpm > (rz * p10) then mBU0710Leds = 0xA end -- R
+ if rpm > (rz * p11) then mBU0710Leds = 0xB end -- RRRR
+end
+
+-- percentage method for BU0710
+function PercentageBU0710(rpm, redzone, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11 )
+ local onePercent = redzone / 100
+ if rpm > (p1 * onePercent) then mBU0710Leds = 0x1 end -- G
+ if rpm > (p2 * onePercent) then mBU0710Leds = 0x2 end -- G
+ if rpm > (p3 * onePercent) then mBU0710Leds = 0x3 end -- G
+ if rpm > (p4 * onePercent) then mBU0710Leds = 0x4 end -- Y
+ if rpm > (p5 * onePercent) then mBU0710Leds = 0x5 end -- Y
+ if rpm > (p6 * onePercent) then mBU0710Leds = 0x6 end -- Y
+ if rpm > (p7 * onePercent) then mBU0710Leds = 0x7 end -- R
+ if rpm > (p8 * onePercent) then mBU0710Leds = 0x8 end -- R
+ if rpm > (p9 * onePercent) then mBU0710Leds = 0x9 end -- R
+ if rpm > (p10 * onePercent) then mBU0710Leds = 0xA end -- R
+ if rpm > (p11 * onePercent) then mBU0710Leds = 0xB end -- RRRR
+end
+
+-- fixed rpm method for BU0710 (NOT RECOMMENDED)
+function RpmBU0710(rpm, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11 )
+ if rpm > p1 then mBU0710Leds = 0x1 end -- G
+ if rpm > p2 then mBU0710Leds = 0x2 end -- G
+ if rpm > p3 then mBU0710Leds = 0x3 end -- G
+ if rpm > p4 then mBU0710Leds = 0x4 end -- Y
+ if rpm > p5 then mBU0710Leds = 0x5 end -- Y
+ if rpm > p6 then mBU0710Leds = 0x6 end -- Y
+ if rpm > p7 then mBU0710Leds = 0x7 end -- R
+ if rpm > p8 then mBU0710Leds = 0x8 end -- R
+ if rpm > p9 then mBU0710Leds = 0x9 end -- R
+ if rpm > p10 then mBU0710Leds = 0xA end -- R
+ if rpm > p11 then mBU0710Leds = 0xB end -- RRRR
+end
+
+-- --------------------------------------------
+-- --------------------------------------------
+-- G27 functions
+
+-- progressive method for G27
+function ProgressiveG27(rpm, redzone, p1, p2, p3, p4, p5)
+ local rz = redzone / 5.0
+ if rpm > (rz * p1) then mG27Leds = 0x1 end -- G
+ if rpm > (rz * p2) then mG27Leds = 0x3 end -- G
+ if rpm > (rz * p3) then mG27Leds = 0x7 end -- Y
+ if rpm > (rz * p4) then mG27Leds = 0x0F end -- Y
+ if rpm > (rz * p5) then mG27Leds = 0x1F end -- R
+end
+
+-- percentage method for G27
+function PercentageG27(rpm, redzone, p1, p2, p3, p4, p5)
+ local onePercent = redzone / 100
+ if rpm > (p1 * onePercent) then mG27Leds = 0x1 end -- G
+ if rpm > (p2 * onePercent) then mG27Leds = 0x3 end -- G
+ if rpm > (p3 * onePercent) then mG27Leds = 0x7 end -- Y
+ if rpm > (p4 * onePercent) then mG27Leds = 0x0F end -- Y
+ if rpm > (p5 * onePercent) then mG27Leds = 0x1F end -- R
+end
+
+-- fixed rpm method for G27 (NOT RECOMMENDED)
+function RpmG27(rpm, p1, p2, p3, p4, p5 )
+ if rpm > p1 then mG27Leds = 0x1 end -- G
+ if rpm > p2 then mG27Leds = 0x3 end -- G
+ if rpm > p3 then mG27Leds = 0x7 end -- Y
+ if rpm > p4 then mG27Leds = 0x0F end -- Y
+ if rpm > p5 then mG27Leds = 0x1F end -- R
+end
+
+-- --------------------------------------------
+-- --------------------------------------------
+-- Fanatec functions
+
+-- progressive method for Fanatec
+function ProgressiveFanatec(rpm, redzone, p1, p2, p3, p4, p5, p6, p7, p8, p9)
+ local rz = redzone / 9.0
+ if rpm > (rz*p1) then mRPMLedTable.RPM0 = 1 end
+ if rpm > (rz*p2) then mRPMLedTable.RPM1 = 1 end
+ if rpm > (rz*p3) then mRPMLedTable.RPM2 = 1 end
+ if rpm > (rz*p4) then mRPMLedTable.RPM3 = 1 end
+
+ if rpm > (rz*p5) then mRPMLedTable.RPM4 = 1 end
+ if rpm > (rz*p6) then mRPMLedTable.RPM5 = 1 end
+ if rpm > (rz*p7) then mRPMLedTable.RPM6 = 1 end
+ if rpm > (rz*p8) then mRPMLedTable.RPM7 = 1 end
+ if rpm > (rz*p9) then mRPMLedTable.RPM8 = 1 end
+end
+
+-- percentage method for Fanatec
+function PercentageFanatec(rpm, redzone, p1, p2, p3, p4, p5, p6, p7, p8, p9)
+ local onePercent = redzone / 100
+ if p1>0 and rpm >= (p1*onePercent) then mRPMLedTable.RPM0 = 1 end -- y
+ if p2>0 and rpm >= (p2*onePercent) then mRPMLedTable.RPM1 = 1 end -- y
+ if p3>0 and rpm >= (p3*onePercent) then mRPMLedTable.RPM2 = 1 end -- y
+ if p4>0 and rpm >= (p4*onePercent) then mRPMLedTable.RPM3 = 1 end -- r
+ if p5>0 and rpm >= (p5*onePercent) then mRPMLedTable.RPM4 = 1 end -- r
+ if p6>0 and rpm >= (p6*onePercent) then mRPMLedTable.RPM5 = 1 end -- r
+ if p7>0 and rpm >= (p7*onePercent) then mRPMLedTable.RPM6 = 1 end -- b
+ if p8>0 and rpm >= (p8*onePercent) then mRPMLedTable.RPM7 = 1 end -- b
+ if p9>0 and rpm >= (p9*onePercent) then mRPMLedTable.RPM8 = 1 end -- b
+end
+
+-- fixed rpm method for Fanatec (NOT RECOMMENDED)
+function RpmFanatec(rpm, p1, p2, p3, p4, p5, p6, p7, p8, p9 )
+ if rpm > p1 then mRPMLedTable.RPM0 = 1 end
+ if rpm > p2 then mRPMLedTable.RPM1 = 1 end
+ if rpm > p3 then mRPMLedTable.RPM2 = 1 end
+ if rpm > p4 then mRPMLedTable.RPM3 = 1 end
+
+ if rpm > p5 then mRPMLedTable.RPM4 = 1 end
+ if rpm > p6 then mRPMLedTable.RPM5 = 1 end
+ if rpm > p7 then mRPMLedTable.RPM6 = 1 end
+ if rpm > p8 then mRPMLedTable.RPM7 = 1 end
+ if rpm > p9 then mRPMLedTable.RPM8 = 1 end
+end
+
+-- alternate yellow, red and blue method
+function AlternateFanatec(rpm, redzone, step1, step2, step3)
+
+ local rz = redzone / 9.0
+ if rpm > (rz*step1) then
+ mRPMLedTable.RPM0 = 1 -- y
+ mRPMLedTable.RPM1 = 1 -- y
+ mRPMLedTable.RPM2 = 1 -- y
+ end
+ if rpm > (rz*step2) then
+ mRPMLedTable.RPM3 = 1 -- r
+ mRPMLedTable.RPM4 = 1 -- r
+ mRPMLedTable.RPM5 = 1 -- r
+ end
+ if rpm > (rz*step3) then
+ mRPMLedTable.RPM6 = 1 -- b
+ mRPMLedTable.RPM7 = 1 -- b
+ mRPMLedTable.RPM8 = 1 -- b
+ end
+end
+
+-- shiftlights method from side to center
+function SideToCenterFanatec(rpm, redzone, p1, p2, p3, p4 ,p5 )
+
+ local rz = redzone / 100
+
+ -- side to center custom
+ if rpm > (rz*p1) then mRPMLedTable.RPM0 = 1 end -- y
+ if rpm > (rz*p1) then mRPMLedTable.RPM8 = 1 end -- B
+
+ if rpm > (rz*p2) then mRPMLedTable.RPM1 = 1 end -- y
+ if rpm > (rz*p2) then mRPMLedTable.RPM7 = 1 end -- B
+
+ if rpm > (rz*p3) then mRPMLedTable.RPM2 = 1 end -- y
+ if rpm > (rz*p3) then mRPMLedTable.RPM6 = 1 end -- B
+
+ if rpm > (rz*p4) then mRPMLedTable.RPM3 = 1 end -- r
+ if rpm > (rz*p4) then mRPMLedTable.RPM5 = 1 end -- r
+
+ if rpm > (rz*p5) then mRPMLedTable.RPM4 = 1 end -- R
+end
+
+
+-- ==============================================================================
+
+ -- SLI-M, SLI-PRO ShiftLights Methods Event
+function shiftLightsMethodEvent(idx)
+ -- get red zone (red zone default value is initialized in gear.lua )
+ if gRedZone == nil or gRedZone == 0 then gRedZone = GetCarInfo("redzone") end
+
+ -- call custom script
+ local result = custom_shiftLightsMethodEvent(idx)
+ -- if result = 0 bypass the script below and return 0
+ -- if result = 1 bypass the script below and return 1
+ if result <= 1 then return result end
+ -- if result >= 2 continue
+
+ -- call global custom script
+ result = global_custom_shiftLightsMethodEvent(idx)
+ -- if result = 0 bypass the script below and return 0
+ -- if result = 1 bypass the script below and return 1
+ if result <= 1 then return result end
+ -- if result >= 2 continue
+
+ -- get rpm
+ local rpm = 0
+ rpm = GetCarInfo("rpm")
+ if rpm == nil then rpm = 0 end
+
+ -- init leds (see global.lua)
+ initLedTable(mRPMLedTable, 0)
+
+ if idx == 0 then
+ -- progressive method 0
+ ProgressiveSLI(rpm, gRedZone, 7.5, 8, 8.5, 9, 9.5, 10, 10.5, 11, 11.5, 12, 12.5, 12.8, 12.98 )
+
+ elseif idx == 1 then
+ -- alternate method 1
+ AlternateSLI(rpm, gRedZone, 11.0, 12.0, 12.9)
+
+ elseif idx == 2 then
+ -- percentage method 2
+ PercentageSLI(rpm, gRedZone, RPM_PERCENT_VALUES[1], RPM_PERCENT_VALUES[2], RPM_PERCENT_VALUES[3], RPM_PERCENT_VALUES[4], RPM_PERCENT_VALUES[5], RPM_PERCENT_VALUES[6], RPM_PERCENT_VALUES[7], RPM_PERCENT_VALUES[8], RPM_PERCENT_VALUES[9], RPM_PERCENT_VALUES[10], RPM_PERCENT_VALUES[11], RPM_PERCENT_VALUES[12], RPM_PERCENT_VALUES[13] )
+
+ elseif idx == 3 then
+ -- abs rpm method 3 (not recommended)
+ RpmSLI(rpm, RPM_ABSOLUTE_VALUES[1], RPM_ABSOLUTE_VALUES[2], RPM_ABSOLUTE_VALUES[3], RPM_ABSOLUTE_VALUES[4], RPM_ABSOLUTE_VALUES[5], RPM_ABSOLUTE_VALUES[6], RPM_ABSOLUTE_VALUES[7], RPM_ABSOLUTE_VALUES[8], RPM_ABSOLUTE_VALUES[9], RPM_ABSOLUTE_VALUES[10], RPM_ABSOLUTE_VALUES[11], RPM_ABSOLUTE_VALUES[12], RPM_ABSOLUTE_VALUES[13] )
+
+ elseif idx == 4 then
+ -- side to center method 4
+ SideToCenterSLI(rpm, gRedZone, 94.5, 95, 96, 97 ,98 ,99 ,99.5 )
+
+ elseif idx == 5 then
+ -- KERS + RPM
+
+ -- get kers value
+ local k_percent = GetKersPercent()
+
+ -- without first 4 green leds
+ AlternateSLI(rpm, gRedZone, 100, 11.6, 12.9)
+
+ -- KERS feedback on green leds
+ -- print("KERS: " .. kers_level .. " - " .. k_percent .. "\n")
+
+ if k_percent > 0 then mRPMLedTable.RPM0 = 1 end
+ if k_percent >= 25 then mRPMLedTable.RPM1 = 1 end
+ if k_percent >= 50 then mRPMLedTable.RPM2 = 1 end
+ if k_percent >= 75 then mRPMLedTable.RPM3 = 1 end
+
+ elseif idx == 6 then
+ -- Revers KERS + RPM
+
+ -- get kers value
+ local k_percent = GetKersPercent()
+
+ -- without first 4 green leds
+ AlternateSLI(rpm, gRedZone, 0, 11.6, 12.9)
+
+ -- KERS feedback on green leds
+ -- print("KERS: " .. kers_level .. " - " .. k_percent .. "\n")
+
+ if k_percent > 0 then mRPMLedTable.RPM3 = 0 end
+ if k_percent >= 25 then mRPMLedTable.RPM2 = 0 end
+ if k_percent >= 50 then mRPMLedTable.RPM1 = 0 end
+ if k_percent >= 75 then mRPMLedTable.RPM0 = 0 end
+
+ else
+ return 1
+ end
+
+ local tName = "mRPMLedTable"
+ SetRPMLed(tName)
+ return 1
+end
+
+-- ==============================================================================
+
+-- BU0710 ShiftLights Methods Event
+function shiftLightsBU0710Event(idx)
+
+ -- get red zone (red zone default value is initialized in gear.lua )
+ if gRedZone == nil or gRedZone == 0 then gRedZone = GetCarInfo("redzone") end
+
+ -- call custom script
+ local result = custom_shiftLightsBU0710Event(idx)
+ -- if result = 0 bypass the script below and return 0
+ -- if result = 1 bypass the script below and return 1
+ if result <= 1 then return result end
+ -- if result >= 2 continue
+
+ -- call global custom script
+ result = global_custom_shiftLightsBU0710Event(idx)
+ -- if result = 0 bypass the script below and return 0
+ -- if result = 1 bypass the script below and return 1
+ if result <= 1 then return result end
+ -- if result >= 2 continue
+
+ local rpm = GetCarInfo("rpm")
+ if rpm == nil then rpm = 0 end
+
+ -- init leds (see global.lua)
+ mBU0710Leds = 0
+
+ if (idx <= 1) or (idx >= 4) then
+ -- progressive methods 1 or 4
+ ProgressiveBU0710(rpm, gRedZone, 4.0, 6.0, 7.0, 7.5, 8.0, 8.5, 9.0, 9.3, 9.5, 9.7, 9.9 )
+
+ elseif (idx == 2) then
+ -- percentage method 2
+ PercentageBU0710(rpm, gRedZone, 84, 88, 90, 92, 93, 94, 95, 96, 97, 98, 99 )
+
+ elseif (idx == 3) then
+ -- abs method 3 (not recommended)
+ RpmBU0710(rpm, 15823, 16354, 16410, 16675, 17252, 17545, 17823, 18354, 18510, 18655, 18675 )
+
+ else
+ return 1
+ end
+ SetBU0710Led(mBU0710Leds)
+ return 1
+end
+
+-- ==============================================================================
+
+-- G27 ShiftLights Methods Event
+function shiftLightsG27LedsMethodEvent(idx)
+ -- get red zone (red zone default value is initialized in gear.lua )
+
+ if gRedZone == nil or gRedZone == 0 then gRedZone = GetCarInfo("redzone") end
+
+ -- call custom script
+ local result = custom_shiftLightsG27LedsMethodEvent(idx)
+ -- if result = 0 bypass the script below and return 0
+ -- if result = 1 bypass the script below and return 1
+ if result <= 1 then return result end
+ -- if result >= 2 continue
+
+ -- call global custom script
+ result = global_custom_shiftLightsG27LedsMethodEvent(idx)
+ -- if result = 0 bypass the script below and return 0
+ -- if result = 1 bypass the script below and return 1
+ if result <= 1 then return result end
+ -- if result >= 2 continue
+
+ local rpm = GetCarInfo("rpm")
+ if rpm == nil then rpm = 0 end
+
+ -- init leds (see global.lua)
+ mG27Leds = 0
+
+ if idx <= 0 or idx >= 3 then
+ -- progressive methods 1
+ ProgressiveG27(rpm, gRedZone, 2.0, 2.5, 3.5, 4.5, 4.9 )
+
+ elseif idx == 1 then
+ -- percentage method 2
+ --PercentageG27(rpm, gRedZone, 88, 92, 95, 97, 99 )
+ PercentageG27(rpm, gRedZone, RPM_PERCENT_VALUES[1], RPM_PERCENT_VALUES[2], RPM_PERCENT_VALUES[3], RPM_PERCENT_VALUES[4], RPM_PERCENT_VALUES[5] )
+
+ elseif idx == 2 then
+ -- abs method 3 (not recommended)
+ RpmG27(rpm, RPM_ABSOLUTE_VALUES[1], RPM_ABSOLUTE_VALUES[2], RPM_ABSOLUTE_VALUES[3], RPM_ABSOLUTE_VALUES[4], RPM_ABSOLUTE_VALUES[5] )
+
+ else
+ return 1
+ end
+ SetG27Led(mG27Leds)
+ return 1
+end
+
+-- ==============================================================================
+
+-- Fanatec ShiftLights Methods Event
+function shiftLightsFanatecMethodEvent(idx)
+ -- get red zone (red zone default value is initialized in gear.lua )
+
+ if gRedZone == nil or gRedZone == 0 then gRedZone = GetCarInfo("redzone") end
+
+ -- call custom script
+ local result = custom_shiftLightsFanatecMethodEvent(idx)
+ -- if result = 0 bypass the script below and return 0
+ -- if result = 1 bypass the script below and return 1
+ if result <= 1 then return result end
+ -- if result >= 2 continue
+
+ -- call global custom script
+ result = global_custom_shiftLightsFanatecMethodEvent(idx)
+ -- if result = 0 bypass the script below and return 0
+ -- if result = 1 bypass the script below and return 1
+ if result <= 1 then return result end
+ -- if result >= 2 continue
+
+ local rpm = GetCarInfo("rpm")
+ if rpm == nil then rpm = 0 end
+
+ -- init leds (see global.lua)
+ initLedTable(mRPMLedTable, 0)
+
+ if (idx < 1) or (idx > 6) then
+ -- progressive methods 0
+ ProgressiveFanatec(rpm, gRedZone, 6.0, 6.5, 7.0, 7.5, 8.0, 8.3, 8.5, 8.7, 8.9 )
+
+ elseif idx == 1 then
+ -- alternate method 1
+ AlternateFanatec(rpm, gRedZone, 7.0, 8.0, 8.9)
+
+ elseif (idx == 2) then
+ -- percentage method 2
+ PercentageFanatec(rpm, gRedZone, RPM_PERCENT_VALUES[1], RPM_PERCENT_VALUES[2], RPM_PERCENT_VALUES[3], RPM_PERCENT_VALUES[4], RPM_PERCENT_VALUES[5], RPM_PERCENT_VALUES[6], RPM_PERCENT_VALUES[7], RPM_PERCENT_VALUES[8], RPM_PERCENT_VALUES[9] )
+
+ elseif (idx == 3) then
+ -- abs method 3 (not recommended)
+ RpmFanatec(rpm, RPM_ABSOLUTE_VALUES[1], RPM_ABSOLUTE_VALUES[2], RPM_ABSOLUTE_VALUES[3], RPM_ABSOLUTE_VALUES[4], RPM_ABSOLUTE_VALUES[5], RPM_ABSOLUTE_VALUES[6], RPM_ABSOLUTE_VALUES[7], RPM_ABSOLUTE_VALUES[8], RPM_ABSOLUTE_VALUES[9] )
+
+ elseif idx == 4 then
+ -- side to center method 4
+ SideToCenterFanatec(rpm, gRedZone, 96, 97 ,98 ,99 ,99.5 )
+
+ elseif idx == 5 then
+ -- KERS + RPM
+
+ -- get kers value, see function in global.lua
+ local k_percent = GetKersPercent()
+
+ -- without first 4 green leds
+ local kers_level = GetCarInfo("kers")
+ AlternateFanatec(rpm, gRedZone, 100, 7.6, 8.9)
+
+ -- KERS feedback on yellow leds
+ -- print("IDX: ".. idx.." KERS: " .. kers_level .. " - " .. k_percent .. "\n")
+
+ if k_percent > 0 then mRPMLedTable.RPM0 = 1 end
+ if k_percent >= 33 then mRPMLedTable.RPM1 = 1 end
+ if k_percent >= 66 then mRPMLedTable.RPM2 = 1 end
+
+ elseif idx == 6 then
+ -- Revers KERS + RPM
+
+ -- get kers value, see function in global.lua
+ local k_percent = GetKersPercent()
+
+ -- without first 4 green leds
+ AlternateFanatec(rpm, gRedZone, 0, 7.6, 8.9)
+
+ -- KERS feedback on yellow leds
+ --local kers_level = GetCarInfo("kers")
+ --print("IDX: ".. idx.." KERS: " .. kers_level .. " - " .. k_percent .. "\n")
+
+ if k_percent > 0 then mRPMLedTable.RPM2 = 0 end
+ if k_percent >= 33 then mRPMLedTable.RPM1 = 0 end
+ if k_percent >= 66 then mRPMLedTable.RPM0 = 0 end
+
+ else
+ return 1
+ end
+
+
+
+ local tName = "mRPMLedTable"
+ SetFanatecLed(tName)
+ return 1
+end
+
diff --git a/scripts/slidevice.lua b/scripts/slidevice.lua
index 08da886..ef81cfa 100755
--- a/scripts/slidevice.lua
+++ b/scripts/slidevice.lua
@@ -1,11 +1,14 @@
--- Load SLIMax Mgr Lua Scripts v2.1
--- Copyright (c)2011-2013 by Zappadoc - All Rights Reserved.
--- changed by Zappadoc - 2012-11-10
--- main device script
+-- Load SLIMax Mgr Lua Scripts v3
+-- Copyright (c)2012-2013 by Zappadoc - All Rights Reserved.
+-- changed by Zappadoc - 2013-02
+-- main device script, do not modify this script
+print ()
+print ("-------------------------------------------")
require "scripts/led"
require "scripts/enter_exit_session"
require "scripts/gear"
+require "scripts/fanatec"
require "scripts/slipro"
require "scripts/shiftlights"
require "scripts/speedlimiter"
@@ -16,8 +19,8 @@ require "scripts/global_custom_scripts"
-- load the custom scripts if exists
scr = GetCustomScripts("scriptname")
--- print ( scr )
if scr ~= nil and scr ~= "" then
mCustomScriptsFileName = scr
require(mCustomScriptsFileName)
+ print ( string.format("%s => LOADED", scr ) )
end
diff --git a/scripts/sliemu_iracing.lua b/scripts/sliemu_iracing.lua
new file mode 100755
index 0000000..2d5b5ba
--- /dev/null
+++ b/scripts/sliemu_iracing.lua
@@ -0,0 +1,11 @@
+-- iRacing Custom Scripts - SLIMax Manager Scripts v1.9
+-- Copyright ©2011-2013 by Zappadoc - All Rights Reserved.
+-- last change by Zappadoc - 2012-09-16
+
+-- ================================
+-- add the short desciption of your script(s) in mScript_Info global var
+mScript_Info = "A useful iRacing COMBO SETUP to select automatically the good settings for each iracing car you drive (shiftlights, max gears, osp, et.)."
+
+-- ================================
+-- load common scripts file
+require "scripts/zdoc_scripts/iracing_common_scripts" \ No newline at end of file
diff --git a/scripts/slim_iracing.lua b/scripts/slim_iracing.lua
new file mode 100755
index 0000000..2d5b5ba
--- /dev/null
+++ b/scripts/slim_iracing.lua
@@ -0,0 +1,11 @@
+-- iRacing Custom Scripts - SLIMax Manager Scripts v1.9
+-- Copyright ©2011-2013 by Zappadoc - All Rights Reserved.
+-- last change by Zappadoc - 2012-09-16
+
+-- ================================
+-- add the short desciption of your script(s) in mScript_Info global var
+mScript_Info = "A useful iRacing COMBO SETUP to select automatically the good settings for each iracing car you drive (shiftlights, max gears, osp, et.)."
+
+-- ================================
+-- load common scripts file
+require "scripts/zdoc_scripts/iracing_common_scripts" \ No newline at end of file
diff --git a/scripts/slimax_script_readme.txt b/scripts/slimax_script_readme.txt
index 8e5fc44..148f7f7 100755
--- a/scripts/slimax_script_readme.txt
+++ b/scripts/slimax_script_readme.txt
@@ -1,6 +1,6 @@
-SLIMax Manager II 2.2.4.5 Scripting Information - PART OF SLIMax Manager pkg
+SLIMax Manager III 3.0 Scripting Information - PART OF SLIMax Manager pkg
Copyright (c)2011-2013 by EK & Zappadoc - All Rights Reserved.
-updated 2013-01-16 by Zappadoc
+updated 2013-02 by Zappadoc
** ALL INFORMATION BELOW ARE SUBJECT TO CHANGE WITHOUT NOTICE **
@@ -24,9 +24,9 @@ Reference manual (v5.1):
http://www.lua.org/manual/5.1/
-=================================
+====================================
Events received from SLIMax Manager
-=================================
+====================================
function custom_initEvent(scriptFile)
param = custom script file name
@@ -34,54 +34,69 @@ Notes: this event is triggered at startup or when loading your custom script,
this is the good opportunity to init your preferences and global vars
All event functions below must return 1 if the event has been fully managed or
-0 (zero) to skip and give control to SLIMax Mgr
+2 to skip and give control to SLIMax Mgr
---------------------------------------------
function shiftLightsMethodEvent(idx) and custom_shiftLightsMethodEvent
function shiftLightsBU0710Event(idx) and custom_shiftLightsBU0710Event
+function shiftLightsFanatecMethodEvent(idx) and custom_shiftLightsFanatecMethodEvent
+function shiftLightsG27LedsMethodEvent(idx) and custom_shiftLightsG27LedsMethodEvent
param = current method index
+Devices supported: SLI Boards series, Fanatec Wheels and Logitech G27 leds
Notes: shiftlights method event, computes all shiftlights methods
(see shiftlights.lua script)
---------------------------------------------
function ospMethodEvent(idx) and custom_ospMethodEvent
+function ospFanatecMethodEvent(idx) and custom_ospFanatecMethodEvent
+function ospG27LedsMethodEvent(idx) and custom_ospG27LedsMethodEvent
param = current method index
+Devices supported: SLI Boards series, Fanatec Wheels and Logitech G27 leds
Notes: OSP method event, computes all Optimal Shift-Points methods
(see osp.lua script)
---------------------------------------------
function spdLmtMethodEvent(idx) and custom_spdLmtMethodEvent
+function spdLmtFanatecMethodEvent(idx) and custom_spdLmtFanatecMethodEvent
+function spdLmtG27MethodEvent(idx) and custom_spdLmtG27MethodEvent
param = current method index
+Devices supported: SLI Boards series, Fanatec Wheels and Logitech G27 leds
Notes: speedlimiter method event, computes all speedlimiter methods
(see speedlimiter.lua script)
---------------------------------------------
function leftDigitsEvent(swPosition) and custom_leftDigitsEvent
function rightDigitsEvent(swPosition) and custom_rightDigitsEvent
+function fanatecDigitsEvent(swPosition) and custom_fanatecDigitsEvent
param = switch position
-Notes: SLI-PRO Left and Right Panel functions events, computes data to be
+Devices supported: SLI Boards series and Fanatec Wheels
+Notes: SLI-PRO Left and Right Panel and Fanatec digits functions events, computes data to be
displayed on left and rights digits of SLI-PRO device
(see slipro.lua script)
---------------------------------------------
+function gearEvent(gear) and custom_gearEvent
+function gearFanatecEvent(gear) and custom_gearFanatecEvent
+Devices supported: SLI Boards series and Fanatec Wheels
+param = current seleted gear ( -1 = reverse, 0 = neutral, 1 ... 7)
+Notes: gear event, show the current selected gear on central digit
+(see gear.lua script)
+
+---------------------------------------------
function controlsEvent(deviceIdx, ctrlType, ctrlPos, value, funcIndex) and custom_controlsEvent
params = see the script
+Devices supported: global event
Notes: Controls Event, Manage buttons and switches. (see controls.lua script)
---------------------------------------------
function deviceReport(devType) and custom_deviceReport
param = the current targeted SLI device
+Devices supported: global event
Notes: This function is called periodically and outputs the previously processed data to the device when it returns
back to the manager, if needed, patch any previous function here to
display additional info or to change everything. (see devhook.lua script)
---------------------------------------------
-function gearEvent(gear) and custom_gearEvent
-param = current seleted gear ( -1 = reverse, 0 = neutral, 1 ... 7)
-Notes: gear event, show the current selected gear on central digit
-(see gear.lua script)
-
----------------------------------------------
function enterSessionEvent(devType) and custom_enterSessionEvent
param = current device (SLI-M, SLI-PRO or BU0710)
Notes: Triggered when the session starts
@@ -90,6 +105,7 @@ Notes: Triggered when the session starts
---------------------------------------------
function exitSessionEvent(devType) and custom_exitSessionEvent
param = current device (SLI-M, SLI-PRO or BU0710)
+Devices supported: global event
Notes: Triggered when the session ends
(see enter_exit_session.lua script)
@@ -111,6 +127,8 @@ param = index of the led, std state of the led and corresponding function
13=Blue Flag
14=DRS
15=Safe Prefs
+
+Devices supported: SLI Boards series only
Notes: patch std led behaviors (i.e. tc, abs, lowfuel,
dammage, rev limit, drs, pit request, flags, ... )
IMPORTANT: your script must be optimized as the function is
@@ -130,19 +148,65 @@ functions to change SLIMax Manager information
============================================
---------------------------------------------
+Fanatec additions:
+---------------------------------------------
+SetFanatecDigitsAllowed(boolean)
+param boolean = true or false
+by default the 3 digits are showed but sometime we need to temporarily
+hide them to set our custom information, pass false to this function to hide digits
+and true to show them again
+
+---------------------------------------------
+SetFanatecDigits(string)
+param string = 3 chars string + dots
+Set the alpha-numerical text (including the . delimiter) to the digits panel (see fanatec.lua script)
+
+---------------------------------------------
+SetFanatecOneDigit(digit,a,b,c,d,e,f,g,dot)
+param digit = from 0 to 2
+param a,b,c,d,e,f,g = false or true
+param dot = false or true
+Set the 7 segments + dot of each digit
+
+---------------------------------------------
+SetFanatecCspMotor(power,delay)
+param power: from 0 to 100
+param delay: from 0 to 1000 ms (1sec max)
+
+SetFanatecWheelMotor(motor,power,delay)
+param motor = 0 or 1 (left or right motor )
+param power: from 0 to 100
+param delay: from 0 to 1000 ms (1sec max)
+
+SetFanatecLed(string table)
+param string = name of lua table (default mRPMLedTable)
+set RPM led of Fanatec rim ( see shiftlights.lua script)
+
+SetFanatecGear(gear)
+param string = one char string (i.e. "r" or "n" or "1" ... )
+set the gear value in center of the Fanatec digits panel (see fanatec.lua script)
+
+---------------------------------------------
+Logitech Additions:
+---------------------------------------------
+SetG27Led(int)
+param integer = number, each bit represent one led from 0 to 0x1F
+set leds of G27 device ( see shiftlights.lua script)
+
+---------------------------------------------
SetBU0710Led(int)
param integer = number from 0 to 10
-set leds of BU0710 device (e.g. see shiftlights.lua script)
+set leds of BU0710 device ( see shiftlights.lua script)
---------------------------------------------
SetGeadDigit(string)
param string = one char string (i.e. "r" or "n" or "1")
-set gear digit of current targeted SLI device (e.g. see gear.lua script)
+set gear digit of current targeted SLI device ( see gear.lua script)
---------------------------------------------
SetRPMLed(string)
param string = name of lua table (default mRPMLedTable)
-set RPM led of current targeted SLI device, SLI-M or SLI-PRO (e.g. see shiftlights.lua script)
+set RPM led of current targeted SLI device, SLI-M or SLI-PRO ( see shiftlights.lua script)
---------------------------------------------
SetWarnLed(idx, val)
@@ -251,7 +315,7 @@ SLISleep(ms)
-----------------------------------------------------------------------------------
SLISendReport()
-
+FanatecSendReport()
-----------------------------------------------------------------------------------
SetGlobalBrightness(int)
@@ -281,6 +345,7 @@ GetCarInfo("selector")
GetTimeInfo("selector")
GetPartialTimeInfo("selector", index)
IsSLIFunction("selector", function_index)
+GetDeviceType(deviceID)
-----------------------------------------------------------------------------------
GetContextInfo("selector")
@@ -289,6 +354,24 @@ Param "selector" (string), this string contains the following value:
IMPORTANT ** THESE VALUES ARE NOT AVAILABLE IN ALL SIMULATIONS ** IMPORTANT
+Fanatec additions:
+"bypass" return the state of BYPASS preference (see advanced options panel)
+"fanatecdigitscount" return the number of digits default = 3
+"wheelmotorcount" return the number of wheel motors default = 2
+"cspmotorcount" return the number of Clubsport pedals motors default = 1
+"fanatecwheeltype" return the type of wheel
+"fanatecrimtype" return the type of rim ( BMW = 1; Formula = 2)
+"cspdetected" return true if CSP are present
+"gearshock" return state of GEARSHOCK effect preference (see advanced options panel)
+"gearshockdelay" return the value in ms of GEARSHOCKDELAY preference (see advanced options panel)
+"fanatecdigits" return the current position of digits panel
+"fanatecquickinfo" return the current selected quick-info function
+
+
+"shiftlightsmethod" return current selected method of targeted device
+"ospmethod" return current selected method of targeted device
+"speedlimitermethod" return current selected method of targeted device
+
"ospcustom" return true if an OSP record to the current car has been found
"neutral" return ascii code of neutral char (default 'n')
"reverse" return ascii code of reverse char (default 'r')
@@ -299,7 +382,7 @@ IMPORTANT ** THESE VALUES ARE NOT AVAILABLE IN ALL SIMULATIONS ** IMPORTANT
"paused" return true if simulation is paused if available
"pluginactive" return 1 if a plugin has been activated
"pluginready" return true if plugin is ready to send data from simulation
-"devicetype" return current targeted SLI USB device (integer - see mDeviceType global)
+"devicetype" return current targeted SLI USB device (integer - see also GetDeviceType())
"tracksize" return current track size (meter) if available
"lapdistance" return the traveled distance of the car (meter) if available
"trackame" return current track name if available
@@ -414,15 +497,13 @@ see GetContextInfo() to get the total number of partials
IMPORTANT ** THESE VALUES ARE NOT AVAILABLE IN ALL SIMULATIONS ** IMPORTANT
-"currentpartial" return current partial time if available
-"bestpartial" return best partial time of this sector if available
-"optimalpartial" return optimal partial time of this sector if available
-"sessionbest" return session best partial time of this sector
-"sessionoptimal" return session optimal partial time of this sector
-"diffbestpartial" return diff from best if available
-"diffoptimalpartial" return diff from optimal if available
-"diffsessionbest" return diff from session best if available
-"diffsessionoptimal" return diff from session optimal if available
+"currentpartial" return current partial time if available
+"vsbestlap" return best partial time of this sector if available
+"vsoptimallap" return optimal partial time of this sector if available
+"vssessionbestlap" return session best partial time of this sector
+"vsoptimalsector" return session optimal partial time of this sector
+"vssessionoptimallap" return diff from session optimal if available
+"vssessionoptimalsector" return diff from optimal if available
-----------------------------------------------------------------------------------
IsSLIFunction("selector", function_index)
@@ -433,6 +514,7 @@ Param index (number) contains the targeted function index returned by controlsEv
Param "selector" (string), contains the following value:
see controls.lua scripts for more info.
+"fanatecdigits"
"brightness"
"quickinfo"
"speedmetric"
@@ -443,7 +525,7 @@ see controls.lua scripts for more info.
"blinktime"
"lowfuel"
"speedlimitermethod"
-"shiftlightsmethod"
+"shiftlights"
"ospmethod"
"rightdigits"
"leftdigits"
@@ -451,6 +533,13 @@ see controls.lua scripts for more info.
"drivingsetup"
"maxgear"
+-----------------------------------------------------------------------------------
+GetDeviceType(deviceID)
+returns the corresponding name of device ID
+Param deviceID (integer)
+return string value
+
+
===============================
Script Developpment
globals and utilities
@@ -475,10 +564,28 @@ mSpdLimitMethod to overwrite the method value, useful in custom_spdLmtMethodEven
-----------------------
SHIFTLIGHTS UTILITIES
-----------------------
-[NEW] shiftlights utilities functions in SLIMax Mananger II script API
+shiftlights utilities functions in SLIMax Mananger script API
(see shiftlights.lua for example and usage)
--------------------------------------------------------
+shiftlights utilities functions for Fanatec
+--------------------------------------------------------
+-- shiftlights method from side to center
+function SideToCenterFanatec(rpm, redzone, p1, p2, p3, p4 ,p5 )
+
+-- progressive method
+function ProgressiveFanatec(rpm, redzone, p1, p2, p3, p4, p5, p6, p7, p8, p9 )
+
+-- alternate yellow, red and blue method
+function AlternateFanatec(rpm, redzone, step1, step2, step3)
+
+-- percentage method
+function percentageFanatec(rpm, redzone, p1, p2, p3, p4, p5, p6, p7, p8, p9 )
+
+-- fixed rpm method, set rpm for each led (NOT RECOMMENDED)
+function RpmFanatec(rpm, p1, p2, p3, p4, p5, p6, p7, p8, p9 )
+
+--------------------------------------------------------
shiftlights utilities functions for SLI-M and SLI-PRO
--------------------------------------------------------
-- shiftlights method from side to center
@@ -496,7 +603,7 @@ function percentageSLI(rpm, redzone, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p1
-- fixed rpm method, set rpm for each led (NOT RECOMMENDED)
function RpmSLI(rpm, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13 )
--- progressive method but with rpm value for eah led
+-- progressive method but with rpm value for eah led (NOT RECOMMENDED)
function ProgressiveFixedSLI(rpm, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13)
--------------------------------------------------------
@@ -512,7 +619,23 @@ function percentageBU0710(rpm, redzone, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10,
function RpmSLI(rpm, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11 )
--------------------------------------------------------
-LEFT and RIGHT Functions utilities
+shiftlights utilities functions for Logitech G27
+--------------------------------------------------------
+-- progressive method for G27
+function ProgressiveG27(rpm, redzone, p1, p2, p3, p4, p5)
+
+-- percentage method for G27
+function PercentageG27(rpm, redzone, p1, p2, p3, p4, p5)
+
+-- fixed rpm method for G27 (NOT RECOMMENDED)
+function RpmG27(rpm, p1, p2, p3, p4, p5 )
+
+--------------------------------------------------------
+-- KERS functions
+function GetKersPercent()
+
+--------------------------------------------------------
+LEFT and RIGHT Functions utilities for SLI-M and SLI-PRO
--------------------------------------------------------
-- add a function name to left and right functions list
@@ -522,6 +645,8 @@ LEFT and RIGHT Functions utilities
-- or right list:
-- local err = FuncAddName("cfg/sli_right_functions.ecfg", "100.DSII KERS")
-- return 1 if ok
+-- local err = FuncAddName("cfg/fanatec_digits_functions.ecfg", "100.DSII KERS")
+-- return 1 if ok
-- same as above for removing the function name
@@ -538,4 +663,70 @@ LEFT and RIGHT Functions utilities
-- local num_available = FuncGetNewIndex("cfg/sli_left_functions.ecfg")
-- or right list:
-- local num_available = FuncGetNewIndex("cfg/sli_right_functions.ecfg")
--- return value >=100 (0 to 99 are reserved ) \ No newline at end of file
+-- return value >=100 (0 to 99 are reserved )
+-- or fanatec list:
+-- local num_available = FuncGetNewIndex("cfg/fanatec_digits_functions.ecfg")
+-- return value >=100 (0 to 99 are reserved )
+
+--------------------------------------------------------
+functions utilities in global.lua
+--------------------------------------------------------
+
+-- return KERS value in percent
+function GetKersPercent()
+
+-- Init all globals
+function InitGlobals()
+
+-- set RPM threshold value in percentage ( SLIMax Manager 2.1 )
+function SetRPMPercentValue(index, value)
+
+-- set RPM threshold value ( SLIMax Manager 2.1 )
+function SetRPMAbsoluteValue(index, value)
+
+-- get all global preferences set in general_default.sli
+function GetSLIMaxInfo()
+
+-- get cpu ticks
+function GetTicks()
+
+-- reset table function
+function initLedTable(ibl, value)
+
+-- toggle all led state
+function toggleAllLed(val)
+
+-- The following function rounds a number
+-- lua doesn't return the same rounded value as C/C++
+function round(num)
+
+-- The following function calculate hr, mn, sec, hd, ms
+-- param: time in meter/sec
+function timeDispatcher( tt)
+
+-- return speed in KPH or MPH
+function speed(spd, selector)
+
+-- Fahrenheit to Celsius
+function FtoC(f)
+
+-- Celsius to Fahrenheit
+function CtoF(c)
+
+-- Kelvin to Celsius
+function KtoC(k)
+
+-- liters to gallons
+function LtoG(liters)
+
+-- gallons to liters
+function GtoL(gallons)
+
+-- return fuel in liters or gallons
+function GetFuel(fl, selector)
+
+-- return celcius or fahrenheit
+function GetTemp(tmp, selector)
+
+-- set delta time delay in ms
+function SetDeltaTimeDelay(delay) \ No newline at end of file
diff --git a/scripts/slipro.lua b/scripts/slipro.lua
index 14b9107..ed4cd63 100755
--- a/scripts/slipro.lua
+++ b/scripts/slipro.lua
@@ -1,24 +1,12 @@
--- SLIPRO Lua Script v2.5
--- Copyright (c)2011-2013 by EK and Zappadoc - All Rights Reserved.
--- Use this script to build all functions associated with
+-- SLIPRO Lua Script v3
+-- Copyright (c)2012-2013 by Zappadoc - All Rights Reserved.
+-- this script builds all functions associated with
-- left and right panels of SLIPRO device
--- changed by Zappadoc - 2012-10-29
+-- last change by Zappadoc - 2013-02
-- ============================================================
-- Left and Right Panel functions
-- ============================================================
-function isAppIRacing(sim)
- if sim == "iRacingSim.exe" or sim == "iRacingSim64.exe" then
- return true
- end
- return false
-end
-function isAppRFactor(sim)
- if sim == "rFactor.exe" or sim == "rFactor2.exe" then
- return true
- end
- return false
-end
-- IN function of left panel
-- param: recieve from SLI Manager the current switch position
@@ -388,21 +376,23 @@ function rightDigitsEvent(swFunction)
if swValue == 4 then
lpt = GetPartialTimeInfo("currentpartial", sector)
elseif swValue == 5 then
- lpt = GetPartialTimeInfo("bestpartial", sector)
+ diffFlag = true
+ lpt = GetPartialTimeInfo("vsbestlap", sector)
elseif swValue == 6 then
- lpt = GetPartialTimeInfo("sessionbest", sector)
+ diffFlag = true
+ lpt = GetPartialTimeInfo("vsoptimallap", sector)
elseif swValue == 7 then
diffFlag = true
- lpt = GetPartialTimeInfo("diffbestpartial", sector)
+ lpt = GetPartialTimeInfo("vsoptimalsector", sector)
elseif swValue == 8 then
diffFlag = true
- lpt = GetPartialTimeInfo("diffsessionbest", sector)
+ lpt = GetPartialTimeInfo("vssessionbestlap", sector)
elseif swValue == 9 then
diffFlag = true
- lpt = GetPartialTimeInfo("diffoptimalpartial", sector)
+ lpt = GetPartialTimeInfo("vssessionoptimallap", sector)
elseif swValue == 10 then
diffFlag = true
- lpt = GetPartialTimeInfo("diffsessionoptimal", sector)
+ lpt = GetPartialTimeInfo("vssessionoptimalsector", sector)
end
else
lpt = 0.0
diff --git a/scripts/slipro_iracing.lua b/scripts/slipro_iracing.lua
new file mode 100755
index 0000000..2d5b5ba
--- /dev/null
+++ b/scripts/slipro_iracing.lua
@@ -0,0 +1,11 @@
+-- iRacing Custom Scripts - SLIMax Manager Scripts v1.9
+-- Copyright ©2011-2013 by Zappadoc - All Rights Reserved.
+-- last change by Zappadoc - 2012-09-16
+
+-- ================================
+-- add the short desciption of your script(s) in mScript_Info global var
+mScript_Info = "A useful iRacing COMBO SETUP to select automatically the good settings for each iracing car you drive (shiftlights, max gears, osp, et.)."
+
+-- ================================
+-- load common scripts file
+require "scripts/zdoc_scripts/iracing_common_scripts" \ No newline at end of file
diff --git a/scripts/speedlimiter.lua b/scripts/speedlimiter.lua
index 3d9a54c..90cd229 100755
--- a/scripts/speedlimiter.lua
+++ b/scripts/speedlimiter.lua
@@ -1,7 +1,7 @@
--- SLIMax Mgr Lua Script v2.1
--- Copyright (c)2011-2013 by EK and Zappadoc - All Rights Reserved.
--- Use this script to build all speed-limiter feedback methods
--- last change by Zappadoc - 2012-10-06
+-- SLIMax Mgr Lua Script v3
+-- Copyright (c)2012-2013 by Zappadoc - All Rights Reserved.
+-- this script builds all speed/pit-limiter feedback methods
+-- last change by Zappadoc - 2013-02
-- SLI-M, SLI-PRO speed limiter Methods
function spdLmtMethodEvent(idx)
@@ -34,11 +34,8 @@ function spdLmtMethodEvent(idx)
GetSLIMaxInfo()
-- init table
- if mSpdLimitMethod > 2 then
- -- reinit RPM leds only if method > 2
- initLedTable(mRPMLedTable, 0)
- SetRPMLed("mRPMLedTable")
- end
+ initLedTable(mRPMLedTable, 0)
+ SetRPMLed("mRPMLedTable")
if mNoBlink or (mSpdLimitMethod == 0) then
-- speedlimiter led NOT blinking
@@ -229,9 +226,98 @@ function spdLmtMethodEvent(idx)
SetRPMLed("mRPMLedTable")
else
- return 0
+ return 1
+ end
+
+ -- timebase
+ if GetTicks() > mOldTickCount then
+ mOldTickCount = GetTicks() + 20
+ end
+ return 1
+end
+
+
+-- G27 speed limiter Methods
+function spdLmtG27MethodEvent(idx)
+ mSpdLimitMethod = idx
+ -- call custom script
+ local result = custom_spdLmtG27MethodEvent(mSpdLimitMethod)
+ -- if result = 0 bypass the script below and return 0
+ -- if result = 1 bypass the script below and return 1
+ if result <= 1 then return result end
+ -- if result >= 2 continue
+
+ -- call global custom script
+ result = global_custom_spdLmtG27MethodEvent(mSpdLimitMethod)
+ -- if result = 0 bypass the script below and return 0
+ -- if result = 1 bypass the script below and return 1
+ if result <= 1 then return result end
+ -- if result >= 2 continue
+
+ local led = ""
+
+ -- check if initialized
+ if isGlobalInitialized == 0 then
+ isGlobalInitialized = 1
+ -- init them
+ InitGlobals()
+ end
+ -- get global prefs
+ GetSLIMaxInfo()
+
+ -- init table
+ mG27Leds = 0
+
+ if mNoBlink or mSpdLimitMethod == 0 then
+ -- speedlimiter led NOT blinking
+ mG27Leds = 0x1F
+
+ elseif mSpdLimitMethod == 1 then
+ -- speedlimiter led blinking, method 1
+ if GetTicks() > mOldTickCount then
+ mSpdLmtBlink = mSpdLmtBlink + 1
+ end
+
+ if mSpdLmtBlink >= mBlinkTime then
+ mSpdLmtBlink = 0
+ end
+
+ if mSpdLmtBlink <= (mBlinkTime / 2) then
+
+ mG27Leds = 0x1F
+ end
+
+ if mSpdLmtBlink > (mBlinkTime / 2) then
+
+ mG27Leds = 0
+ end
+
+ elseif mSpdLimitMethod >= 2 then
+ -- speedlimiter alternate led blinking, method 2 to n
+ if GetTicks() > mOldTickCount then
+ mSpdLmtBlink = mSpdLmtBlink + 1
+ end
+
+ if mSpdLmtBlink >= mBlinkTime then
+ mSpdLmtBlink = 0
+ end
+
+ if mSpdLmtBlink <= (mBlinkTime / 2) then
+
+ mG27Leds = 0x0A
+ end
+
+ if mSpdLmtBlink > (mBlinkTime / 2) then
+
+ mG27Leds = 0x15
+ end
+
+ else
+ return 1
end
+ SetG27Led(mG27Leds)
+
-- timebase
if GetTicks() > mOldTickCount then
mOldTickCount = GetTicks() + 20
@@ -239,3 +325,221 @@ function spdLmtMethodEvent(idx)
return 1
end
+
+ -- Fanatec speed/pit limiter Methods
+function spdLmtFanatecMethodEvent(idx)
+ mSpdLimitMethod = idx
+ mFanatecSpdLmtText = " "
+ -- call custom script
+ local result = custom_spdLmtFanatecMethodEvent(mSpdLimitMethod)
+ -- if result = 0 bypass the script below and return 0
+ -- if result = 1 bypass the script below and return 1
+ if result <= 1 then return result end
+ -- if result >= 2 continue
+
+ -- call global custom script
+ result = global_custom_spdLmtFanatecMethodEvent(mSpdLimitMethod)
+ -- if result = 0 bypass the script below and return 0
+ -- if result = 1 bypass the script below and return 1
+ if result <= 1 then return result end
+ -- if result >= 2 continue
+
+ local led = ""
+
+ -- check if initialized
+ if isGlobalInitialized == 0 then
+ isGlobalInitialized = 1
+ -- init them
+ InitGlobals()
+ end
+ -- get global prefs
+ GetSLIMaxInfo()
+
+ -- init table
+ initLedTable(mRPMLedTable, 0)
+ SetFanatecLed("mRPMLedTable")
+
+ if mNoBlink or mSpdLimitMethod == 0 then
+ -- speedlimiter first rpm led NOT blinking
+ SetFanatecDigitsAllowed(true)
+ mRPMLedTable["RPM0"]= 1
+ SetFanatecLed("mRPMLedTable")
+
+ elseif mSpdLimitMethod == 1 then
+ -- speedlimiter first rpm led blinking
+ if GetTicks() > mOldTickCount then
+ mSpdLmtBlink = mSpdLmtBlink + 1
+ end
+ if mSpdLmtBlink >= mBlinkTime then
+ mSpdLmtBlink = 0
+ end
+
+ if mSpdLmtBlink <= (mBlinkTime / 2) then
+ -- one led
+ mRPMLedTable["RPM0"]= 1
+
+ SetFanatecDigitsAllowed(true)
+
+ -- if not mSpdLmtRPMLedOnly then
+ -- SetFanatecDigitsAllowed(false)
+ -- if mLimiterChar then
+ -- SetFanatecGear("L", false)
+ -- else
+ -- SetFanatecDigits( "---" )
+ -- end
+ -- end
+ end
+
+ if mSpdLmtBlink > (mBlinkTime / 2) then
+ mRPMLedTable["RPM0"]= 0
+ -- if not mSpdLmtRPMLedOnly then
+ -- SetFanatecDigitsAllowed(true)
+ -- SetFanatecDigits( " " )
+ -- end
+ end
+ SetFanatecLed("mRPMLedTable")
+
+ elseif mSpdLimitMethod == 2 then
+ -- speedlimiter all rpm led blinking
+ if GetTicks() > mOldTickCount then
+ mSpdLmtBlink = mSpdLmtBlink + 1
+ end
+ if mSpdLmtBlink >= mBlinkTime then
+ mSpdLmtBlink = 0
+ end
+ if mSpdLmtBlink <= (mBlinkTime / 2) then
+
+ initLedTable(mRPMLedTable, 1)
+
+ SetFanatecDigitsAllowed(true)
+ -- if not mSpdLmtRPMLedOnly then
+ -- SetFanatecDigitsAllowed(false)
+ -- if mLimiterChar then
+ -- SetFanatecGear("L", false)
+ -- else
+ -- SetFanatecDigits( "---" )
+ -- end
+ -- end
+ end
+
+ if mSpdLmtBlink > (mBlinkTime / 2) then
+ initLedTable(mRPMLedTable, 0)
+ -- if not mSpdLmtRPMLedOnly then
+ -- SetFanatecDigitsAllowed(true)
+ -- SetFanatecDigits( " " )
+ -- end
+ end
+ SetFanatecLed("mRPMLedTable")
+
+ elseif mSpdLimitMethod == 3 or mSpdLimitMethod > 6 then
+ -- speedlimiter alternate RPM blinking
+ if GetTicks() > mOldTickCount then
+ mSpdLmtBlink = mSpdLmtBlink + 1
+ end
+ if mSpdLmtBlink >= mBlinkTime then
+ mSpdLmtBlink = 0
+ end
+ if mSpdLmtBlink <= (mBlinkTime / 2) then
+
+ for i = 0,8 do
+ led = led.format("RPM%d",i)
+ if (i % 2)==0 then
+ mRPMLedTable[led] = 1
+ else
+ mRPMLedTable[led] = 0
+ end
+ end
+ if not mSpdLmtRPMLedOnly then
+ SetFanatecDigitsAllowed(false)
+ if mLimiterChar then
+ SetFanatecGear("L", false)
+ else
+ SetFanatecDigits( "---" )
+ end
+ end
+ end
+
+ if mSpdLmtBlink > (mBlinkTime / 2) then
+ for i = 0,8 do
+ led = led.format("RPM%d",i)
+ if (i % 2)==0 then
+ mRPMLedTable[led] = 0
+ else
+ mRPMLedTable[led] = 1
+ end
+ end
+
+ if not mSpdLmtRPMLedOnly then
+ SetFanatecDigitsAllowed(true)
+ --SetFanatecDigits( " " )
+ end
+ end
+ SetFanatecLed("mRPMLedTable")
+
+
+ elseif mSpdLimitMethod == 4 or mSpdLimitMethod == 5 then
+ -- speedlimiter no led digits only
+ if GetTicks() > mOldTickCount then
+ mSpdLmtBlink = mSpdLmtBlink + 1
+ end
+
+ if mSpdLmtBlink >= mBlinkTime then
+ mSpdLmtBlink = 0
+ end
+
+ if mSpdLmtBlink <= (mBlinkTime / 2) then
+ initLedTable(mRPMLedTable, 0)
+ if mSpdLimitMethod == 4 then
+ SetFanatecDigitsAllowed(true)
+ else
+ SetFanatecDigitsAllowed(false)
+ SetFanatecDigits( " " )
+ end
+ end
+
+ if mSpdLmtBlink > (mBlinkTime / 2) then
+
+ SetFanatecDigitsAllowed(false)
+ SetFanatecDigits( "---" )
+
+ initLedTable(mRPMLedTable, 0)
+ end
+ SetFanatecLed("mRPMLedTable")
+
+ elseif mSpdLimitMethod == 6 then
+ -- speedlimiter freezed rpm + digits blinking
+ if GetTicks() > mOldTickCount then
+ mSpdLmtBlink = mSpdLmtBlink + 1
+ end
+
+ if mSpdLmtBlink >= mBlinkTime then
+ mSpdLmtBlink = 0
+ end
+
+ if mSpdLmtBlink <= (mBlinkTime / 2) then
+ initLedTable(mRPMLedTable, 1)
+ --if not mSpdLmtRPMLedOnly then
+ SetFanatecDigitsAllowed(true)
+ --SetFanatecDigits( " " )
+ --end
+ end
+
+ if mSpdLmtBlink > (mBlinkTime / 2) then
+
+ SetFanatecDigitsAllowed(false)
+ SetFanatecDigits( " " )
+
+ initLedTable(mRPMLedTable, 1)
+ end
+ SetFanatecLed("mRPMLedTable")
+
+ else
+ return 1
+ end
+
+ -- timebase
+ if GetTicks() > mOldTickCount then
+ mOldTickCount = GetTicks() + 20
+ end
+ return 1
+end
diff --git a/scripts/zdoc_scripts/iracing_common_scripts.lua b/scripts/zdoc_scripts/iracing_common_scripts.lua
index 1d5bb02..3b19bb2 100755
--- a/scripts/zdoc_scripts/iracing_common_scripts.lua
+++ b/scripts/zdoc_scripts/iracing_common_scripts.lua
@@ -1,6 +1,6 @@
--- iRacing SLI-PRO Custom SLIMax Manager Scripts v2.3
+-- iRacing SLI-PRO Custom SLIMax Manager Scripts v3
-- Copyright ©2012-2013 by Zappadoc - All Rights Reserved.
--- last change by Zappadoc - 2012-12-17
+-- last change by Zappadoc - 2013-02
-- ================================
-- CONSTANTS
@@ -45,8 +45,18 @@ function custom_ospMethodEvent(idx)
-- get current simulation name
local sim = GetContextInfo("simulation")
if isAppIRacing(sim) then
- result = iRacing_ospMethodEvent(idx)
-
+ result = iRacing_ospMethodEvent(idx, "SLI")
+ end
+ return result
+end
+function custom_ospFanatecMethodEvent(idx)
+ -- type your custom Optimal Shift Points (OSP) method here
+ -- custom speedlimiter for each iRacing car
+ local result = 2
+ -- get current simulation name
+ local sim = GetContextInfo("simulation")
+ if isAppIRacing(sim) then
+ result = iRacing_ospMethodEvent(idx, "FANATEC")
end
return result
end
@@ -58,7 +68,21 @@ function custom_shiftLightsMethodEvent(idx)
-- get current simulation name
local sim = GetContextInfo("simulation")
if isAppIRacing(sim) then
- iRacing_shiftLightsMethodEvent(idx)
+ iRacing_shiftLightsMethodEvent(idx, "SLI")
+ -- skip std methods
+ return 1
+ end
+
+ return 2
+end
+function custom_shiftLightsFanatecMethodEvent(idx)
+ -- type your custom shiftlights method here
+
+ -- custom shiftlights for each iRacing car
+ -- get current simulation name
+ local sim = GetContextInfo("simulation")
+ if isAppIRacing(sim) then
+ iRacing_shiftLightsMethodEvent(idx, "FANATEC")
-- skip std methods
return 1
end
@@ -81,6 +105,11 @@ function custom_rightDigitsEvent(swPosition)
return 2
end
+function custom_fanatecDigitsEvent(swPosition)
+ -- type your custom script related to Fanatec digits panel here
+ return 2
+end
+
function custom_spdLmtMethodEvent(idx)
-- type your custom speedlimiter method here
@@ -89,25 +118,40 @@ function custom_spdLmtMethodEvent(idx)
-- get current simulation name
local sim = GetContextInfo("simulation")
if isAppIRacing(sim) then
- result = iRacing_spdLmtMethodEvent(idx)
-
+ result = iRacing_spdLmtMethodEvent(idx, "SLI")
end
return result
end
+function custom_spdLmtFanatecMethodEvent(idx)
+ -- type your custom Optimal Shift Points (OSP) method here
+
+ -- custom speedlimiter for each iRacing car
+ local result = 2
+ -- get current simulation name
+ local sim = GetContextInfo("simulation")
+ if isAppIRacing(sim) then
+ result = iRacing_spdLmtMethodEvent(idx, "FANATEC")
+ end
+ return result
+end
+
+function custom_gearFanatecEvent(gear)
+ -- type your custom gear event script here
+
+ local sim = GetContextInfo("simulation")
+ if isAppIRacing(sim) then
+ iRacing_InitGearEvent(gear)
+ end
+ return 2
+end
+
function custom_gearEvent(gear)
-- type your custom gear event script here
- -- get current simulation name
- -- custom script to overwrite OSP value and OSP limit for each gear of each iRacing car
+
local sim = GetContextInfo("simulation")
if isAppIRacing(sim) then
- if gOldGear == nil then gOldGear = -2 end
- -- setup iRacing car OSP, RedZone, Max gear, ...
- iRacing_CarSetup(gear)
- if gear ~= gOldGear then
- gOldGear = gear
- -- print("\n----------\nGear: ".. gear .."\nOSP: " .. gOSPLimit .. "\nRedZone:" .. gRedZone .."\n")
- end
+ iRacing_InitGearEvent(gear)
end
return 2
end
@@ -120,12 +164,7 @@ function custom_enterSessionEvent(devType)
local sim = GetContextInfo("simulation")
if isAppIRacing(sim ) then
iRacing_CarSetup(0)
- -- see debug window
- -- get car name
- local cNm = GetContextInfo("carname")
- local mxG = GetCarInfo("maxgear")
- local ospf = GetContextInfo("ospfactor")
- print("\n----------\nSetup car:" .. cNm .. "\nMaxGear:" .. mxG .. "\nOSP Factor:" .. ospf .. "\n");
+ iRacing_DebugCarInfo(devType)
end
return 2
end
diff --git a/scripts/zdoc_scripts/iracing_stuff.lua b/scripts/zdoc_scripts/iracing_stuff.lua
index b53c66c..42a708d 100755
--- a/scripts/zdoc_scripts/iracing_stuff.lua
+++ b/scripts/zdoc_scripts/iracing_stuff.lua
@@ -1,11 +1,33 @@
--- Custom SLIMax Manager Scripts for iRacing v2.1
+-- Custom SLIMax Manager Scripts for iRacing v3
-- Copyright ©2012-2013 by Zappadoc
--- _last change by Zappadoc - 2012-12-17
+-- _last change by Zappadoc - 2013-02
-- =====================================
-- iRacing Stuff script
-- define car setup function and all pit limiter and shiftlights methods for each car you drive
+function iRacing_DebugCarInfo(devType)
+ -- see debug console window
+ -- get car name
+ local dev = GetDeviceType(devType)
+ local cNm = GetContextInfo("carname")
+ local mxG = GetCarInfo("maxgear")
+ local ospf = GetContextInfo("ospfactor")
+ print("\n----------\nDevice:"..dev.."\nSetup car:" .. cNm .. "\nMaxGear:" .. mxG .. "\nOSP Factor:" .. ospf .. "\n");
+end
+function iRacing_InitGearEvent(gear)
+ -- get current simulation name
+ -- custom script to overwrite OSP value and OSP limit for each gear of each iRacing car
+ local sim = GetContextInfo("simulation")
+ if isAppIRacing(sim) then
+ if gOldGear == nil then gOldGear = -2 end
+ -- setup iRacing car OSP, RedZone, Max gear, ...
+ iRacing_CarSetup(gear)
+ if gear ~= gOldGear then
+ gOldGear = gear
+ end
+ end
+end
function iRacing_CarSetup(cGear)
-- get car name
@@ -160,7 +182,7 @@ function FixRPMSpeedlimiter()
end
-function iRacing_spdLmtMethodEvent(idx)
+function iRacing_spdLmtMethodEvent(idx, devType)
local led = ""
-- get car name
@@ -175,7 +197,7 @@ function iRacing_spdLmtMethodEvent(idx)
elseif cNm == "williamsfw31" then
-- speedlimiter led fixed + digits blinking, method 6
- mSpdLimitMethod = 6
+ mSpdLimitMethod = 5
elseif cNm == "fordv8sc" then
mSpdLimitMethod = 2
@@ -234,7 +256,7 @@ function iRacing_spdLmtMethodEvent(idx)
return 2
end
-function iRacing_shiftLightsMethodEvent(idx)
+function iRacing_shiftLightsMethodEvent(idx, dev)
-- rpm table name
local tName = "mRPMLedTable"
-- get rpm
@@ -268,55 +290,117 @@ function iRacing_shiftLightsMethodEvent(idx)
end
end
+ -- get device type
+ if dev == nil then dev = "none" end
+
-- shiftlights stuff
if cNm == "formulamazda" then
-- start Mazda shiftlights
- SideToCenterSLI(rpm, gRedZone, 94.5, 95, 96, 97 ,98 ,99 ,99.5)
-
+ if dev == "FANATEC" then
+ SideToCenterFanatec(rpm, gRedZone, 96, 97 ,98 ,99 ,99.5)
+ else
+ SideToCenterSLI(rpm, gRedZone, 94.5, 95, 96, 97 ,98 ,99 ,99.5)
+ end
elseif cNm == "mclarenmp4" then
local gear = GetCarInfo("gear")
if gear == 6 then
- ProgressiveFixedSLI(rpm, 6300, 6490, 6580, 6690, 6720 , 6870 , 7000 , 7200, 7305, 7340, 7340, 7340, 7340)
+ if dev == "FANATEC" then
+ RpmFanatec(rpm, 6720 , 6870 , 7000 , 7200, 7305, 7340, 7340, 7340, 7340)
+ else
+ ProgressiveFixedSLI(rpm, 6300, 6490, 6580, 6690, 6720 , 6870 , 7000 , 7200, 7305, 7340, 7340, 7340, 7340)
+ end
else
- ProgressiveFixedSLI(rpm, 6200, 6390, 6480, 6590, 6620 , 6670 , 6750 , 6800, 6895, 7040, 7040, 7040, 7040)
+ if dev == "FANATEC" then
+ RpmFanatec(rpm, 6620 , 6670 , 6750 , 6800, 6895, 7040, 7040, 7040, 7040)
+ else
+ ProgressiveFixedSLI(rpm, 6200, 6390, 6480, 6590, 6620 , 6670 , 6750 , 6800, 6895, 7040, 7040, 7040, 7040)
+ end
end
elseif cNm == "williamsfw31" then
- AlternateSLI(rpm, gRedZone, 11.0, 12.0, 12.9)
+ if dev == "FANATEC" then
+ AlternateFanatec(rpm, gRedZone, 7.0, 8.0, 8.9)
+ else
+ AlternateSLI(rpm, gRedZone, 11.0, 12.0, 12.9)
+ end
elseif cNm == "mx5 cup" or cNm == "mx5 roadster" then
- SideToCenterSLI(rpm, gRedZone, 86, 90, 95, 96 ,97 ,98 ,99)
+ if dev == "FANATEC" then
+ SideToCenterFanatec(rpm, gRedZone, 95, 96 ,97 ,98 ,99)
+ else
+ SideToCenterSLI(rpm, gRedZone, 86, 90, 95, 96 ,97 ,98 ,99)
+ end
elseif cNm == "fr500s" then
- SideToCenterSLI(rpm, gRedZone, 80, 84, 86, 88 ,90 ,98 ,99)
+ if dev == "FANATEC" then
+ SideToCenterFanatec(rpm, gRedZone, 86, 88 ,90 ,98 ,99)
+ else
+ SideToCenterSLI(rpm, gRedZone, 80, 84, 86, 88 ,90 ,98 ,99)
+ end
elseif cNm == "fordv8sc" then
- SideToCenterSLI(rpm, gRedZone, 87, 90, 92, 94 ,97 ,98 ,99)
+ if dev == "FANATEC" then
+ SideToCenterFanatec(rpm, gRedZone, 92, 94 ,97 ,98 ,99)
+ else
+ SideToCenterSLI(rpm, gRedZone, 87, 90, 92, 94 ,97 ,98 ,99)
+ end
elseif cNm == "dallara" then
- SideToCenterSLI(rpm, gRedZone, 78, 82, 90, 94 ,97 ,98 ,99)
---
+ if dev == "FANATEC" then
+ SideToCenterFanatec(rpm, gRedZone, 90, 94 ,97 ,98 ,99)
+ else
+ SideToCenterSLI(rpm, gRedZone, 78, 82, 90, 94 ,97 ,98 ,99)
+ end
+
elseif cNm == "fordgt" then
- SideToCenterSLI(rpm, gRedZone, 93, 94, 95, 96 ,97 ,98 ,99)
+ if dev == "FANATEC" then
+ SideToCenterFanatec(rpm, gRedZone, 95, 96 ,97 ,98 ,99)
+ else
+ SideToCenterSLI(rpm, gRedZone, 93, 94, 95, 96 ,97 ,98 ,99)
+ end
elseif cNm == "hpdarx01c" then
- ProgressiveFixedSLI(rpm, 7800, 7900, 8100, 8300, 8500 , 8700 , 8800 , 8900, 9100, 9300, 9500, 9700, 9940)
-
+ if dev == "FANATEC" then
+ RpmFanatec(rpm, 8500 , 8700 , 8800 , 8900, 9100, 9300, 9500, 9700, 9940)
+ else
+ ProgressiveFixedSLI(rpm, 7800, 7900, 8100, 8300, 8500 , 8700 , 8800 , 8900, 9100, 9300, 9500, 9700, 9940)
+ end
+
elseif cNm == "rileydp" then
- ProgressiveFixedSLI(rpm, 10000, 6700, 6800, 6900, 7000 , 10000 , 10000 , 10000, 10000, 10000, 10000, 10000, 10000)
-
+ if dev == "FANATEC" then
+ RpmFanatec(rpm, 6900, 7000 , 10000 , 10000 , 10000, 10000, 10000, 10000, 10000)
+ else
+ ProgressiveFixedSLI(rpm, 10000, 6700, 6800, 6900, 7000 , 10000 , 10000 , 10000, 10000, 10000, 10000, 10000, 10000)
+ end
+
elseif cNm == "c6r" then
- ProgressiveFixedSLI(rpm, 4700, 4800, 4900, 5000, 5200 , 5300 , 5400 , 5600, 5700, 5800, 5900, 6000, 6100)
+ if dev == "FANATEC" then
+ RpmFanatec(rpm, 5200 , 5300 , 5400 , 5600, 5700, 5800, 5900, 6000, 6100)
+ else
+ ProgressiveFixedSLI(rpm, 4700, 4800, 4900, 5000, 5200 , 5300 , 5400 , 5600, 5700, 5800, 5900, 6000, 6100)
+ end
elseif cNm == "radical sr8" then
- ProgressiveFixedSLI(rpm, 4350, 4800, 5100, 5700, 6400 , 6900 , 7700 , 8100, 8700, 9850, 10100, 10250, 10500)
+ if dev == "FANATEC" then
+ RpmFanatec(rpm, 6400 , 6900 , 7700 , 8100, 8700, 9850, 10100, 10250, 10500)
+ else
+ ProgressiveFixedSLI(rpm, 4350, 4800, 5100, 5700, 6400 , 6900 , 7700 , 8100, 8700, 9850, 10100, 10250, 10500)
+ end
elseif cNm == "jettatdi" then
- SideToCenterSLI(rpm, gRedZone, 80, 84, 86, 88 ,90 ,98 ,99)
+ if dev == "FANATEC" then
+ SideToCenterFanatec(rpm, gRedZone, 86, 88 ,90 ,98 ,99)
+ else
+ SideToCenterSLI(rpm, gRedZone, 80, 84, 86, 88 ,90 ,98 ,99)
+ end
elseif cNm == "cadillacctsvr" then
--ProgressiveFixedSLI(rpm, 6500, 6580, 6600, 6700, 6800 , 6900 , 7000 , 7100, 7200, 7300, 7400, 7500, 7600)
- ProgressiveSLI(rpm, gRedZone, 11.9, 11.95, 11.98, 12, 12.1, 12.15, 12.2, 12.25, 12.3, 12.35, 12.5, 12.8, 12.98 )
+ if dev == "FANATEC" then
+ ProgressiveFanatec(rpm, 7.9, 8.15, 8.2, 8.25, 8.3, 8.35, 8.5, 8.8, 8.98 )
+ else
+ ProgressiveSLI(rpm, gRedZone, 11.9, 11.95, 11.98, 12, 12.1, 12.15, 12.2, 12.25, 12.3, 12.35, 12.5, 12.8, 12.98 )
+ end
-- progressive default method for all cars with dashboard without leds
-- elseif cNm == "latemodel" then
@@ -337,19 +421,35 @@ function iRacing_shiftLightsMethodEvent(idx)
else
-- default
- ProgressiveSLI(rpm, gRedZone, 7.5, 8, 8.5, 9, 9.5, 10, 10.5, 11, 11.5, 12, 12.5, 12.8, 12.98 )
+ if dev == "FANATEC" then
+ ProgressiveFanatec(rpm, 4.5, 5, 6.5, 7, 7.5, 8, 8.5, 8.8, 8.98 )
+ else
+ ProgressiveSLI(rpm, gRedZone, 7.5, 8, 8.5, 9, 9.5, 10, 10.5, 11, 11.5, 12, 12.5, 12.8, 12.98 )
+ end
end
-- set leds
SetRPMLed(tName)
end
-function iRacing_ospMethodEvent(idx)
+function iRacing_ospMethodEvent(idx, devType)
-- get car name
local cNm = GetContextInfo("carname")
- -- OSP Method stuff
- if cNm == "mclarenmp4" or cNm == "williamsfw31" then
- if mOSPMethod ~= nil then mOSPMethod = 3 end
+ -- OSP Method stuff
+ if mOSPMethod ~= nil then
+ if cNm == "mclarenmp4" or cNm == "williamsfw31" then
+ --if devType == "FANATEC" then
+ -- mOSPMethod = 0
+ --else
+ mOSPMethod = 3
+ --end
+
+ -- else
+ -- -- default
+ -- if devType == "FANATEC" then
+ -- mOSPMethod = 1
+ -- end
+ end
end
return 2
end \ No newline at end of file