diff options
author | Hugues Hiegel <hugues@hiegel.fr> | 2013-11-15 12:24:10 +0100 |
---|---|---|
committer | Hugues Hiegel <hugues@hiegel.fr> | 2013-11-15 12:35:51 +0100 |
commit | 9d1de325216b89a6682a639fe235d781b6963d69 (patch) | |
tree | 8752c6554f47dd06e4e768f7ef6ff781dd5ef92f | |
parent | 7b74203c84c48b1c049354022e778c9b25b9fa8a (diff) |
CLEANUP.
-rw-r--r-- | scripts/controls.lua | 646 | ||||
-rw-r--r-- | scripts/custom_events.lua | 76 | ||||
-rw-r--r-- | scripts/devhook.lua | 76 | ||||
-rw-r--r-- | scripts/enter_exit_session.lua | 74 | ||||
-rw-r--r-- | scripts/fanatec.lua | 1000 | ||||
-rw-r--r-- | scripts/fanatec_iracing.lua | 20 | ||||
-rw-r--r-- | scripts/functions_tools.lua | 468 | ||||
-rw-r--r-- | scripts/gear.lua | 350 | ||||
-rw-r--r-- | scripts/global.lua | 1038 | ||||
-rw-r--r-- | scripts/global_custom_scripts.lua | 418 | ||||
-rw-r--r-- | scripts/led.lua | 89 | ||||
-rw-r--r-- | scripts/osp.lua | 1512 | ||||
-rw-r--r-- | scripts/shiftlights.lua | 200 | ||||
-rw-r--r-- | scripts/simracedlx.lua | 1074 | ||||
-rw-r--r-- | scripts/simracedlx_iracing.lua | 20 | ||||
-rw-r--r-- | scripts/simracef1.lua | 1388 | ||||
-rw-r--r-- | scripts/simracef1_iracing.lua | 20 | ||||
-rw-r--r-- | scripts/slidevice.lua | 60 | ||||
-rw-r--r-- | scripts/sliemu_iracing.lua | 20 | ||||
-rw-r--r-- | scripts/slim_iracing.lua | 20 | ||||
-rw-r--r-- | scripts/slipro.lua | 1730 | ||||
-rw-r--r-- | scripts/slipro_gus.lua | 436 | ||||
-rw-r--r-- | scripts/slipro_iracing.lua | 20 | ||||
-rw-r--r-- | scripts/speedlimiter.lua | 2036 | ||||
-rw-r--r-- | scripts/srf1emu_iracing.lua | 20 |
25 files changed, 6405 insertions, 6406 deletions
diff --git a/scripts/controls.lua b/scripts/controls.lua index c687c11..de6b889 100644 --- a/scripts/controls.lua +++ b/scripts/controls.lua @@ -1,323 +1,323 @@ --- SLIMax Mgr Lua Script v3.1.4
--- Copyright (c)2012-2013 by Zappadoc - All Rights Reserved.
--- last change by Zappadoc - 2013-10
-
--- param deviceType = (see GetDeviceType() to get device name )
--- 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
--- param funcIndex = mapped to internal function or -1
--- param targetDevice = the device targeted, should be equal to deviceType above or different
--- if mapped to other device (see GetDeviceType() to get device name )
--- return 0 to give the control to SLIMax Mgr
--- return 1 to force the update of device
-function controlsEvent(deviceType, ctrlType, ctrlPos, value, funcIndex, targetDevice)
- -- call custom script
- local result = custom_controlsEvent(deviceType, ctrlType, ctrlPos, value, funcIndex, targetDevice)
- -- 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_controlsEvent(deviceType, ctrlType, ctrlPos, value, funcIndex, targetDevice)
- -- 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 loopFlag = false
- local dev = ""
- dev = GetDeviceType(deviceType)
- if dev == nil then dev = "none" end
-
- local targetdev = ""
- targetdev = GetDeviceType(targetDevice)
- if targetdev == nil then targetdev = "none" end
-
- -- switches and buttons
- -- ctrl change event
- local state = 0
- local ftecStr = ""
- local leftStr = ""
- local rightStr = ""
-
- local oldTcks = GetTicks()
-
- local delay = 600
- if funcIndex ~= -1 then
- if IsSLIFunction("maxgear", funcIndex) and mMaxGearFeedbackAllowed then
- -- max gear switch
- -- value from 4 to 7
- local mxgear = 0
- mxgear = GetCarInfo("maxgear")
-
- leftStr = "GEAR "
- rightStr = rightStr.format( "MAX%1d ", mxgear)
-
- -- set digits
- UpdateDigits(leftStr, rightStr)
- SLISendReport(0)
-
- state = 1
- -- set timeout
- oldTcks = GetTicks() + delay
-
- elseif IsSLIFunction("brightness", funcIndex) and mBrightnessFeedbackAllowed then
- -- brightness feedback (switch or buttons)
- BrightnessFeedBack(targetdev)
-
- leftStr = "888888"
- rightStr = "888888"
-
- SLISendReport(0)
-
- state = 1
- -- set timeout
- oldTcks = GetTicks() + delay
-
- elseif IsSLIFunction("ospfactor", funcIndex) and mOSPFeedbackAllowed then
- -- OSP Factor feedback
- leftStr = "OSP "
-
- local ospf = GetContextInfo("ospfactor")
- rightStr = rightStr.format(" %03d ", ospf)
-
- -- set digits
- UpdateDigits(leftStr, rightStr)
- SLISendReport(0)
-
- state = 1
- -- set timeout
- oldTcks = GetTicks() + delay
-
- elseif IsSLIFunction("speedmetric", funcIndex) and mUnitFeedbackAllowed then
- -- metric KPH or MPH
- local spdm = false
- spdm = GetContextInfo("speedmetric")
-
- leftStr = "SPD "
- rightStr = " KPH "
- if spdm then rightStr = " MPH " end
-
- -- set digits
- UpdateDigits(leftStr, rightStr)
- SLISendReport(0)
-
- 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 = GetContextInfo("rightdigits")
-
- if ctrlType == 1 then
- leftStr = leftStr.format("B%02d ", ctrlPos)
- else
- leftStr = leftStr.format("S%1d ", ctrlPos)
- end
- rightStr = rightStr.format("P%02d ", info+1)
-
- -- set digits
- UpdateDigits(leftStr, rightStr)
- SLISendReport(0)
-
- state = 1
- -- set timeout
- oldTcks = GetTicks() + delay
-
- elseif IsSLIFunction("leftdigits", funcIndex) and mLeftDigitsFeedbackAllowed then
- -- leftdigits feedback
- local info = GetContextInfo("leftdigits")
- rightStr = leftStr.format("P%02d ", info+1)
-
- if ctrlType == 1 then
- leftStr = rightStr.format("B%02d ", ctrlPos)
- else
- leftStr = rightStr.format("S%1d ", ctrlPos)
- end
-
- -- set digits
- UpdateDigits(leftStr, rightStr)
- SLISendReport(0)
-
- state = 1
- -- set timeout
- oldTcks = GetTicks() + delay
-
- elseif IsSLIFunction("lowfuel", funcIndex) and mLowFuelFeedbackAllowed then
- -- lowfuel feedback
- -- get the option
- local info = GetContextInfo("lowfuel")
-
- -- set digits
- leftStr = leftStr.format("FUEL ", ctrlPos)
- rightStr = rightStr.format("L %02d ", info)
-
- UpdateDigits(leftStr, rightStr)
- SLISendReport(0)
-
- state = 1
- -- set timeout
- oldTcks = GetTicks() + delay
- end
- else
-
- if ctrlType == 0 then
- -- switch
-
- if mDemoMapToKeyAllowed and ctrlPos == mDemoMapToKeySwitch then
- -- demo script
- -- mapping a keystroke (see global.lua to set the targeted switch)
- local key = ""
- if value == 2 then key = "v" end
- -- if value == 3 then key = "K" end
- -- if value == 4 then key = "v" end
- -- if value == 5 then key = "F5" end
- if key ~= "" then
- -- params: key, delay, modifier
- SetKeystroke(key, 100, "")
- end
- end
-
- if mSwitchFeedbackAllowed then
- -- general switch feedback (see global.lua to activate)
- leftStr = leftStr.format("S%1d ", ctrlPos)
- rightStr = rightStr.format("P%02d ", value)
-
- -- set digits
- UpdateDigits(leftStr, rightStr)
- SLISendReport(0)
-
- state = 1
- -- set timeout
- oldTcks = GetTicks() + delay
- end
- elseif ctrlType == 1 then
- if ctrlPos == mDumpLapButton and dev == "SLI-PRO" and value>0 and mDumpLapAllowed then
- -- sample script using button of SLI-PRO to
- -- toggle telemetry dumplastlap flag (true or false)
- -- telemetry logs are stored in telemetry directory
- -- after each completed lap
- local dlap = GetContextInfo("dumplastlap")
- local flag = not dlap;
- TelemetryTools("dumplastlap", flag);
- -- set digits
- leftStr = "tELENN"
- if flag then
- rightStr = "SAVE "
- else
- rightStr = "FALSE "
- end
- UpdateDigits(leftStr, rightStr)
- SLISendReport(0)
-
- state = 1
- -- set timeout
- oldTcks = GetTicks() + delay
- end
- end
- end
-
- if state >= 1 then
- -- loop until timeout
- local newtcks = GetTicks()
- loopFlag = true
- while(oldTcks > newtcks and loopFlag ) do
- SLISleep(10)
- newtcks = GetTicks()
- SetLeftDigits(leftStr)
- SetRightDigits(rightStr)
- SLISendReport(0)
- end
-
- -- cleanup device
- oldTcks = 0
- state = 0
- toggleAllLed(0)
- UpdateDigits(" ", " ")
- SLISendReport(0)
-
- -- allow Mgr to display info on digits
- SetDigitsAllowed(true)
- end
-
- -- skip
- return 0
-end
-
--- set leds, digits, parts to cleanup and timeout
-function UpdateDigits(leftInfo, rightInfo)
- -- do not refresh digits until timeout
- SetDigitsAllowed(false)
- mF1LeftSpdLmtText = string.sub(leftInfo,4)
- mF1RightSpdLmtText = string.sub(rightInfo,4)
-
- -- set digits string
- SetLeftDigits(leftInfo)
- SetRightDigits(rightInfo)
-
-end
-
--- brightness feedback function
-function BrightnessFeedBack(device)
- -- set all leds
- toggleAllLed(1)
-
- if device == "SLI-PRO" then
- -- SLI-PRO Device
- -- set digits
- UpdateDigits("888888", "888888")
- end
-end
+-- SLIMax Mgr Lua Script v3.1.4 +-- Copyright (c)2012-2013 by Zappadoc - All Rights Reserved. +-- last change by Zappadoc - 2013-10 + +-- param deviceType = (see GetDeviceType() to get device name ) +-- 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 +-- param funcIndex = mapped to internal function or -1 +-- param targetDevice = the device targeted, should be equal to deviceType above or different +-- if mapped to other device (see GetDeviceType() to get device name ) +-- return 0 to give the control to SLIMax Mgr +-- return 1 to force the update of device +function controlsEvent(deviceType, ctrlType, ctrlPos, value, funcIndex, targetDevice) + -- call custom script + local result = custom_controlsEvent(deviceType, ctrlType, ctrlPos, value, funcIndex, targetDevice) + -- 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_controlsEvent(deviceType, ctrlType, ctrlPos, value, funcIndex, targetDevice) + -- 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 loopFlag = false + local dev = "" + dev = GetDeviceType(deviceType) + if dev == nil then dev = "none" end + + local targetdev = "" + targetdev = GetDeviceType(targetDevice) + if targetdev == nil then targetdev = "none" end + + -- switches and buttons + -- ctrl change event + local state = 0 + local ftecStr = "" + local leftStr = "" + local rightStr = "" + + local oldTcks = GetTicks() + + local delay = 600 + if funcIndex ~= -1 then + if IsSLIFunction("maxgear", funcIndex) and mMaxGearFeedbackAllowed then + -- max gear switch + -- value from 4 to 7 + local mxgear = 0 + mxgear = GetCarInfo("maxgear") + + leftStr = "GEAR " + rightStr = rightStr.format( "MAX%1d ", mxgear) + + -- set digits + UpdateDigits(leftStr, rightStr) + SLISendReport(0) + + state = 1 + -- set timeout + oldTcks = GetTicks() + delay + + elseif IsSLIFunction("brightness", funcIndex) and mBrightnessFeedbackAllowed then + -- brightness feedback (switch or buttons) + BrightnessFeedBack(targetdev) + + leftStr = "888888" + rightStr = "888888" + + SLISendReport(0) + + state = 1 + -- set timeout + oldTcks = GetTicks() + delay + + elseif IsSLIFunction("ospfactor", funcIndex) and mOSPFeedbackAllowed then + -- OSP Factor feedback + leftStr = "OSP " + + local ospf = GetContextInfo("ospfactor") + rightStr = rightStr.format(" %03d ", ospf) + + -- set digits + UpdateDigits(leftStr, rightStr) + SLISendReport(0) + + state = 1 + -- set timeout + oldTcks = GetTicks() + delay + + elseif IsSLIFunction("speedmetric", funcIndex) and mUnitFeedbackAllowed then + -- metric KPH or MPH + local spdm = false + spdm = GetContextInfo("speedmetric") + + leftStr = "SPD " + rightStr = " KPH " + if spdm then rightStr = " MPH " end + + -- set digits + UpdateDigits(leftStr, rightStr) + SLISendReport(0) + + 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 = GetContextInfo("rightdigits") + + if ctrlType == 1 then + leftStr = leftStr.format("B%02d ", ctrlPos) + else + leftStr = leftStr.format("S%1d ", ctrlPos) + end + rightStr = rightStr.format("P%02d ", info+1) + + -- set digits + UpdateDigits(leftStr, rightStr) + SLISendReport(0) + + state = 1 + -- set timeout + oldTcks = GetTicks() + delay + + elseif IsSLIFunction("leftdigits", funcIndex) and mLeftDigitsFeedbackAllowed then + -- leftdigits feedback + local info = GetContextInfo("leftdigits") + rightStr = leftStr.format("P%02d ", info+1) + + if ctrlType == 1 then + leftStr = rightStr.format("B%02d ", ctrlPos) + else + leftStr = rightStr.format("S%1d ", ctrlPos) + end + + -- set digits + UpdateDigits(leftStr, rightStr) + SLISendReport(0) + + state = 1 + -- set timeout + oldTcks = GetTicks() + delay + + elseif IsSLIFunction("lowfuel", funcIndex) and mLowFuelFeedbackAllowed then + -- lowfuel feedback + -- get the option + local info = GetContextInfo("lowfuel") + + -- set digits + leftStr = leftStr.format("FUEL ", ctrlPos) + rightStr = rightStr.format("L %02d ", info) + + UpdateDigits(leftStr, rightStr) + SLISendReport(0) + + state = 1 + -- set timeout + oldTcks = GetTicks() + delay + end + else + + if ctrlType == 0 then + -- switch + + if mDemoMapToKeyAllowed and ctrlPos == mDemoMapToKeySwitch then + -- demo script + -- mapping a keystroke (see global.lua to set the targeted switch) + local key = "" + if value == 2 then key = "v" end + -- if value == 3 then key = "K" end + -- if value == 4 then key = "v" end + -- if value == 5 then key = "F5" end + if key ~= "" then + -- params: key, delay, modifier + SetKeystroke(key, 100, "") + end + end + + if mSwitchFeedbackAllowed then + -- general switch feedback (see global.lua to activate) + leftStr = leftStr.format("S%1d ", ctrlPos) + rightStr = rightStr.format("P%02d ", value) + + -- set digits + UpdateDigits(leftStr, rightStr) + SLISendReport(0) + + state = 1 + -- set timeout + oldTcks = GetTicks() + delay + end + elseif ctrlType == 1 then + if ctrlPos == mDumpLapButton and dev == "SLI-PRO" and value>0 and mDumpLapAllowed then + -- sample script using button of SLI-PRO to + -- toggle telemetry dumplastlap flag (true or false) + -- telemetry logs are stored in telemetry directory + -- after each completed lap + local dlap = GetContextInfo("dumplastlap") + local flag = not dlap; + TelemetryTools("dumplastlap", flag); + -- set digits + leftStr = "tELENN" + if flag then + rightStr = "SAVE " + else + rightStr = "FALSE " + end + UpdateDigits(leftStr, rightStr) + SLISendReport(0) + + state = 1 + -- set timeout + oldTcks = GetTicks() + delay + end + end + end + + if state >= 1 then + -- loop until timeout + local newtcks = GetTicks() + loopFlag = true + while(oldTcks > newtcks and loopFlag ) do + SLISleep(10) + newtcks = GetTicks() + SetLeftDigits(leftStr) + SetRightDigits(rightStr) + SLISendReport(0) + end + + -- cleanup device + oldTcks = 0 + state = 0 + toggleAllLed(0) + UpdateDigits(" ", " ") + SLISendReport(0) + + -- allow Mgr to display info on digits + SetDigitsAllowed(true) + end + + -- skip + return 0 +end + +-- set leds, digits, parts to cleanup and timeout +function UpdateDigits(leftInfo, rightInfo) + -- do not refresh digits until timeout + SetDigitsAllowed(false) + mF1LeftSpdLmtText = string.sub(leftInfo,4) + mF1RightSpdLmtText = string.sub(rightInfo,4) + + -- set digits string + SetLeftDigits(leftInfo) + SetRightDigits(rightInfo) + +end + +-- brightness feedback function +function BrightnessFeedBack(device) + -- set all leds + toggleAllLed(1) + + if device == "SLI-PRO" then + -- SLI-PRO Device + -- set digits + UpdateDigits("888888", "888888") + end +end diff --git a/scripts/custom_events.lua b/scripts/custom_events.lua index 9b6513a..4cebe7a 100644 --- a/scripts/custom_events.lua +++ b/scripts/custom_events.lua @@ -1,39 +1,39 @@ --- Custom Events SLIMax Manager Scripts v1.2
--- Copyright ©2012-2013 by Zappadoc - All Rights Reserved.
--- last change by Zappadoc - 2013-09
-
--- ================================
--- IMPORTANT:
--- local custom events PLACEHOLDERS
--- DO NOT CHANGE THE SCRIPT BELOW
--- ================================
-function custom_controlsEvent(deviceType, ctrlType, ctrlPos, value, funcIndex, targetDevice) return 2 end
-function custom_deviceReport(deviceType) 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_ospSRDlxMethodEvent(idx) return 2 end
-function custom_ospSRF1MethodEvent(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_shiftLightsSRDlxMethodEvent(idx) return 2 end
-function custom_srdlxLeftDigitsEvent(swPosition) return 2 end
-function custom_srdlxRightDigitsEvent(swPosition) return 2 end
-function custom_shiftLightsSRF1MethodEvent(idx) return 2 end
-function custom_srf1LeftDigitsEvent(swPosition) return 2 end
-function custom_srf1RightDigitsEvent(swPosition) 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_spdLmtSRDlxMethodEvent(idx) return 2 end
-function custom_spdLmtSRF1MethodEvent(idx) return 2 end
-function custom_gearEvent(gear) return 2 end
-function custom_gearFanatecEvent(gear) return 2 end
-function custom_enterSessionEvent(deviceType) return 2 end
-function custom_exitSessionEvent(deviceType) return 2 end
+-- Custom Events SLIMax Manager Scripts v1.2 +-- Copyright ©2012-2013 by Zappadoc - All Rights Reserved. +-- last change by Zappadoc - 2013-09 + +-- ================================ +-- IMPORTANT: +-- local custom events PLACEHOLDERS +-- DO NOT CHANGE THE SCRIPT BELOW +-- ================================ +function custom_controlsEvent(deviceType, ctrlType, ctrlPos, value, funcIndex, targetDevice) return 2 end +function custom_deviceReport(deviceType) 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_ospSRDlxMethodEvent(idx) return 2 end +function custom_ospSRF1MethodEvent(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_shiftLightsSRDlxMethodEvent(idx) return 2 end +function custom_srdlxLeftDigitsEvent(swPosition) return 2 end +function custom_srdlxRightDigitsEvent(swPosition) return 2 end +function custom_shiftLightsSRF1MethodEvent(idx) return 2 end +function custom_srf1LeftDigitsEvent(swPosition) return 2 end +function custom_srf1RightDigitsEvent(swPosition) 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_spdLmtSRDlxMethodEvent(idx) return 2 end +function custom_spdLmtSRF1MethodEvent(idx) return 2 end +function custom_gearEvent(gear) return 2 end +function custom_gearFanatecEvent(gear) return 2 end +function custom_enterSessionEvent(deviceType) return 2 end +function custom_exitSessionEvent(deviceType) return 2 end function custom_ledEvent(idx, ledFunction, state) return 2 end
\ No newline at end of file diff --git a/scripts/devhook.lua b/scripts/devhook.lua index 944fa05..4d5d6b5 100644 --- a/scripts/devhook.lua +++ b/scripts/devhook.lua @@ -1,38 +1,38 @@ --- SLIMax Mgr Lua Script v3.1
--- Copyright (c)2012-2013 by Zappadoc - All Rights Reserved.
-
-
--- 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(deviceType)
- -- call custom script
- local result = custom_deviceReport(deviceType)
- -- 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_deviceReport(deviceType)
- -- 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
-
- -- sim paused?
- local paused = GetContextInfo("paused")
- -- limiter ON?
- local spdLmt = GetCarInfo("speedlimiter")
- if paused or spdLmt == 0 then
- -- reset value
- SetDigitsAllowed(true)
- SetFanatecDigitsAllowed(true)
- end
-
-
- -- skip and give the control to Mgr
- return 0
-
-end
-
+-- SLIMax Mgr Lua Script v3.1 +-- Copyright (c)2012-2013 by Zappadoc - All Rights Reserved. + + +-- 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(deviceType) + -- call custom script + local result = custom_deviceReport(deviceType) + -- 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_deviceReport(deviceType) + -- 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 + + -- sim paused? + local paused = GetContextInfo("paused") + -- limiter ON? + local spdLmt = GetCarInfo("speedlimiter") + if paused or spdLmt == 0 then + -- reset value + SetDigitsAllowed(true) + SetFanatecDigitsAllowed(true) + end + + + -- skip and give the control to Mgr + return 0 + +end + diff --git a/scripts/enter_exit_session.lua b/scripts/enter_exit_session.lua index 6d42ff2..2a246b5 100644 --- a/scripts/enter_exit_session.lua +++ b/scripts/enter_exit_session.lua @@ -1,37 +1,37 @@ --- SLIMax Mgr Lua Script v3.1
--- Copyright (c)2012-2013 by Zappadoc - All Rights Reserved.
--- Event received when the car enter and exit the session.
-
--- param = device type (integer - see GetDeviceType() )
--- enter session
-function enterSessionEvent(deviceType)
- -- call custom script
- local result = custom_enterSessionEvent(deviceType)
- if result <= 1 then return result end
- -- if result >= 2 continue
-
- -- call global custom script
- result = global_custom_enterSessionEvent(deviceType)
- if result <= 1 then return result end
- -- if result >= 2 continue
-
- -- do nothing
- return 1
-end
-
--- param = device type (integer - see GetDeviceType() )
--- exit session
-function exitSessionEvent(deviceType)
- -- call custom script
- local result = custom_exitSessionEvent(deviceType)
- if result <= 1 then return result end
- -- if result >= 2 continue
-
- -- call global custom script
- result = global_custom_exitSessionEvent(deviceType)
- if result <= 1 then return result end
- -- if result >= 2 continue
-
- -- do nothing
- return 1
-end
+-- SLIMax Mgr Lua Script v3.1 +-- Copyright (c)2012-2013 by Zappadoc - All Rights Reserved. +-- Event received when the car enter and exit the session. + +-- param = device type (integer - see GetDeviceType() ) +-- enter session +function enterSessionEvent(deviceType) + -- call custom script + local result = custom_enterSessionEvent(deviceType) + if result <= 1 then return result end + -- if result >= 2 continue + + -- call global custom script + result = global_custom_enterSessionEvent(deviceType) + if result <= 1 then return result end + -- if result >= 2 continue + + -- do nothing + return 1 +end + +-- param = device type (integer - see GetDeviceType() ) +-- exit session +function exitSessionEvent(deviceType) + -- call custom script + local result = custom_exitSessionEvent(deviceType) + if result <= 1 then return result end + -- if result >= 2 continue + + -- call global custom script + result = global_custom_exitSessionEvent(deviceType) + if result <= 1 then return result end + -- if result >= 2 continue + + -- do nothing + return 1 +end diff --git a/scripts/fanatec.lua b/scripts/fanatec.lua index 46d944c..7809f2b 100644 --- a/scripts/fanatec.lua +++ b/scripts/fanatec.lua @@ -1,500 +1,500 @@ --- Fanatec Lua Script v1.4
--- Copyright (c)2012-2013 by Zappadoc - All Rights Reserved.
--- this script builds all functions associated with
--- digits panels of Fanatec device
--- last change by Zappadoc - 2013-09
-
--- ============================================================
--- 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 if PIT Feedback ON
- local pf = false
- pf = GetContextInfo("pitfeedback")
- if pf == nil or pf == 0 then pf = false end
- if pf then
- -- force position to PIT function if car pits
- local pit = GetCarInfo("inpits")
- if pit > 0 then
- swValue = 41
- end
- end
-
- -- check postion and compute panel string
- if swValue == 1 then
- -- oldGear is intialized in gearEvent (see gear.lua)
- if oldGear ~= nil then
- -- gear
- --local g = GetCarInfo("gear")
-
- -- 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 oldGear == 0 then
- -- if neutral and using custom OSP record then add a dot to gear digit
- SetFanatecGear(n, ospcustom_on)
-
- elseif oldGear < 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(oldGear), 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
- --dlt = true
- lpt = GetTimeInfo("bestlaptime")
- mFanatecText = DisplayFormatTime(lpt,mRefreshLapTimeRate,2,0,3)
-
- SetFanatecDigits( mFanatecText )
- return 1
- elseif swValue == 11 then
- -- last lap time
- --timeFlag = true
- --dlt = true
- lpt = GetTimeInfo("lastlaptime")
- mFanatecText = DisplayFormatTime(lpt,mRefreshLapTimeRate,2,0,3)
- SetFanatecDigits( mFanatecText )
- return 1
- elseif swValue >= 12 and swValue <= 18 and isAppIRacing(sim) then
- --timeFlag = true
- -- iRacing partials
- local ts = GetContextInfo("partialcount")
- local sector = GetCarInfo("sector")
- if sector == nil then sector = 0 end
- if ts ~= nil and ts > 0 then
- if swValue == 12 then
- lpt = GetPartialTimeInfo("currentpartial", sector)
- 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
- mFanatecText = DisplayFormatTime(lpt,mDeltaTimeDelay,2,1,3)
- SetFanatecDigits( mFanatecText )
- return 1
- elseif swValue == 19 then
- -- real time diff vs your best
- --timeFlag = true
- lpt = GetTimeInfo("realdiffbest")
- mFanatecText = DisplayFormatTime(lpt,mDeltaTimeDelay,2,1,3)
- SetFanatecDigits( mFanatecText )
- return 1
- elseif swValue == 20 then
- -- real time diff vs your last
- --timeFlag = true
- lpt = GetTimeInfo("realdifflast")
- mFanatecText = DisplayFormatTime(lpt,mDeltaTimeDelay,2,1,3)
- SetFanatecDigits( mFanatecText )
- return 1
-
- elseif swValue == 21 then
- -- get an average consumption of fuel per lap and gives the remaining laps
- local remainintank = GetCarInfo("remainlapsintank")
- if remainintank >= 100 then
- fPanel = string.format("%3.0f", math.floor (remainintank))
- else
- fPanel = string.format("L%2.0f", math.floor(remainintank))
- end
-
- elseif swValue == 22 then
- -- rpm
- isSlowUpdate = true
- 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
-
- elseif swValue == 41 then
- -- PIT
- fPanel = "PIt"
-
- elseif swValue == 42 then
- -- sc
- local sc = GetContextInfo("safetycare")
- if sc == 1 then
- fPanel = " SC"
- else
- fPanel = " "
- end
-
- else
- fPanel = " "
- end
-
- -- the function below has been replaced with generic time display function in global.lua
-
- -- if timeFlag and lpt ~= nil then
-
- -- -- explod time
- -- hr, mn, sc, hd, ms = timeDispatcher(lpt)
-
-
- -- print("lpt:" .. lpt .. " mn:" .. mn .. " sc:" .. sc .. " hd:" .. hd .. " ms:" .. ms .."\n" )
-
- -- -- update display every mDeltaTimeDelay time
- -- -- current ticks > old backuped value
- -- if GetTicks() > mDeltaTimeOldTicks then
- -- -- store ticks + delay
- -- mDeltaTimeOldTicks = GetTicks() + ( 2 * mDeltaTimeDelay)
-
- -- if lpt == -1 or (mn + sc + ms) == 0.00 then
- -- mDeltaTimeBackup = "-.--"
-
- -- elseif mn > 0 or sc >= 10 then
-
- -- if dlt and mn <100 then
- -- -- display time and mn < 100
- -- if mn >=10 then
- -- -- mn > 10
- -- mDeltaTimeBackup = string.format( "%2d.%01d", mn, sc)
- -- else
- -- mDeltaTimeBackup = string.format( "%1d.%02d", mn, sc)
- -- end
- -- else
- -- -- delta > 9.99s or lap time > 100mn
- -- mDeltaTimeBackup = " . "
- -- end
-
- -- else
- -- -- delta
- -- if lpt < 0 then
- -- -- negative value
- -- mDeltaTimeBackup = string.format( "-%01d.%01d ", sc, round(hd))
- -- else
- -- mDeltaTimeBackup = string.format( "%01d.%02d", sc, round(hd))
- -- end
- -- end
- -- end
-
- -- fPanel = mDeltaTimeBackup
- -- end
-
- if isSlowUpdate then
- -- request slow display update
- if GetTicks() > ( mDeltaTimeDelay + mDeltaTimeOldTicks ) then
- mDeltaTimeOldTicks = GetTicks()
- mFanatecText = fPanel
- end
- else
- -- normal display update
- mFanatecText = fPanel
- end
-
- -- send string to sli manager
- SetFanatecDigits( mFanatecText )
- return 1
-end
-
-
+-- Fanatec Lua Script v1.4 +-- Copyright (c)2012-2013 by Zappadoc - All Rights Reserved. +-- this script builds all functions associated with +-- digits panels of Fanatec device +-- last change by Zappadoc - 2013-09 + +-- ============================================================ +-- 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 if PIT Feedback ON + local pf = false + pf = GetContextInfo("pitfeedback") + if pf == nil or pf == 0 then pf = false end + if pf then + -- force position to PIT function if car pits + local pit = GetCarInfo("inpits") + if pit > 0 then + swValue = 41 + end + end + + -- check postion and compute panel string + if swValue == 1 then + -- oldGear is intialized in gearEvent (see gear.lua) + if oldGear ~= nil then + -- gear + --local g = GetCarInfo("gear") + + -- 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 oldGear == 0 then + -- if neutral and using custom OSP record then add a dot to gear digit + SetFanatecGear(n, ospcustom_on) + + elseif oldGear < 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(oldGear), 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 + --dlt = true + lpt = GetTimeInfo("bestlaptime") + mFanatecText = DisplayFormatTime(lpt,mRefreshLapTimeRate,2,0,3) + + SetFanatecDigits( mFanatecText ) + return 1 + elseif swValue == 11 then + -- last lap time + --timeFlag = true + --dlt = true + lpt = GetTimeInfo("lastlaptime") + mFanatecText = DisplayFormatTime(lpt,mRefreshLapTimeRate,2,0,3) + SetFanatecDigits( mFanatecText ) + return 1 + elseif swValue >= 12 and swValue <= 18 and isAppIRacing(sim) then + --timeFlag = true + -- iRacing partials + local ts = GetContextInfo("partialcount") + local sector = GetCarInfo("sector") + if sector == nil then sector = 0 end + if ts ~= nil and ts > 0 then + if swValue == 12 then + lpt = GetPartialTimeInfo("currentpartial", sector) + 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 + mFanatecText = DisplayFormatTime(lpt,mDeltaTimeDelay,2,1,3) + SetFanatecDigits( mFanatecText ) + return 1 + elseif swValue == 19 then + -- real time diff vs your best + --timeFlag = true + lpt = GetTimeInfo("realdiffbest") + mFanatecText = DisplayFormatTime(lpt,mDeltaTimeDelay,2,1,3) + SetFanatecDigits( mFanatecText ) + return 1 + elseif swValue == 20 then + -- real time diff vs your last + --timeFlag = true + lpt = GetTimeInfo("realdifflast") + mFanatecText = DisplayFormatTime(lpt,mDeltaTimeDelay,2,1,3) + SetFanatecDigits( mFanatecText ) + return 1 + + elseif swValue == 21 then + -- get an average consumption of fuel per lap and gives the remaining laps + local remainintank = GetCarInfo("remainlapsintank") + if remainintank >= 100 then + fPanel = string.format("%3.0f", math.floor (remainintank)) + else + fPanel = string.format("L%2.0f", math.floor(remainintank)) + end + + elseif swValue == 22 then + -- rpm + isSlowUpdate = true + 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 + + elseif swValue == 41 then + -- PIT + fPanel = "PIt" + + elseif swValue == 42 then + -- sc + local sc = GetContextInfo("safetycare") + if sc == 1 then + fPanel = " SC" + else + fPanel = " " + end + + else + fPanel = " " + end + + -- the function below has been replaced with generic time display function in global.lua + + -- if timeFlag and lpt ~= nil then + + -- -- explod time + -- hr, mn, sc, hd, ms = timeDispatcher(lpt) + + + -- print("lpt:" .. lpt .. " mn:" .. mn .. " sc:" .. sc .. " hd:" .. hd .. " ms:" .. ms .."\n" ) + + -- -- update display every mDeltaTimeDelay time + -- -- current ticks > old backuped value + -- if GetTicks() > mDeltaTimeOldTicks then + -- -- store ticks + delay + -- mDeltaTimeOldTicks = GetTicks() + ( 2 * mDeltaTimeDelay) + + -- if lpt == -1 or (mn + sc + ms) == 0.00 then + -- mDeltaTimeBackup = "-.--" + + -- elseif mn > 0 or sc >= 10 then + + -- if dlt and mn <100 then + -- -- display time and mn < 100 + -- if mn >=10 then + -- -- mn > 10 + -- mDeltaTimeBackup = string.format( "%2d.%01d", mn, sc) + -- else + -- mDeltaTimeBackup = string.format( "%1d.%02d", mn, sc) + -- end + -- else + -- -- delta > 9.99s or lap time > 100mn + -- mDeltaTimeBackup = " . " + -- end + + -- else + -- -- delta + -- if lpt < 0 then + -- -- negative value + -- mDeltaTimeBackup = string.format( "-%01d.%01d ", sc, round(hd)) + -- else + -- mDeltaTimeBackup = string.format( "%01d.%02d", sc, round(hd)) + -- end + -- end + -- end + + -- fPanel = mDeltaTimeBackup + -- end + + if isSlowUpdate then + -- request slow display update + if GetTicks() > ( mDeltaTimeDelay + mDeltaTimeOldTicks ) then + mDeltaTimeOldTicks = GetTicks() + mFanatecText = fPanel + end + else + -- normal display update + 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 index a84c983..462c502 100644 --- a/scripts/fanatec_iracing.lua +++ b/scripts/fanatec_iracing.lua @@ -1,11 +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
+-- 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/functions_tools.lua b/scripts/functions_tools.lua index 50a7883..592e7bc 100644 --- a/scripts/functions_tools.lua +++ b/scripts/functions_tools.lua @@ -1,234 +1,234 @@ --- SLIMax Mgr Lua Script v1.4
--- PART OF SLIMAX Manager pkg
--- Copyright (c)2012-2013 by Zappadoc - All Rights Reserved.
--- CREDITS: first release - Zappadoc
--- updated - Desty 2013-04-26
-
--- ===============================
--- left and right functions tools
--- ===============================
-
--- add a function name to left and right functions list
-
--- Returns Index if success
--- Returns Index if FunctionName allready exists
--- Returns -1 if Error Reading File
--- Returns -2 if Error writing File
-
--- Usage AddFuncName(FilePath, FunctionName):
-
--- on left list:
--- local err = AddFuncName("cfg/sli_left_functions.ecfg", "DSII KERS")
--- or right list:
--- local err = AddFuncName("cfg/sli_right_functions.ecfg", "DSII KERS")
-
-function AddFuncName(path, func)
-
- idx = 0
- idx = GetFuncIndex(path, func)
- if idx < 0 then
- print("BAD ERROR occurred!")
- return idx --returns errorcode -1 or -2
- elseif idx > 0 then
- return idx -- OK, return index
- end
-
- idx = GetNewFuncIndex(path)
- if idx < 1 then
- print("BAD ERROR occurred!")
- return -1
- end
-
- file,err = io.open(path,"r")
- if err then return -1 end
-
- funcStr = idx.."."..func
- isOK = false
- local t1 = {} --IndexTable
- local t2 = {} --functionsTable
- i= 1
- for line in file:lines() do
- if line == nil then break end
- -- Seperate Index from function name
- a = string.find(line, '.', 1, true)
- if a then
- b = string.sub(line, a+1)
- c = string.sub(line, 1, a-1)
- d=(c + 0)
- -- check for EXACT MATCH of the function name
- if b == func then isOK = true end
- table.insert(t1, d)
- t2[d]= line
- end
- end
- table.insert(t1, idx)
- t2[idx]= funcStr
-
- file:close()
-
- if not isOK then
- -- write mode
- file, err = io.open(path,"w+")
- if err then return -2 end
-
- --sort IndexTable
- table.sort(t1)
-
- -- Write All functions in order of IndexTable
- for i = 1, #t1, 1 do
- a = t1[i]
- b = t2[a]
- --print(" a: "..a.." b: "..b)
- file:write(b)
- file:write("\n")
- end
- file:close()
- end
-
- return idx
-
-end
-
-
- -- Remove a FunctionName
-
--- Returns 1 if success
--- Returns -1 if Error Reading File
--- Returns -2 if Error writing File
-
- --Usage: RemoveFuncName(FunctionName)
-
--- on left list:
--- local err = RemoveFuncName("cfg/sli_left_functions.ecfg", "DSII KERS")
--- or right list:
--- local err = RemoveFuncName("cfg/sli_right_functions.ecfg", "DSII KERS")
-
-function RemoveFuncName(path, func)
-
- file,err = io.open(path,"r")
- if err then return -1 end
-
- t = { }
- i=1
- for line in file:lines() do
- if line == nil then break end
-
- -- Seperate Index from function name
- a = string.find(line, '.', 1, true)
- -- Empty Lines will be deleted
- if a then
- b = string.sub(line, a+1)
- c = string.sub(line, 1, a-1)
- d = (c + 0)
- -- check for an EXACT MATCH of the function name
- if b ~= func or d < 100 then
- t[i] = line
- i= i + 1
- end
- end
- end
- file:close()
-
- -- write mode, delete previous data
- file, err = io.open(path,"w+")
- if err then return -2 end
-
- for k, v in pairs(t) do
- file:write(v)
- file:write("\n")
- end
-
- file:close()
- return 1
-end
-
-
--- Returns Index
--- returns 0 if Function not exists
--- returns -1 if error reading file
-
--- Usage: GetFuncIndex(FilePath, FunctionName)
--- on left list:
--- local idx = GetFuncIndex("cfg/sli_left_functions.ecfg", "DSII KERS")
--- or right list:
--- localidx = GetFuncIndex("cfg/sli_right_functions.ecfg", "DSII KERS")
-
-function GetFuncIndex(path, func)
-
- file,err = io.open(path,"r")
- if err then return -1 end
-
- for line in file:lines() do
- if line == nil then break end
- -- Seperate Index from function name
- a = string.find(line, '.', 1, true)
- if a then
- b = string.sub( line, a+1)
- -- check for an EXACT MATCH of the function name
- if b == func then
- c = string.sub( line,1, a-1)
- d = (c + 0)
- return d
- end
- end
- end
-
- return 0
-
-end
-
-
--- Returns lowest function index available (above 100)
--- Returns -1 if Error Reading File
-
--- typical usage GetNewFuncIndex(FilePath):
--- on left list:
--- local num_available = GetNewFuncIndex("cfg/sli_left_functions.ecfg")
--- or right list:
--- local num_available = GetNewFuncIndex("cfg/sli_right_functions.ecfg")
-
-function GetNewFuncIndex(path)
-
- local t = { 99,}
- local idx = 99
-
- file,err = io.open(path,"r")
- if err then return -1 end
-
- for line in file:lines() do
- if line == nil then break end
- -- Seperate Index from function name
- a = string.find(line, '.', 1, true)
- if a then
- b = string.sub( line,1, a-1)
- -- string to num conversion
- c = (b + 0)
- -- store if it's greater
- if c > idx then
- table.insert(t, c)
- end
- end
- end
- file:close()
-
- table.sort(t)
- --s = table.concat(t, ", ")
- --print(s)
-
- idx = 0
- local n = #t-1
- for i = 1, n, 1 do
- if t[i] < (t[i+1]-1) then
- if idx == 0 then --added this Iteration
- idx = t[i]+1 --to start at the lowest gap
- end
- end
- end
- if idx == 0 then
- idx = t[n+1]+1
- end
-
- return idx
-
-end
-
+-- SLIMax Mgr Lua Script v1.4 +-- PART OF SLIMAX Manager pkg +-- Copyright (c)2012-2013 by Zappadoc - All Rights Reserved. +-- CREDITS: first release - Zappadoc +-- updated - Desty 2013-04-26 + +-- =============================== +-- left and right functions tools +-- =============================== + +-- add a function name to left and right functions list + +-- Returns Index if success +-- Returns Index if FunctionName allready exists +-- Returns -1 if Error Reading File +-- Returns -2 if Error writing File + +-- Usage AddFuncName(FilePath, FunctionName): + +-- on left list: +-- local err = AddFuncName("cfg/sli_left_functions.ecfg", "DSII KERS") +-- or right list: +-- local err = AddFuncName("cfg/sli_right_functions.ecfg", "DSII KERS") + +function AddFuncName(path, func) + + idx = 0 + idx = GetFuncIndex(path, func) + if idx < 0 then + print("BAD ERROR occurred!") + return idx --returns errorcode -1 or -2 + elseif idx > 0 then + return idx -- OK, return index + end + + idx = GetNewFuncIndex(path) + if idx < 1 then + print("BAD ERROR occurred!") + return -1 + end + + file,err = io.open(path,"r") + if err then return -1 end + + funcStr = idx.."."..func + isOK = false + local t1 = {} --IndexTable + local t2 = {} --functionsTable + i= 1 + for line in file:lines() do + if line == nil then break end + -- Seperate Index from function name + a = string.find(line, '.', 1, true) + if a then + b = string.sub(line, a+1) + c = string.sub(line, 1, a-1) + d=(c + 0) + -- check for EXACT MATCH of the function name + if b == func then isOK = true end + table.insert(t1, d) + t2[d]= line + end + end + table.insert(t1, idx) + t2[idx]= funcStr + + file:close() + + if not isOK then + -- write mode + file, err = io.open(path,"w+") + if err then return -2 end + + --sort IndexTable + table.sort(t1) + + -- Write All functions in order of IndexTable + for i = 1, #t1, 1 do + a = t1[i] + b = t2[a] + --print(" a: "..a.." b: "..b) + file:write(b) + file:write("\n") + end + file:close() + end + + return idx + +end + + + -- Remove a FunctionName + +-- Returns 1 if success +-- Returns -1 if Error Reading File +-- Returns -2 if Error writing File + + --Usage: RemoveFuncName(FunctionName) + +-- on left list: +-- local err = RemoveFuncName("cfg/sli_left_functions.ecfg", "DSII KERS") +-- or right list: +-- local err = RemoveFuncName("cfg/sli_right_functions.ecfg", "DSII KERS") + +function RemoveFuncName(path, func) + + file,err = io.open(path,"r") + if err then return -1 end + + t = { } + i=1 + for line in file:lines() do + if line == nil then break end + + -- Seperate Index from function name + a = string.find(line, '.', 1, true) + -- Empty Lines will be deleted + if a then + b = string.sub(line, a+1) + c = string.sub(line, 1, a-1) + d = (c + 0) + -- check for an EXACT MATCH of the function name + if b ~= func or d < 100 then + t[i] = line + i= i + 1 + end + end + end + file:close() + + -- write mode, delete previous data + file, err = io.open(path,"w+") + if err then return -2 end + + for k, v in pairs(t) do + file:write(v) + file:write("\n") + end + + file:close() + return 1 +end + + +-- Returns Index +-- returns 0 if Function not exists +-- returns -1 if error reading file + +-- Usage: GetFuncIndex(FilePath, FunctionName) +-- on left list: +-- local idx = GetFuncIndex("cfg/sli_left_functions.ecfg", "DSII KERS") +-- or right list: +-- localidx = GetFuncIndex("cfg/sli_right_functions.ecfg", "DSII KERS") + +function GetFuncIndex(path, func) + + file,err = io.open(path,"r") + if err then return -1 end + + for line in file:lines() do + if line == nil then break end + -- Seperate Index from function name + a = string.find(line, '.', 1, true) + if a then + b = string.sub( line, a+1) + -- check for an EXACT MATCH of the function name + if b == func then + c = string.sub( line,1, a-1) + d = (c + 0) + return d + end + end + end + + return 0 + +end + + +-- Returns lowest function index available (above 100) +-- Returns -1 if Error Reading File + +-- typical usage GetNewFuncIndex(FilePath): +-- on left list: +-- local num_available = GetNewFuncIndex("cfg/sli_left_functions.ecfg") +-- or right list: +-- local num_available = GetNewFuncIndex("cfg/sli_right_functions.ecfg") + +function GetNewFuncIndex(path) + + local t = { 99,} + local idx = 99 + + file,err = io.open(path,"r") + if err then return -1 end + + for line in file:lines() do + if line == nil then break end + -- Seperate Index from function name + a = string.find(line, '.', 1, true) + if a then + b = string.sub( line,1, a-1) + -- string to num conversion + c = (b + 0) + -- store if it's greater + if c > idx then + table.insert(t, c) + end + end + end + file:close() + + table.sort(t) + --s = table.concat(t, ", ") + --print(s) + + idx = 0 + local n = #t-1 + for i = 1, n, 1 do + if t[i] < (t[i+1]-1) then + if idx == 0 then --added this Iteration + idx = t[i]+1 --to start at the lowest gap + end + end + end + if idx == 0 then + idx = t[n+1]+1 + end + + return idx + +end + diff --git a/scripts/gear.lua b/scripts/gear.lua index 54649d6..bcf0361 100644 --- a/scripts/gear.lua +++ b/scripts/gear.lua @@ -1,176 +1,176 @@ --- SLIMax Mgr Lua Script v3.2.1
--- Copyright (c)2012-2013 by Zappadoc - All Rights Reserved.
--- gear event
--- last change by Zappadoc - 2013-09
-
-function Ignition(gear, isFanatec)
- -- ========================================================================================
- -- IGNITION
- -- patch led function damage for ignition
- -- check if sim is rFactor2
- if GetContextInfo("simulation") == "rFactor2.exe" then
- if GetCarInfo("rpm") == 0 and GetCarInfo("rawspeed") == 0 then
- if GetCarInfo("ignition") == 0 then
- -- engine has been stopped
- -- engine has been stopped
- -- do nothing
-
-
- elseif GetCarInfo("ignition") == 1 then
- -- ignition ON after engine stop
- -- engine has been stopped, ignition ON
-
- SetDigitsAllowed(false)
- if isFanatec == true then
- SetFanatecDigits(" ")
- else
- SetLeftDigits (" ")
- SetRightDigits (" ")
- end
-
- SetGearDigit("_")
-
- -- init led
- toggleAllLed(0)
-
- -- blink damage led
- if mOLDIgnitionticks == nil or GetTicks() > mOLDIgnitionticks then
- mOLDIgnitionticks = GetTicks() + 1000
- initLedTable(mRPMLedTable, 1)
-
- SetWarnLed(GetLedIndex("damage"), 1)
-
- else
- initLedTable(mRPMLedTable, 0)
- SetWarnLed(GetLedIndex("damage"), 0)
- end
- SetRPMLed("mRPMLedTable")
- SLISendReport()
- return 1
-
- elseif GetCarInfo("ignition") == 2 and GetCarInfo("rpm") == 0 and GetCarInfo("rawspeed") == 0 then
- -- ignition ON and starter ON
- -- engine has been stopped, ignition ON + Starter ON
-
- SetGearDigit("-")
- SetDigitsAllowed(true)
- -- stop blinking
- initLedTable(mRPMLedTable, 1)
- SetWarnLed(GetLedIndex("damage"), 1)
- SetRPMLed("mRPMLedTable")
- SLISendReport()
- return 1
- end
- end
- end
- return 2
-end
-
--- SIM RACE Deluxe, SIM RACE F1, SLI-M, SLI-PRO Gear Event
-function gearEvent(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 II
- -- 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
-
- -- ignition
- if Ignition(gear, false) <= 1 then return 1 end
-
- local g = gear
- if oldGear == nil then oldGear = -1 end
-
- -- 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")
-
- -- optimize display, call if changed
- 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
- if ospcustom_on then n = n + 128 end
- SetGearDigit(string.char(n))
- elseif g < 0 then
- SetGearDigit(r)
- else
- -- 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
-
-
--- 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_gearFanatecEvent(gear)
- if result <= 1 then return result end
-
- -- call global custom script
- result = global_custom_gearFanatecEvent(gear)
- if result <= 1 then return result end
-
- -- ignition
- if Ignition(gear, true) <= 1 then return 1 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
-
- return 2
+-- SLIMax Mgr Lua Script v3.2.1 +-- Copyright (c)2012-2013 by Zappadoc - All Rights Reserved. +-- gear event +-- last change by Zappadoc - 2013-09 + +function Ignition(gear, isFanatec) + -- ======================================================================================== + -- IGNITION + -- patch led function damage for ignition + -- check if sim is rFactor2 + if GetContextInfo("simulation") == "rFactor2.exe" then + if GetCarInfo("rpm") == 0 and GetCarInfo("rawspeed") == 0 then + if GetCarInfo("ignition") == 0 then + -- engine has been stopped + -- engine has been stopped + -- do nothing + + + elseif GetCarInfo("ignition") == 1 then + -- ignition ON after engine stop + -- engine has been stopped, ignition ON + + SetDigitsAllowed(false) + if isFanatec == true then + SetFanatecDigits(" ") + else + SetLeftDigits (" ") + SetRightDigits (" ") + end + + SetGearDigit("_") + + -- init led + toggleAllLed(0) + + -- blink damage led + if mOLDIgnitionticks == nil or GetTicks() > mOLDIgnitionticks then + mOLDIgnitionticks = GetTicks() + 1000 + initLedTable(mRPMLedTable, 1) + + SetWarnLed(GetLedIndex("damage"), 1) + + else + initLedTable(mRPMLedTable, 0) + SetWarnLed(GetLedIndex("damage"), 0) + end + SetRPMLed("mRPMLedTable") + SLISendReport() + return 1 + + elseif GetCarInfo("ignition") == 2 and GetCarInfo("rpm") == 0 and GetCarInfo("rawspeed") == 0 then + -- ignition ON and starter ON + -- engine has been stopped, ignition ON + Starter ON + + SetGearDigit("-") + SetDigitsAllowed(true) + -- stop blinking + initLedTable(mRPMLedTable, 1) + SetWarnLed(GetLedIndex("damage"), 1) + SetRPMLed("mRPMLedTable") + SLISendReport() + return 1 + end + end + end + return 2 +end + +-- SIM RACE Deluxe, SIM RACE F1, SLI-M, SLI-PRO Gear Event +function gearEvent(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 II + -- 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 + + -- ignition + if Ignition(gear, false) <= 1 then return 1 end + + local g = gear + if oldGear == nil then oldGear = -1 end + + -- 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") + + -- optimize display, call if changed + 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 + if ospcustom_on then n = n + 128 end + SetGearDigit(string.char(n)) + elseif g < 0 then + SetGearDigit(r) + else + -- 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 + + +-- 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_gearFanatecEvent(gear) + if result <= 1 then return result end + + -- call global custom script + result = global_custom_gearFanatecEvent(gear) + if result <= 1 then return result end + + -- ignition + if Ignition(gear, true) <= 1 then return 1 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 + + return 2 end
\ No newline at end of file diff --git a/scripts/global.lua b/scripts/global.lua index 13c3c1d..fad73df 100644 --- a/scripts/global.lua +++ b/scripts/global.lua @@ -1,519 +1,519 @@ --- SLIMax Mgr Lua Script v3.8.1
--- PART OF SLIMAX Manager pkg
--- Copyright (c)2012-2013 by Zappadoc - All Rights Reserved.
--- last change by Zappadoc - 2013-10
-
-mSMX_VERSION = 3.8
-
--- see slimax_script_readme.txt for implementation
-
--- load left and right functions tools
-require "scripts/functions_tools"
-
--- ============================================================
--- GLOBAL VAR
--- ============================================================
--- SMXMessageBox Styles
-MB_OK = 0x00000000
-MB_OKCANCEL = 0x00000001
-MB_ABORTRETRYIGNORE = 0x00000002
-MB_YESNOCANCEL = 0x00000003
-MB_YESNO = 0x00000004
-MB_RETRYCANCEL = 0x00000005
-MB_CANCELTRYCONTINUE = 0x00000006
-
-MB_ICONHAND = 0x00000010
-MB_ICONQUESTION = 0x00000020
-MB_ICONEXCLAMATION = 0x00000030
-MB_ICONASTERISK = 0x00000040
-
-MB_USERICON = 0x00000080
-MB_ICONWARNING = MB_ICONEXCLAMATION
-MB_ICONERROR = MB_ICONHAND
-
-MB_ICONINFORMATION = MB_ICONASTERISK
-MB_ICONSTOP = MB_ICONHAND
-
--- MB result
-mIDOK = 1
-mIDCANCEL = 2
-mIDABORT = 3
-mIDRETRY = 4
-mIDIGNORE = 5
-mIDYES = 6
-mIDNO = 7
-
--- scripts settings
-mCustomScriptsFileName = ""
-
--- new in: 2.2
--- init left and right digits panel text
-mLeftSpdLmtText = " "
-mRightSpdLmtText = " "
--- 4 digits F1 panel
-mF1LeftSpdLmtText = " "
-mF1RightSpdLmtText = " "
-
--- new: 2.1
--- RPM threshold values in percentage used with Shiftlights method 2
--- and configured with SLIMax Manager II Advanced Options Panel
--- default values:
-RPM_PERCENT_VALUES = {50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 97, 98, 98, 99, 99 }
-RPM_ABSOLUTE_VALUES = {15452, 15545, 15823, 16354, 16410, 16675, 17252, 17545, 17823, 18354, 18510, 18655, 18670, 18675, 18677 }
-
--- Fanatec text using for slowdown update
-mFanatecText = ""
--- SIMRACE DLX text using for slowdown update
-mSRDlxLeftText = ""
-mSRDlxRightText = ""
--- SIMRACE DLX text using for slowdown update
-mSRF1LeftText = ""
-mSRF1RightText = ""
-
--- get feedback on display when you turn encoder or press button assigned to internal functions, see control.lua
--- true if you want to display switch pos and value
-mSwitchFeedbackAllowed = true
-
--- mapping to keystroke demo script
--- see the support forum for more info on key mapping
-mDemoMapToKeyAllowed = false
-mDemoMapToKeySwitch = 5
-
--- Fanatec Digits Status
-mFanatecDigitsFeedbackAllowed = true
--- Fanatec speedlimiter method seleted
-mFanatecSpeedLimiterFeedbackAllowed = true
--- Fanatec osp method seleted
-mFanatecOSPFeedbackAllowed = true
--- Fanatec shiftlights method seleted
-mFanatecShiftlightsFeedbackAllowed = true
-
--- Low Fuel status
-mLowFuelFeedbackAllowed = true
-
--- Left and Right Digits status
-mLeftDigitsFeedbackAllowed = true
-mRightDigitsFeedbackAllowed = true
-
--- display KPH or KMH
-mUnitFeedbackAllowed = true
-
--- show the current OSP Factor
-mOSPFeedbackAllowed = true
-
--- cool global brightness feedback
-mBrightnessFeedbackAllowed = true
-
--- show the current value of maxgear option
-mMaxGearFeedbackAllowed = true
-
--- activate or deactivate lap dump telemetry
--- using button 9 by default
-mDumpLapAllowed = false
-mDumpLapButton = 9
-
--- delta time delay
-mDeltaTimeBackup = 0
-mDeltaTimeOldTicks = 0
-mDeltaTimeDelay = 100
-mRefreshLapTimeRate = 50
-
--- dump telemetry
-TelemetryTools("dumplastlap", false);
--- ============================================================
-
--- init globals flag
-isGlobalInitialized = 0
-
--- 15 RPM leds
-mRPMLedTable = {
- RPM0=0,
- RPM1=0,
- RPM2=0,
- RPM3=0,
- RPM4=0,
- RPM5=0,
- RPM6=0,
- RPM7=0,
- RPM8=0,
- RPM9=0,
- RPM10=0,
- RPM11=0,
- RPM12=0,
- RPM13=0,
- RPM14=0
-}
-
-
--- SLI device type
--- mDeviceType no longer avaialable use GetDeviceType(devID) see 2.3 API
-
-
--- --------------------------------------------
--- KERS functions
--- --------------------------------------------
-
-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
-
-
--- Init all globals
-function InitGlobals()
- -- default blink time delay
- mBlinkTime = 32
- mOSPBlinkTime = 8
-
- -- ticks stuff
- mOSPBlink = 0
- mSpdLmtBlink = 0
- mOldTickCount = 0
- mOldOSPTickCount = 0
-
- gRedZone = 0
- gOSPLimit = 0
- mBU0710Leds = 0
- mG27Leds = 0
- mOSPMethod = 0
- mFanatecLeds = 0
-end
-
--- set RPM threshold value in percentage ( SLIMax Manager 2.1 )
-function SetRPMPercentValue(index, value)
- if index <1 or index>15 then
- return
- end
- if value <0 or value >100 then
- return
- end
-
- RPM_PERCENT_VALUES[index] = value
-end
-
--- set RPM threshold value ( SLIMax Manager 2.1 )
-function SetRPMAbsoluteValue(index, value)
- if index <1 or index>15 then
- return
- end
- if value <0 or value >20000 then
- return
- end
-
- RPM_ABSOLUTE_VALUES[index] = value
-end
-
--- get all global preferences set in general_default.sli
-function GetSLIMaxInfo()
- -- get RPM Only flag
- mSpdLmtRPMLedOnly = GetContextInfo("spdlmtrpmledonlyflag")
- if mSpdLmtRPMLedOnly == nil then mSpdLmtRPMLedOnly = false end
-
- -- get blink delay value*
- mBlinkTime = GetContextInfo("blinktime")
- if mBlinkTime == nil then mBlinkTime = 32 end
- if mBlinkTime < 1 or mBlinkTime > 48 then mBlinkTime = 32 end
-
- -- get osp blink delay value
- mOSPBlinkTime = GetContextInfo("ospblinktime")
- if mOSPBlinkTime == nil then mOSPBlinkTime = 32 end
- if mOSPBlinkTime < 1 or mOSPBlinkTime > 48 then mOSPBlinkTime = 32 end
-
- -- get current speed Limiter LED index
- mSpeedLimiterLED = GetContextInfo("ledspeedlimiterindex")
- if mSpeedLimiterLED == nil then mSpeedLimiterLED = 5 end
- if mSpeedLimiterLED < 1 or mSpeedLimiterLED > 6 then mSpeedLimiterLED = 5 end
-
- -- get current osp LEDs index
- mOSPLED1 = GetContextInfo("ospled1")
- if mOSPLED1 == nil then mOSPLED1 = 1 end
- if mOSPLED1 < 1 or mOSPLED1 > 11 then mOSPLED1 = 1 end
-
- mOSPLED2 = GetContextInfo("ospled2")
- if mOSPLED2 == nil then mOSPLED2 = 1 end
- if mOSPLED2 < 1 or mOSPLED2 > 11 then mOSPLED2 = 1 end
-
- -- blinking allowed?
- mNoBlink = GetContextInfo("noblinkflag")
- if mNoBlink == nil then mNoBlink = false end
-
- -- get limiter char flag
- mLimiterChar = GetContextInfo("limitercharflag")
- if mLimiterChar == nil then mLimiterChar = false end
-
- -- is OSP with first gear allowed?
- mOSPWithFirstGear = GetContextInfo("ospwithfirstgear")
- if mOSPWithFirstGear == nil then mOSPWithFirstGear = false end
-
-end
-
--- get cpu ticks
- function GetTicks()
- local tcks = GetContextInfo("ticks")
- if tcks == nil then tcks = 0 end
- return tcks
-end
-
--- reset table function
-function initLedTable(ibl, value)
- if ibl ~= nil then
- for k, v in pairs(ibl) do
- ibl[k] = value
- end
- end
-end
-
--- toggle all led state
-function toggleAllLed(val)
- initLedTable(mRPMLedTable, val)
- for i = 1, 6 do SetWarnLed(i, val) end
- -- 7 external leds is the max value used in SIM RACE F1 and Emulator
- for i = 1, 7 do SetExtLed(i, val) end
- SetRPMLed("mRPMLedTable")
-end
-
--- The following function rounds a number
--- lua doesn't return the same rounded value as C/C++
-function round(num)
- if num == nil then num = 0 end
- local i = 0
- if num >= 0 then
- i = math.floor(num+.5)
- else
- i = math.ceil(num-.5)
- end
- return i
-end
-
--- The following function calculate hr, mn, sec, hd, ms
--- param: time in meter/sec
-function timeDispatcher( tt)
- if tms == nil then tms = 0 end
- local tms = math.abs(tt)
- local t_hr = 0
- local t_mn = 0
- local t_sc = 0
- local t_ms = 0
- local t_hd = 0
-
- if tms > 0 then
- t_hr, n = math.modf(tms/3600)
- t_mn, c = math.modf(n*60)
- t_sc, s = math.modf(c*60)
- t_hd, h = math.modf(s*100)
- t_ms, m = math.modf(s*1000)
- end
--- print( tt, t_hr, t_mn, t_sc, t_hd, t_ms)
- return t_hr, t_mn, t_sc, t_hd, t_ms
-end
-
--- return speed in KPH or MPH
-function speed(spd, selector)
- if spd == nil then spd = 0 end
- if selector then
- -- MPH
- return ( spd * 2.237)
- else
- return (spd * 3.6)
- end
-end
-
--- Fahrenheit to Celsius
-function FtoC(f)
- return ((f - 32) * (5/9))
-end
-
--- Celsius to Fahrenheit
-function CtoF(c)
- return (c * (9/5) + 32)
-end
-
--- Kelvin to Celsius
-function KtoC(k)
- return ( k - 273.313)
-end
-
--- liters to gallons
-function LtoG(liters)
- return (liters * 0.264172052 )
-end
-
--- gallons to liters
-function GtoL(gallons)
- return (gallons * 3.78541178 )
-end
-
--- return fuel in liters or gallons
-function GetFuel(fl, selector)
- if fl == nil then fl = 0 end
- if selector then
- -- gallons
- return LtoG( fl)
- else
- return fl
- end
-end
-
--- return celcius or fahrenheit
-function GetTemp(tmp, selector)
- if tmp == nil then tmp = 0 end
- if selector then
- -- gallons
- return CtoF( tmp)
- else
- return tmp
- end
-end
-
--- set refresh lap time rate in ms
-function SetRefreshLapTimeRate(delay)
- if delay == nil or delay < 0 or delay > 5000 then delay = 50 end
- mRefreshLapTimeRate = delay
-end
-
--- set delta time delay in ms
-function SetDeltaTimeDelay(delay)
- if delay == nil or delay < 0 or delay > 5000 then delay = 200 end
- mDeltatimeDelay = delay
-end
-
--- 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
-
- return result
-end
-
-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
-
-function DisplayFormatTime(lptime, delay, dec, deltaflag, numDigits)
- local ticks = GetTicks()
-
- if dft_old_time == nil or (ticks - dft_old_time) > delay then
- -- global to backup ticks (ms)
- dft_old_time = ticks
-
- local hr = 0
- local mn = 0
- local sc = 0
- local ms = 0
- local hd = 0
- local panel = ""
- local prefix = " "
-
- if lptime < 0 then
- prefix = "-"
- end
- -- explod time
- hr, mn, sc, hd, ms = timeDispatcher(lptime)
-
- if deltaflag == 1 then
- --display delta time
- if lptime == -1 or (mn + sc + ms) == 0.0 then
- if numDigits == 3 then
- Panel = "-.--"
- else
- Panel = " -.-- "
- end
- elseif mn > 0 then
- if numDigits == 3 then
- if mn < 100 then
- Panel = string.format( "%s%02d.", prefix, mn)
- else
- Panel = " ."
- end
-
- else
- Panel = string.format( " %s%1d.%02d ", prefix, mn, sc)
- end
- else
-
- if numDigits == 3 then
- if sc < 10 then
- if prefix == "-" then
- Panel = string.format( "%s%1d.%01d ", prefix, sc, hd)
- else
- Panel = string.format( "%1d.%02d ", sc, hd)
- end
- else
- Panel = " . "
- end
- else
- if Ndig == 2 then
- Panel = string.format( " %s%1d.%02d ", prefix, sc, hd)
- else
- Panel = string.format( " %s%1d.%03d", prefix, sc, ms)
- end
- end
-
- end
-
- elseif deltaflag == 0 then
- --display laptime
- if lptime == -1 or (mn + sc + ms) == 0.0 then
- if numDigits == 3 then
- Panel = "-.--"
- else
- Panel = "-:--.---"
- end
-
- elseif mn < 10 then
- if numDigits == 3 then
- Panel = string.format( "%1d.%02d", mn, sc)
- else
- Panel = string.format( "%1d:%02d.%03d", mn, sc, ms)
- end
- elseif hr > 0 then
- if numDigits == 3 then
- Panel = " . "
- else
- Panel = string.format( " %02d.%02d ", hr, mn)
- end
- else
- if numDigits == 3 then
- Panel = string.format( " %02d.", mn)
- else
- Panel = string.format( " %02d.%02d.%01d", mn, sc, ms)
- end
- end
- end
- end
-
- return Panel
-end
---==============================================
-require "scripts/slidevice"
+-- SLIMax Mgr Lua Script v3.8.1 +-- PART OF SLIMAX Manager pkg +-- Copyright (c)2012-2013 by Zappadoc - All Rights Reserved. +-- last change by Zappadoc - 2013-10 + +mSMX_VERSION = 3.8 + +-- see slimax_script_readme.txt for implementation + +-- load left and right functions tools +require "scripts/functions_tools" + +-- ============================================================ +-- GLOBAL VAR +-- ============================================================ +-- SMXMessageBox Styles +MB_OK = 0x00000000 +MB_OKCANCEL = 0x00000001 +MB_ABORTRETRYIGNORE = 0x00000002 +MB_YESNOCANCEL = 0x00000003 +MB_YESNO = 0x00000004 +MB_RETRYCANCEL = 0x00000005 +MB_CANCELTRYCONTINUE = 0x00000006 + +MB_ICONHAND = 0x00000010 +MB_ICONQUESTION = 0x00000020 +MB_ICONEXCLAMATION = 0x00000030 +MB_ICONASTERISK = 0x00000040 + +MB_USERICON = 0x00000080 +MB_ICONWARNING = MB_ICONEXCLAMATION +MB_ICONERROR = MB_ICONHAND + +MB_ICONINFORMATION = MB_ICONASTERISK +MB_ICONSTOP = MB_ICONHAND + +-- MB result +mIDOK = 1 +mIDCANCEL = 2 +mIDABORT = 3 +mIDRETRY = 4 +mIDIGNORE = 5 +mIDYES = 6 +mIDNO = 7 + +-- scripts settings +mCustomScriptsFileName = "" + +-- new in: 2.2 +-- init left and right digits panel text +mLeftSpdLmtText = " " +mRightSpdLmtText = " " +-- 4 digits F1 panel +mF1LeftSpdLmtText = " " +mF1RightSpdLmtText = " " + +-- new: 2.1 +-- RPM threshold values in percentage used with Shiftlights method 2 +-- and configured with SLIMax Manager II Advanced Options Panel +-- default values: +RPM_PERCENT_VALUES = {50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 97, 98, 98, 99, 99 } +RPM_ABSOLUTE_VALUES = {15452, 15545, 15823, 16354, 16410, 16675, 17252, 17545, 17823, 18354, 18510, 18655, 18670, 18675, 18677 } + +-- Fanatec text using for slowdown update +mFanatecText = "" +-- SIMRACE DLX text using for slowdown update +mSRDlxLeftText = "" +mSRDlxRightText = "" +-- SIMRACE DLX text using for slowdown update +mSRF1LeftText = "" +mSRF1RightText = "" + +-- get feedback on display when you turn encoder or press button assigned to internal functions, see control.lua +-- true if you want to display switch pos and value +mSwitchFeedbackAllowed = true + +-- mapping to keystroke demo script +-- see the support forum for more info on key mapping +mDemoMapToKeyAllowed = false +mDemoMapToKeySwitch = 5 + +-- Fanatec Digits Status +mFanatecDigitsFeedbackAllowed = true +-- Fanatec speedlimiter method seleted +mFanatecSpeedLimiterFeedbackAllowed = true +-- Fanatec osp method seleted +mFanatecOSPFeedbackAllowed = true +-- Fanatec shiftlights method seleted +mFanatecShiftlightsFeedbackAllowed = true + +-- Low Fuel status +mLowFuelFeedbackAllowed = true + +-- Left and Right Digits status +mLeftDigitsFeedbackAllowed = true +mRightDigitsFeedbackAllowed = true + +-- display KPH or KMH +mUnitFeedbackAllowed = true + +-- show the current OSP Factor +mOSPFeedbackAllowed = true + +-- cool global brightness feedback +mBrightnessFeedbackAllowed = true + +-- show the current value of maxgear option +mMaxGearFeedbackAllowed = true + +-- activate or deactivate lap dump telemetry +-- using button 9 by default +mDumpLapAllowed = false +mDumpLapButton = 9 + +-- delta time delay +mDeltaTimeBackup = 0 +mDeltaTimeOldTicks = 0 +mDeltaTimeDelay = 100 +mRefreshLapTimeRate = 50 + +-- dump telemetry +TelemetryTools("dumplastlap", false); +-- ============================================================ + +-- init globals flag +isGlobalInitialized = 0 + +-- 15 RPM leds +mRPMLedTable = { + RPM0=0, + RPM1=0, + RPM2=0, + RPM3=0, + RPM4=0, + RPM5=0, + RPM6=0, + RPM7=0, + RPM8=0, + RPM9=0, + RPM10=0, + RPM11=0, + RPM12=0, + RPM13=0, + RPM14=0 +} + + +-- SLI device type +-- mDeviceType no longer avaialable use GetDeviceType(devID) see 2.3 API + + +-- -------------------------------------------- +-- KERS functions +-- -------------------------------------------- + +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 + + +-- Init all globals +function InitGlobals() + -- default blink time delay + mBlinkTime = 32 + mOSPBlinkTime = 8 + + -- ticks stuff + mOSPBlink = 0 + mSpdLmtBlink = 0 + mOldTickCount = 0 + mOldOSPTickCount = 0 + + gRedZone = 0 + gOSPLimit = 0 + mBU0710Leds = 0 + mG27Leds = 0 + mOSPMethod = 0 + mFanatecLeds = 0 +end + +-- set RPM threshold value in percentage ( SLIMax Manager 2.1 ) +function SetRPMPercentValue(index, value) + if index <1 or index>15 then + return + end + if value <0 or value >100 then + return + end + + RPM_PERCENT_VALUES[index] = value +end + +-- set RPM threshold value ( SLIMax Manager 2.1 ) +function SetRPMAbsoluteValue(index, value) + if index <1 or index>15 then + return + end + if value <0 or value >20000 then + return + end + + RPM_ABSOLUTE_VALUES[index] = value +end + +-- get all global preferences set in general_default.sli +function GetSLIMaxInfo() + -- get RPM Only flag + mSpdLmtRPMLedOnly = GetContextInfo("spdlmtrpmledonlyflag") + if mSpdLmtRPMLedOnly == nil then mSpdLmtRPMLedOnly = false end + + -- get blink delay value* + mBlinkTime = GetContextInfo("blinktime") + if mBlinkTime == nil then mBlinkTime = 32 end + if mBlinkTime < 1 or mBlinkTime > 48 then mBlinkTime = 32 end + + -- get osp blink delay value + mOSPBlinkTime = GetContextInfo("ospblinktime") + if mOSPBlinkTime == nil then mOSPBlinkTime = 32 end + if mOSPBlinkTime < 1 or mOSPBlinkTime > 48 then mOSPBlinkTime = 32 end + + -- get current speed Limiter LED index + mSpeedLimiterLED = GetContextInfo("ledspeedlimiterindex") + if mSpeedLimiterLED == nil then mSpeedLimiterLED = 5 end + if mSpeedLimiterLED < 1 or mSpeedLimiterLED > 6 then mSpeedLimiterLED = 5 end + + -- get current osp LEDs index + mOSPLED1 = GetContextInfo("ospled1") + if mOSPLED1 == nil then mOSPLED1 = 1 end + if mOSPLED1 < 1 or mOSPLED1 > 11 then mOSPLED1 = 1 end + + mOSPLED2 = GetContextInfo("ospled2") + if mOSPLED2 == nil then mOSPLED2 = 1 end + if mOSPLED2 < 1 or mOSPLED2 > 11 then mOSPLED2 = 1 end + + -- blinking allowed? + mNoBlink = GetContextInfo("noblinkflag") + if mNoBlink == nil then mNoBlink = false end + + -- get limiter char flag + mLimiterChar = GetContextInfo("limitercharflag") + if mLimiterChar == nil then mLimiterChar = false end + + -- is OSP with first gear allowed? + mOSPWithFirstGear = GetContextInfo("ospwithfirstgear") + if mOSPWithFirstGear == nil then mOSPWithFirstGear = false end + +end + +-- get cpu ticks + function GetTicks() + local tcks = GetContextInfo("ticks") + if tcks == nil then tcks = 0 end + return tcks +end + +-- reset table function +function initLedTable(ibl, value) + if ibl ~= nil then + for k, v in pairs(ibl) do + ibl[k] = value + end + end +end + +-- toggle all led state +function toggleAllLed(val) + initLedTable(mRPMLedTable, val) + for i = 1, 6 do SetWarnLed(i, val) end + -- 7 external leds is the max value used in SIM RACE F1 and Emulator + for i = 1, 7 do SetExtLed(i, val) end + SetRPMLed("mRPMLedTable") +end + +-- The following function rounds a number +-- lua doesn't return the same rounded value as C/C++ +function round(num) + if num == nil then num = 0 end + local i = 0 + if num >= 0 then + i = math.floor(num+.5) + else + i = math.ceil(num-.5) + end + return i +end + +-- The following function calculate hr, mn, sec, hd, ms +-- param: time in meter/sec +function timeDispatcher( tt) + if tms == nil then tms = 0 end + local tms = math.abs(tt) + local t_hr = 0 + local t_mn = 0 + local t_sc = 0 + local t_ms = 0 + local t_hd = 0 + + if tms > 0 then + t_hr, n = math.modf(tms/3600) + t_mn, c = math.modf(n*60) + t_sc, s = math.modf(c*60) + t_hd, h = math.modf(s*100) + t_ms, m = math.modf(s*1000) + end +-- print( tt, t_hr, t_mn, t_sc, t_hd, t_ms) + return t_hr, t_mn, t_sc, t_hd, t_ms +end + +-- return speed in KPH or MPH +function speed(spd, selector) + if spd == nil then spd = 0 end + if selector then + -- MPH + return ( spd * 2.237) + else + return (spd * 3.6) + end +end + +-- Fahrenheit to Celsius +function FtoC(f) + return ((f - 32) * (5/9)) +end + +-- Celsius to Fahrenheit +function CtoF(c) + return (c * (9/5) + 32) +end + +-- Kelvin to Celsius +function KtoC(k) + return ( k - 273.313) +end + +-- liters to gallons +function LtoG(liters) + return (liters * 0.264172052 ) +end + +-- gallons to liters +function GtoL(gallons) + return (gallons * 3.78541178 ) +end + +-- return fuel in liters or gallons +function GetFuel(fl, selector) + if fl == nil then fl = 0 end + if selector then + -- gallons + return LtoG( fl) + else + return fl + end +end + +-- return celcius or fahrenheit +function GetTemp(tmp, selector) + if tmp == nil then tmp = 0 end + if selector then + -- gallons + return CtoF( tmp) + else + return tmp + end +end + +-- set refresh lap time rate in ms +function SetRefreshLapTimeRate(delay) + if delay == nil or delay < 0 or delay > 5000 then delay = 50 end + mRefreshLapTimeRate = delay +end + +-- set delta time delay in ms +function SetDeltaTimeDelay(delay) + if delay == nil or delay < 0 or delay > 5000 then delay = 200 end + mDeltatimeDelay = delay +end + +-- 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 + + return result +end + +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 + +function DisplayFormatTime(lptime, delay, dec, deltaflag, numDigits) + local ticks = GetTicks() + + if dft_old_time == nil or (ticks - dft_old_time) > delay then + -- global to backup ticks (ms) + dft_old_time = ticks + + local hr = 0 + local mn = 0 + local sc = 0 + local ms = 0 + local hd = 0 + local panel = "" + local prefix = " " + + if lptime < 0 then + prefix = "-" + end + -- explod time + hr, mn, sc, hd, ms = timeDispatcher(lptime) + + if deltaflag == 1 then + --display delta time + if lptime == -1 or (mn + sc + ms) == 0.0 then + if numDigits == 3 then + Panel = "-.--" + else + Panel = " -.-- " + end + elseif mn > 0 then + if numDigits == 3 then + if mn < 100 then + Panel = string.format( "%s%02d.", prefix, mn) + else + Panel = " ." + end + + else + Panel = string.format( " %s%1d.%02d ", prefix, mn, sc) + end + else + + if numDigits == 3 then + if sc < 10 then + if prefix == "-" then + Panel = string.format( "%s%1d.%01d ", prefix, sc, hd) + else + Panel = string.format( "%1d.%02d ", sc, hd) + end + else + Panel = " . " + end + else + if Ndig == 2 then + Panel = string.format( " %s%1d.%02d ", prefix, sc, hd) + else + Panel = string.format( " %s%1d.%03d", prefix, sc, ms) + end + end + + end + + elseif deltaflag == 0 then + --display laptime + if lptime == -1 or (mn + sc + ms) == 0.0 then + if numDigits == 3 then + Panel = "-.--" + else + Panel = "-:--.---" + end + + elseif mn < 10 then + if numDigits == 3 then + Panel = string.format( "%1d.%02d", mn, sc) + else + Panel = string.format( "%1d:%02d.%03d", mn, sc, ms) + end + elseif hr > 0 then + if numDigits == 3 then + Panel = " . " + else + Panel = string.format( " %02d.%02d ", hr, mn) + end + else + if numDigits == 3 then + Panel = string.format( " %02d.", mn) + else + Panel = string.format( " %02d.%02d.%01d", mn, sc, ms) + end + end + end + end + + return Panel +end +--============================================== +require "scripts/slidevice" diff --git a/scripts/global_custom_scripts.lua b/scripts/global_custom_scripts.lua index bbf5e8b..e212250 100644 --- a/scripts/global_custom_scripts.lua +++ b/scripts/global_custom_scripts.lua @@ -1,210 +1,210 @@ --- Global Custom SLIMax Manager Scripts v3.6
--- Copyright ©2012-2013 by Zappadoc - All Rights Reserved.
--- last change by Zappadoc - 2013-09
-
--- add you global custom functions and globals variables here
--- patch the std SLIMax Events with your global custom scripts if needed
--- see the scripting section of the forum for more info...
-
--- IMPORTANT:
--- this script will not be deleted by uninstalling the software
-
--- ================================
--- CONSTANTS
-
-
--- ================================
--- additional lua extension module dll
-
-
--- ================================
--- additional scripts file ( use 'require' statement )
-
--- ================================
--- custom globals
-
--- ================================
--- custom functions
-function _DebugCarInfo(deviceType)
- -- see debug console window
- -- get car name
- local dev = GetDeviceType(deviceType)
- local cNm = "NA" --GetContextInfo("carname")
- local mxG = GetCarInfo("maxgear")
- local rdz = GetCarInfo("redzone")
- local ospf = GetContextInfo("ospfactor")
- print("\n----------\nDevice:"..dev.."\nMax RPM (Red Zone):" .. rdz .. "\nMaxGear:" .. mxG .. "\nOSP Factor:" .. ospf .. "\n");
-end
--- ================================
--- custom events
-
-function global_custom_controlsEvent(deviceType, ctrlType, ctrlPos, value, funcIndex, targetDevice)
- -- type your custom controls script here (manage buttons, switches and encoders)
- return 2
-end
-
-function global_custom_deviceReport(deviceType)
- -- type your script here (just before sending report to the device )
- return 2
-end
-
-function global_custom_enterSessionEvent(deviceType)
- -- type your custom script on session start, here
- _DebugCarInfo(deviceType)
- return 2
-end
-
-function global_custom_exitSessionEvent(deviceType)
- -- 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
- return 2
-end
-
-function global_custom_shiftLightsBU0710Event(idx)
- -- type your custom shiftlights method for BU0710 device only here
- return 2
-end
-
-function global_custom_leftDigitsEvent(swPosition)
- -- type your custom script related to left SLI-PRO digits panel here
- return 2
-end
-
-function global_custom_rightDigitsEvent(swPosition)
- -- type your custom script related to right SLI-PRO digits panel here
- return 2
-end
-
-function global_custom_spdLmtMethodEvent(idx)
- -- type your custom speedlimiter method here
- return 2
-end
-
--- ================================
--- SIM RACE Deluxe, SLI-PRO, SLI-M, BU0710 SUPPORT
-
-function global_custom_gearEvent(gear)
- -- type your custom gear event script here
- return 2
-end
-
-function global_custom_ledEvent(idx, ledFunction, state)
- -- type your custom script on session ending, here
- return 2
-end
-
--- ================================
--- LOGITECH G27 SUPPORT
-
-function global_custom_shiftLightsG27LedsMethodEvent(idx)
- -- type your custom shiftlights method for G27 device only here
- return 2
-end
-
-function global_custom_ospG27MethodEvent(idx)
- -- type your custom Optimal Shift Points (OSP) method here
- return 2
-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_fanatecDigitsEvent(swPosition)
- -- type your custom script related to Fanatec digits panel here
- return 2
-end
-
-function global_custom_ospFanatecMethodEvent(idx)
- -- type your custom Optimal Shift Points (OSP) method here
- return 2
-end
-
-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
-
-
--- ================================
--- SIM RACE DELUXE SUPPORT
-
-function global_custom_shiftLightsSRDlxMethodEvent(idx)
- -- type your custom script related to right SLI-PRO digits panel here
- return 2
-end
-
-function global_custom_srdlxLeftDigitsEvent(swPosition)
- -- type your custom script related to left SLI-PRO digits panel here
- return 2
-end
-
-function global_custom_srdlxRightDigitsEvent(swPosition)
- -- type your custom script related to right SLI-PRO digits panel here
- return 2
-end
-
-function global_custom_ospSRDlxMethodEvent(idx)
- -- type your custom Optimal Shift Points (OSP) method here
- return 2
-end
-
-function global_custom_spdLmtSRDlxMethodEvent(idx)
- -- type your custom Optimal Shift Points (OSP) method here
- return 2
-end
-
--- ================================
--- SIM RACE F1 SUPPORT
-
-function global_custom_shiftLightsSRF1MethodEvent(idx)
- -- type your custom script related to right SLI-PRO digits panel here
- return 2
-end
-
-function global_custom_srf1LeftDigitsEvent(swPosition)
- -- type your custom script related to left SLI-PRO digits panel here
- return 2
-end
-
-function global_custom_srf1RightDigitsEvent(swPosition)
- -- type your custom script related to right SLI-PRO digits panel here
- return 2
-end
-
-function global_custom_ospSRF1MethodEvent(idx)
- -- type your custom Optimal Shift Points (OSP) method here
- return 2
-end
-
-function global_custom_spdLmtSRF1MethodEvent(idx)
- -- type your custom Optimal Shift Points (OSP) method here
- return 2
+-- Global Custom SLIMax Manager Scripts v3.6 +-- Copyright ©2012-2013 by Zappadoc - All Rights Reserved. +-- last change by Zappadoc - 2013-09 + +-- add you global custom functions and globals variables here +-- patch the std SLIMax Events with your global custom scripts if needed +-- see the scripting section of the forum for more info... + +-- IMPORTANT: +-- this script will not be deleted by uninstalling the software + +-- ================================ +-- CONSTANTS + + +-- ================================ +-- additional lua extension module dll + + +-- ================================ +-- additional scripts file ( use 'require' statement ) + +-- ================================ +-- custom globals + +-- ================================ +-- custom functions +function _DebugCarInfo(deviceType) + -- see debug console window + -- get car name + local dev = GetDeviceType(deviceType) + local cNm = "NA" --GetContextInfo("carname") + local mxG = GetCarInfo("maxgear") + local rdz = GetCarInfo("redzone") + local ospf = GetContextInfo("ospfactor") + print("\n----------\nDevice:"..dev.."\nMax RPM (Red Zone):" .. rdz .. "\nMaxGear:" .. mxG .. "\nOSP Factor:" .. ospf .. "\n"); +end +-- ================================ +-- custom events + +function global_custom_controlsEvent(deviceType, ctrlType, ctrlPos, value, funcIndex, targetDevice) + -- type your custom controls script here (manage buttons, switches and encoders) + return 2 +end + +function global_custom_deviceReport(deviceType) + -- type your script here (just before sending report to the device ) + return 2 +end + +function global_custom_enterSessionEvent(deviceType) + -- type your custom script on session start, here + _DebugCarInfo(deviceType) + return 2 +end + +function global_custom_exitSessionEvent(deviceType) + -- 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 + return 2 +end + +function global_custom_shiftLightsBU0710Event(idx) + -- type your custom shiftlights method for BU0710 device only here + return 2 +end + +function global_custom_leftDigitsEvent(swPosition) + -- type your custom script related to left SLI-PRO digits panel here + return 2 +end + +function global_custom_rightDigitsEvent(swPosition) + -- type your custom script related to right SLI-PRO digits panel here + return 2 +end + +function global_custom_spdLmtMethodEvent(idx) + -- type your custom speedlimiter method here + return 2 +end + +-- ================================ +-- SIM RACE Deluxe, SLI-PRO, SLI-M, BU0710 SUPPORT + +function global_custom_gearEvent(gear) + -- type your custom gear event script here + return 2 +end + +function global_custom_ledEvent(idx, ledFunction, state) + -- type your custom script on session ending, here + return 2 +end + +-- ================================ +-- LOGITECH G27 SUPPORT + +function global_custom_shiftLightsG27LedsMethodEvent(idx) + -- type your custom shiftlights method for G27 device only here + return 2 +end + +function global_custom_ospG27MethodEvent(idx) + -- type your custom Optimal Shift Points (OSP) method here + return 2 +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_fanatecDigitsEvent(swPosition) + -- type your custom script related to Fanatec digits panel here + return 2 +end + +function global_custom_ospFanatecMethodEvent(idx) + -- type your custom Optimal Shift Points (OSP) method here + return 2 +end + +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 + + +-- ================================ +-- SIM RACE DELUXE SUPPORT + +function global_custom_shiftLightsSRDlxMethodEvent(idx) + -- type your custom script related to right SLI-PRO digits panel here + return 2 +end + +function global_custom_srdlxLeftDigitsEvent(swPosition) + -- type your custom script related to left SLI-PRO digits panel here + return 2 +end + +function global_custom_srdlxRightDigitsEvent(swPosition) + -- type your custom script related to right SLI-PRO digits panel here + return 2 +end + +function global_custom_ospSRDlxMethodEvent(idx) + -- type your custom Optimal Shift Points (OSP) method here + return 2 +end + +function global_custom_spdLmtSRDlxMethodEvent(idx) + -- type your custom Optimal Shift Points (OSP) method here + return 2 +end + +-- ================================ +-- SIM RACE F1 SUPPORT + +function global_custom_shiftLightsSRF1MethodEvent(idx) + -- type your custom script related to right SLI-PRO digits panel here + return 2 +end + +function global_custom_srf1LeftDigitsEvent(swPosition) + -- type your custom script related to left SLI-PRO digits panel here + return 2 +end + +function global_custom_srf1RightDigitsEvent(swPosition) + -- type your custom script related to right SLI-PRO digits panel here + return 2 +end + +function global_custom_ospSRF1MethodEvent(idx) + -- type your custom Optimal Shift Points (OSP) method here + return 2 +end + +function global_custom_spdLmtSRF1MethodEvent(idx) + -- type your custom Optimal Shift Points (OSP) method here + return 2 end
\ No newline at end of file diff --git a/scripts/led.lua b/scripts/led.lua index 3f53380..67572d1 100644 --- a/scripts/led.lua +++ b/scripts/led.lua @@ -1,45 +1,44 @@ --- Part of SLIMax Mgr II - Lua Script v2.2.1
--- Copyright (c)2012-2013 by Zappadoc - All Rights Reserved.
--- Use this script to patch std led behaviors (i.e lowfuel, flags, damage, rev limit, ...)
--- created by Zappadoc - 2012-11-10
-
--- Display led event
--- params:
--- idx = led index (assigned in settings)
--- state = the std state of the led; activated if > 0
--- ledFunction: the corresponding function
--- 1=LowFuel
--- 2=TC
--- 3=ABS
--- 4=Green Flag
--- 5=Yellow flag
--- 6=Red Flag
--- 7=Over Heating
--- 8=Damage
--- 9=Pit request
--- 10=Power
--- 11=Rev Limit
--- 12=HeadLights
--- 13=Blue Flag
--- 14=DRS
--- 15=Safe Prefs
-
-function ledEvent(idx, ledFunction, state)
- -- call custom script
- local result = custom_ledEvent(idx, ledFunction, state)
- -- 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_ledEvent(idx, ledFunction, state)
- -- 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
-
- -- return 0 to use std behaviors
- return 0
-end
-
\ No newline at end of file +-- Part of SLIMax Mgr II - Lua Script v2.2.1 +-- Copyright (c)2012-2013 by Zappadoc - All Rights Reserved. +-- Use this script to patch std led behaviors (i.e lowfuel, flags, damage, rev limit, ...) +-- created by Zappadoc - 2012-11-10 + +-- Display led event +-- params: +-- idx = led index (assigned in settings) +-- state = the std state of the led; activated if > 0 +-- ledFunction: the corresponding function +-- 1=LowFuel +-- 2=TC +-- 3=ABS +-- 4=Green Flag +-- 5=Yellow flag +-- 6=Red Flag +-- 7=Over Heating +-- 8=Damage +-- 9=Pit request +-- 10=Power +-- 11=Rev Limit +-- 12=HeadLights +-- 13=Blue Flag +-- 14=DRS +-- 15=Safe Prefs + +function ledEvent(idx, ledFunction, state) + -- call custom script + local result = custom_ledEvent(idx, ledFunction, state) + -- 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_ledEvent(idx, ledFunction, state) + -- 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 + + -- return 0 to use std behaviors + return 0 +end diff --git a/scripts/osp.lua b/scripts/osp.lua index 63e5f9f..0b6ded3 100644 --- a/scripts/osp.lua +++ b/scripts/osp.lua @@ -1,757 +1,757 @@ --- SLIMax Mgr Lua Script v3.3
--- Copyright (c)2012-2013 by Zappadoc - All Rights Reserved.
--- this script builds all Optimal ShiftPoints methods (OSP)
--- last change by Zappadoc - 2013-10
-
-function SetOSPFeedback(state)
- if mOSPLED1 > 6 then
- SetExtLed( (mOSPLED1 - 6), state)
- else
- SetWarnLed(mOSPLED1, state)
- end
- if mOSPLED2 > 6 then
- SetExtLed( (mOSPLED2 - 6), state)
- else
- SetWarnLed(mOSPLED2, state)
- end
-end
-
--- SLI-M, SLI-PRO OSP Methods Event
-function ospMethodEvent(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_ospMethodEvent(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_ospMethodEvent(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 red zone value
- --local redZone = GetCarInfo("redzone")
- --if redZone == nil then redZone = 18000 end
-
- -- get current osp factor
- --local ospFactor = GetContextInfo("ospfactor")
- --if ospFactor == nil then ospFactor = 80 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
-
- -- print("OSP1: " .. mOSPLED1 .. " OSP2: " .. mOSPLED2 .."\n")
- -- print(rpm .. " - " .. gOSPLimit)
-
- -- rpm > osplimit so activate shiftpoints leds
- if rpm > gOSPLimit then
-
- -- no blinking allowed
- if mNoBlink then
- -- set both leds
- SetOSPFeedback(1)
-
- else
-
- if GetTicks() > mOldOSPTickCount then
- mOSPBlink = mOSPBlink + 1
- end
-
- if mOSPMethod <= 3 then
- -- methods 1 to 3
- if mOSPBlink >= mOSPBlinkTime then
- mOSPBlink = 0
- end
-
- if mOSPBlink <= (mOSPBlinkTime / 2) then
- if mOSPMethod ~= 3 then
- -- if not method 3
- SetOSPFeedback(1)
- end
- if (mOSPMethod == 1) or (mOSPMethod == 3) then
- -- add blue leds blinking if method 1 or 3
- for i = 9,12 do
- led = led.format("RPM%d",i)
- mRPMLedTable[led] = 1
- end
- SetRPMLed("mRPMLedTable")
- end
- end
-
- if mOSPBlink > (mOSPBlinkTime / 2) then
- SetOSPFeedback(0)
-
- if (mOSPMethod == 1) or (mOSPMethod == 3) then
- -- add blue leds blinking if method 1 or 3
- for i = 9,12 do
- led = led.format("RPM%d",i)
- mRPMLedTable[led] = 0
- end
- SetRPMLed("mRPMLedTable")
- end
- end
- end
-
- if mOSPMethod == 2 then
- -- add blue leds not blinking if method 2
- for i = 9,12 do
- led = led.format("RPM%d",i)
- mRPMLedTable[led] = 1
- end
- SetRPMLed("mRPMLedTable")
- end
- end
- else
- -- bypass (give control to manager)
- return 1
- end
- -- timebase
- if GetTicks() > mOldOSPTickCount then
- mOldOSPTickCount = GetTicks() + 10
- end
-
- return 1
-end
-
-
--- G27 Methods Event
-function ospG27MethodEvent(idx)
- mOSPG27Method = 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(mOSPG27Method)
- -- 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(mOSPG27Method)
- -- 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: " .. mOSPG27Method .. " 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 mOSPG27Method <= 1 or mOSPG27Method > 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 mOSPG27Method == 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 mOSPG27Method == 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)
- mOSPFanatecMethod = 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(mOSPFanatecMethod)
- -- 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(mOSPFanatecMethod)
- -- 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 (mOSPFanatecMethod <= 0) or mOSPFanatecMethod > 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 mOSPFanatecMethod == 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 mOSPFanatecMethod == 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 mOSPFanatecMethod == 3 then
- initLedTable(mRPMLedTable, 0)
- -- center leds blinking if method 3, ON
- mRPMLedTable["RPM3"] = 1
- mRPMLedTable["RPM4"] = 1
- mRPMLedTable["RPM5"] = 1
-
- elseif mOSPFanatecMethod == 4 then
- initLedTable(mRPMLedTable, 0)
- -- side fixed if method 4, ON
- mRPMLedTable["RPM0"] = 1
- mRPMLedTable["RPM1"] = 1
- mRPMLedTable["RPM7"] = 1
- mRPMLedTable["RPM8"] = 1
- end
- SetRPMLed("mRPMLedTable")
- end
-
- if mOSPBlink > (mOSPBlinkTime / 2) then
- if (mOSPFanatecMethod <= 0) or mOSPFanatecMethod > 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 mOSPFanatecMethod == 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 mOSPFanatecMethod == 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 mOSPFanatecMethod == 3 then
- initLedTable(mRPMLedTable, 0)
- -- center leds blinking if method 3, OFF
- mRPMLedTable["RPM3"] = 0
- mRPMLedTable["RPM4"] = 0
- mRPMLedTable["RPM5"] = 0
-
- elseif mOSPFanatecMethod == 4 then
- initLedTable(mRPMLedTable, 0)
- -- side fixed if method 4, ON
- mRPMLedTable["RPM0"] = 1
- mRPMLedTable["RPM1"] = 1
- mRPMLedTable["RPM7"] = 1
- mRPMLedTable["RPM8"] = 1
- end
- SetRPMLed("mRPMLedTable")
- end
- end
-
- else
- -- bypass (give control to manager)
- return 1
- end
- -- timebase
- if GetTicks() > mOldOSPTickCount then
- mOldOSPTickCount = GetTicks() + 10
- end
-
- return 1
-end
-
--- ==================================================
--- SIM RACE Deluxe OSP Methods Event
-
-function ospSRDlxMethodEvent(idx)
- mOSPSRDlxMethod = 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_ospSRDlxMethodEvent(mOSPSRDlxMethod)
- -- 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_ospSRDlxMethodEvent(mOSPSRDlxMethod)
- -- 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 red zone value
- --local redZone = GetCarInfo("redzone")
- --if redZone == nil then redZone = 18000 end
-
- -- get current osp factor
- --local ospFactor = GetContextInfo("ospfactor")
- --if ospFactor == nil then ospFactor = 80 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
-
- -- print("OSP1: " .. mOSPLED1 .. " OSP2: " .. mOSPLED2 .."\n")
- -- print(rpm .. " - " .. gOSPLimit)
-
- -- rpm > osplimit so activate shiftpoints leds
- if rpm > gOSPLimit then
-
- -- no blinking allowed
- if mNoBlink then
- -- set both leds
- SetOSPFeedback(1)
-
- else
-
- if GetTicks() > mOldOSPTickCount then
- mOSPBlink = mOSPBlink + 1
- end
-
- if mOSPSRDlxMethod <= 3 then
- -- methods 1 to 3
- if mOSPBlink >= mOSPBlinkTime then
- mOSPBlink = 0
- end
-
- if mOSPBlink <= (mOSPBlinkTime / 2) then
- if mOSPSRDlxMethod ~= 3 then
- -- if not method 3
- SetOSPFeedback(1)
- end
- if (mOSPSRDlxMethod == 1) or (mOSPSRDlxMethod == 3) then
- -- add blue leds blinking if method 1 or 3
- for i = 7,9 do
- led = led.format("RPM%d",i)
- mRPMLedTable[led] = 1
- end
- SetRPMLed("mRPMLedTable")
- end
- end
-
- if mOSPBlink > (mOSPBlinkTime / 2) then
- SetOSPFeedback(0)
-
- if (mOSPSRDlxMethod == 1) or (mOSPSRDlxMethod == 3) then
- -- add blue leds blinking if method 1 or 3
- for i = 7,9 do
- led = led.format("RPM%d",i)
- mRPMLedTable[led] = 0
- end
- SetRPMLed("mRPMLedTable")
- end
- end
- end
-
- if mOSPSRDlxMethod == 2 then
- -- add blue leds not blinking if method 2
- for i = 7,9 do
- led = led.format("RPM%d",i)
- mRPMLedTable[led] = 1
- end
- SetRPMLed("mRPMLedTable")
- end
- end
- else
- -- bypass (give control to manager)
- return 1
- end
- -- timebase
- if GetTicks() > mOldOSPTickCount then
- mOldOSPTickCount = GetTicks() + 10
- end
-
- return 1
-end
-
-
--- ==================================================
--- SIM RACE F1 OSP Methods Event
-
-function ospSRF1MethodEvent(idx)
- mOSPSRF1Method = 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_ospSRF1MethodEvent(mOSPSRF1Method)
- -- 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_ospSRF1MethodEvent(mOSPSRF1Method)
- -- 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 red zone value
- --local redZone = GetCarInfo("redzone")
- --if redZone == nil then redZone = 18000 end
-
- -- get current osp factor
- --local ospFactor = GetContextInfo("ospfactor")
- --if ospFactor == nil then ospFactor = 80 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
-
- -- print("OSP1: " .. mOSPLED1 .. " OSP2: " .. mOSPLED2 .."\n")
- -- print(rpm .. " - " .. gOSPLimit)
-
- -- rpm > osplimit so activate shiftpoints leds
- if rpm > gOSPLimit then
-
- -- no blinking allowed
- if mNoBlink then
- -- set both leds
- SetOSPFeedback(1)
-
- else
-
- if GetTicks() > mOldOSPTickCount then
- mOSPBlink = mOSPBlink + 1
- end
-
- if mOSPSRF1Method <= 3 then
- -- methods 1 to 3
- if mOSPBlink >= mOSPBlinkTime then
- mOSPBlink = 0
- end
-
- if mOSPBlink <= (mOSPBlinkTime / 2) then
- if mOSPSRF1Method ~= 3 then
- -- if not method 3
- SetOSPFeedback(1)
- end
- if (mOSPSRF1Method == 1) or (mOSPSRF1Method == 3) then
- -- add blue leds blinking if method 1 or 3
- for i = 10,14 do
- led = led.format("RPM%d",i)
- mRPMLedTable[led] = 1
- end
- SetRPMLed("mRPMLedTable")
- end
- end
-
- if mOSPBlink > (mOSPBlinkTime / 2) then
- SetOSPFeedback(0)
-
- if (mOSPSRF1Method == 1) or (mOSPSRF1Method == 3) then
- -- add blue leds blinking if method 1 or 3
- for i = 10,14 do
- led = led.format("RPM%d",i)
- mRPMLedTable[led] = 0
- end
- SetRPMLed("mRPMLedTable")
- end
- end
- end
-
- if mOSPSRF1Method == 2 then
- -- add blue leds not blinking if method 2
- for i = 10,14 do
- led = led.format("RPM%d",i)
- mRPMLedTable[led] = 1
- end
- SetRPMLed("mRPMLedTable")
- end
- end
- else
- -- bypass (give control to manager)
- return 1
- end
- -- timebase
- if GetTicks() > mOldOSPTickCount then
- mOldOSPTickCount = GetTicks() + 10
- end
-
- return 1
+-- SLIMax Mgr Lua Script v3.3 +-- Copyright (c)2012-2013 by Zappadoc - All Rights Reserved. +-- this script builds all Optimal ShiftPoints methods (OSP) +-- last change by Zappadoc - 2013-10 + +function SetOSPFeedback(state) + if mOSPLED1 > 6 then + SetExtLed( (mOSPLED1 - 6), state) + else + SetWarnLed(mOSPLED1, state) + end + if mOSPLED2 > 6 then + SetExtLed( (mOSPLED2 - 6), state) + else + SetWarnLed(mOSPLED2, state) + end +end + +-- SLI-M, SLI-PRO OSP Methods Event +function ospMethodEvent(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_ospMethodEvent(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_ospMethodEvent(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 red zone value + --local redZone = GetCarInfo("redzone") + --if redZone == nil then redZone = 18000 end + + -- get current osp factor + --local ospFactor = GetContextInfo("ospfactor") + --if ospFactor == nil then ospFactor = 80 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 + + -- print("OSP1: " .. mOSPLED1 .. " OSP2: " .. mOSPLED2 .."\n") + -- print(rpm .. " - " .. gOSPLimit) + + -- rpm > osplimit so activate shiftpoints leds + if rpm > gOSPLimit then + + -- no blinking allowed + if mNoBlink then + -- set both leds + SetOSPFeedback(1) + + else + + if GetTicks() > mOldOSPTickCount then + mOSPBlink = mOSPBlink + 1 + end + + if mOSPMethod <= 3 then + -- methods 1 to 3 + if mOSPBlink >= mOSPBlinkTime then + mOSPBlink = 0 + end + + if mOSPBlink <= (mOSPBlinkTime / 2) then + if mOSPMethod ~= 3 then + -- if not method 3 + SetOSPFeedback(1) + end + if (mOSPMethod == 1) or (mOSPMethod == 3) then + -- add blue leds blinking if method 1 or 3 + for i = 9,12 do + led = led.format("RPM%d",i) + mRPMLedTable[led] = 1 + end + SetRPMLed("mRPMLedTable") + end + end + + if mOSPBlink > (mOSPBlinkTime / 2) then + SetOSPFeedback(0) + + if (mOSPMethod == 1) or (mOSPMethod == 3) then + -- add blue leds blinking if method 1 or 3 + for i = 9,12 do + led = led.format("RPM%d",i) + mRPMLedTable[led] = 0 + end + SetRPMLed("mRPMLedTable") + end + end + end + + if mOSPMethod == 2 then + -- add blue leds not blinking if method 2 + for i = 9,12 do + led = led.format("RPM%d",i) + mRPMLedTable[led] = 1 + end + SetRPMLed("mRPMLedTable") + end + end + else + -- bypass (give control to manager) + return 1 + end + -- timebase + if GetTicks() > mOldOSPTickCount then + mOldOSPTickCount = GetTicks() + 10 + end + + return 1 +end + + +-- G27 Methods Event +function ospG27MethodEvent(idx) + mOSPG27Method = 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(mOSPG27Method) + -- 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(mOSPG27Method) + -- 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: " .. mOSPG27Method .. " 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 mOSPG27Method <= 1 or mOSPG27Method > 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 mOSPG27Method == 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 mOSPG27Method == 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) + mOSPFanatecMethod = 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(mOSPFanatecMethod) + -- 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(mOSPFanatecMethod) + -- 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 (mOSPFanatecMethod <= 0) or mOSPFanatecMethod > 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 mOSPFanatecMethod == 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 mOSPFanatecMethod == 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 mOSPFanatecMethod == 3 then + initLedTable(mRPMLedTable, 0) + -- center leds blinking if method 3, ON + mRPMLedTable["RPM3"] = 1 + mRPMLedTable["RPM4"] = 1 + mRPMLedTable["RPM5"] = 1 + + elseif mOSPFanatecMethod == 4 then + initLedTable(mRPMLedTable, 0) + -- side fixed if method 4, ON + mRPMLedTable["RPM0"] = 1 + mRPMLedTable["RPM1"] = 1 + mRPMLedTable["RPM7"] = 1 + mRPMLedTable["RPM8"] = 1 + end + SetRPMLed("mRPMLedTable") + end + + if mOSPBlink > (mOSPBlinkTime / 2) then + if (mOSPFanatecMethod <= 0) or mOSPFanatecMethod > 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 mOSPFanatecMethod == 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 mOSPFanatecMethod == 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 mOSPFanatecMethod == 3 then + initLedTable(mRPMLedTable, 0) + -- center leds blinking if method 3, OFF + mRPMLedTable["RPM3"] = 0 + mRPMLedTable["RPM4"] = 0 + mRPMLedTable["RPM5"] = 0 + + elseif mOSPFanatecMethod == 4 then + initLedTable(mRPMLedTable, 0) + -- side fixed if method 4, ON + mRPMLedTable["RPM0"] = 1 + mRPMLedTable["RPM1"] = 1 + mRPMLedTable["RPM7"] = 1 + mRPMLedTable["RPM8"] = 1 + end + SetRPMLed("mRPMLedTable") + end + end + + else + -- bypass (give control to manager) + return 1 + end + -- timebase + if GetTicks() > mOldOSPTickCount then + mOldOSPTickCount = GetTicks() + 10 + end + + return 1 +end + +-- ================================================== +-- SIM RACE Deluxe OSP Methods Event + +function ospSRDlxMethodEvent(idx) + mOSPSRDlxMethod = 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_ospSRDlxMethodEvent(mOSPSRDlxMethod) + -- 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_ospSRDlxMethodEvent(mOSPSRDlxMethod) + -- 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 red zone value + --local redZone = GetCarInfo("redzone") + --if redZone == nil then redZone = 18000 end + + -- get current osp factor + --local ospFactor = GetContextInfo("ospfactor") + --if ospFactor == nil then ospFactor = 80 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 + + -- print("OSP1: " .. mOSPLED1 .. " OSP2: " .. mOSPLED2 .."\n") + -- print(rpm .. " - " .. gOSPLimit) + + -- rpm > osplimit so activate shiftpoints leds + if rpm > gOSPLimit then + + -- no blinking allowed + if mNoBlink then + -- set both leds + SetOSPFeedback(1) + + else + + if GetTicks() > mOldOSPTickCount then + mOSPBlink = mOSPBlink + 1 + end + + if mOSPSRDlxMethod <= 3 then + -- methods 1 to 3 + if mOSPBlink >= mOSPBlinkTime then + mOSPBlink = 0 + end + + if mOSPBlink <= (mOSPBlinkTime / 2) then + if mOSPSRDlxMethod ~= 3 then + -- if not method 3 + SetOSPFeedback(1) + end + if (mOSPSRDlxMethod == 1) or (mOSPSRDlxMethod == 3) then + -- add blue leds blinking if method 1 or 3 + for i = 7,9 do + led = led.format("RPM%d",i) + mRPMLedTable[led] = 1 + end + SetRPMLed("mRPMLedTable") + end + end + + if mOSPBlink > (mOSPBlinkTime / 2) then + SetOSPFeedback(0) + + if (mOSPSRDlxMethod == 1) or (mOSPSRDlxMethod == 3) then + -- add blue leds blinking if method 1 or 3 + for i = 7,9 do + led = led.format("RPM%d",i) + mRPMLedTable[led] = 0 + end + SetRPMLed("mRPMLedTable") + end + end + end + + if mOSPSRDlxMethod == 2 then + -- add blue leds not blinking if method 2 + for i = 7,9 do + led = led.format("RPM%d",i) + mRPMLedTable[led] = 1 + end + SetRPMLed("mRPMLedTable") + end + end + else + -- bypass (give control to manager) + return 1 + end + -- timebase + if GetTicks() > mOldOSPTickCount then + mOldOSPTickCount = GetTicks() + 10 + end + + return 1 +end + + +-- ================================================== +-- SIM RACE F1 OSP Methods Event + +function ospSRF1MethodEvent(idx) + mOSPSRF1Method = 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_ospSRF1MethodEvent(mOSPSRF1Method) + -- 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_ospSRF1MethodEvent(mOSPSRF1Method) + -- 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 red zone value + --local redZone = GetCarInfo("redzone") + --if redZone == nil then redZone = 18000 end + + -- get current osp factor + --local ospFactor = GetContextInfo("ospfactor") + --if ospFactor == nil then ospFactor = 80 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 + + -- print("OSP1: " .. mOSPLED1 .. " OSP2: " .. mOSPLED2 .."\n") + -- print(rpm .. " - " .. gOSPLimit) + + -- rpm > osplimit so activate shiftpoints leds + if rpm > gOSPLimit then + + -- no blinking allowed + if mNoBlink then + -- set both leds + SetOSPFeedback(1) + + else + + if GetTicks() > mOldOSPTickCount then + mOSPBlink = mOSPBlink + 1 + end + + if mOSPSRF1Method <= 3 then + -- methods 1 to 3 + if mOSPBlink >= mOSPBlinkTime then + mOSPBlink = 0 + end + + if mOSPBlink <= (mOSPBlinkTime / 2) then + if mOSPSRF1Method ~= 3 then + -- if not method 3 + SetOSPFeedback(1) + end + if (mOSPSRF1Method == 1) or (mOSPSRF1Method == 3) then + -- add blue leds blinking if method 1 or 3 + for i = 10,14 do + led = led.format("RPM%d",i) + mRPMLedTable[led] = 1 + end + SetRPMLed("mRPMLedTable") + end + end + + if mOSPBlink > (mOSPBlinkTime / 2) then + SetOSPFeedback(0) + + if (mOSPSRF1Method == 1) or (mOSPSRF1Method == 3) then + -- add blue leds blinking if method 1 or 3 + for i = 10,14 do + led = led.format("RPM%d",i) + mRPMLedTable[led] = 0 + end + SetRPMLed("mRPMLedTable") + end + end + end + + if mOSPSRF1Method == 2 then + -- add blue leds not blinking if method 2 + for i = 10,14 do + led = led.format("RPM%d",i) + mRPMLedTable[led] = 1 + end + SetRPMLed("mRPMLedTable") + end + end + else + -- bypass (give control to manager) + return 1 + end + -- timebase + if GetTicks() > mOldOSPTickCount then + mOldOSPTickCount = GetTicks() + 10 + end + + return 1 end
\ No newline at end of file diff --git a/scripts/shiftlights.lua b/scripts/shiftlights.lua index 81e7f66..795b68b 100644 --- a/scripts/shiftlights.lua +++ b/scripts/shiftlights.lua @@ -12,7 +12,7 @@ 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 @@ -56,7 +56,7 @@ function ProgressiveSLI(rpm, redzone, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p 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) @@ -292,7 +292,7 @@ end 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 @@ -348,12 +348,12 @@ function RpmSRDlx(rpm, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10 ) 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 @@ -386,7 +386,7 @@ end function SideToCenterSRDlx(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.RPM9 = 1 end -- B @@ -413,7 +413,7 @@ end function SideToCenterSRF1(rpm, redzone, p1, p2, p3, p4 ,p5 ,p6 ,p7, p8) local rz = redzone / 100 - + -- side to center custom if rpm > (rz*p1) then mRPMLedTable.RPM0 = 1 end -- G if rpm > (rz*p1) then mRPMLedTable.RPM14 = 1 end -- B @@ -449,13 +449,13 @@ function ProgressiveSRF1(rpm, redzone, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, 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 @@ -463,7 +463,7 @@ function ProgressiveSRF1(rpm, redzone, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, if rpm > (rz*p15) then mRPMLedTable.RPM14 = 1 end end - + -- alternate green, red and blue method function AlternateSRF1(rpm, redzone, step1, step2, step3) @@ -567,7 +567,7 @@ function shiftLightsMethodEvent(idx) -- 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(mShiftlightsMethodIndex) -- if result = 0 bypass the script below and return 0 @@ -579,70 +579,70 @@ function shiftLightsMethodEvent(idx) local rpm = 0 rpm = GetCarInfo("rpm") if rpm == nil then rpm = 0 end - + initLedTable(mRPMLedTable, 0) - + if GetContextInfo("lastgearnorpm") and GetCarInfo("gear") == 7 then -- no shiftlights on last gear local tName = "mRPMLedTable" SetRPMLed(tName) return 1 end - + if mShiftlightsMethodIndex == 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 mShiftlightsMethodIndex == 1 then -- alternate method 1 AlternateSLI(rpm, gRedZone, 11.0, 12.0, 12.9) - + elseif mShiftlightsMethodIndex == 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 mShiftlightsMethodIndex == 3 then - -- abs rpm method 3 (not recommended) + -- 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 mShiftlightsMethodIndex == 4 then -- side to center method 4 SideToCenterSLI(rpm, gRedZone, 94.5, 95, 96, 97 ,98 ,99 ,99.5 ) - + elseif mShiftlightsMethodIndex == 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 mShiftlightsMethodIndex == 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 @@ -666,7 +666,7 @@ function shiftLightsBU0710Event(idx) -- 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(mShiftlightsBU0710MethodIndex) -- if result = 0 bypass the script below and return 0 @@ -676,16 +676,16 @@ function shiftLightsBU0710Event(idx) local rpm = GetCarInfo("rpm") if rpm == nil then rpm = 0 end - + -- init leds (see global.lua) mBU0710Leds = 0 - + if GetContextInfo("lastgearnorpm") and GetCarInfo("gear") == 7 then -- no shiftlights on last gear SetBU0710Led(mBU0710Leds) return 1 end - + if (mShiftlightsBU0710MethodIndex <= 1) or (mShiftlightsBU0710MethodIndex >= 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 ) @@ -701,7 +701,7 @@ function shiftLightsBU0710Event(idx) else return 1 end - + SetBU0710Led(mBU0710Leds) return 1 end @@ -720,7 +720,7 @@ function shiftLightsG27LedsMethodEvent(idx) -- 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(mShiftlightsG27MethodIndex) -- if result = 0 bypass the script below and return 0 @@ -730,16 +730,16 @@ function shiftLightsG27LedsMethodEvent(idx) local rpm = GetCarInfo("rpm") if rpm == nil then rpm = 0 end - + -- init leds (see global.lua) mG27Leds = 0 - + if GetContextInfo("lastgearnorpm") and GetCarInfo("gear") == 7 then -- no shiftlights on last gear SetG27Led(mG27Leds) return 1 end - + if mShiftlightsG27MethodIndex <= 0 or mShiftlightsG27MethodIndex >= 3 then -- progressive methods 1 ProgressiveG27(rpm, gRedZone, 2.0, 2.5, 3.5, 4.5, 4.9 ) @@ -756,7 +756,7 @@ function shiftLightsG27LedsMethodEvent(idx) else return 1 end - + SetG27Led(mG27Leds) return 1 end @@ -766,7 +766,7 @@ end -- Fanatec ShiftLights Methods Event function shiftLightsFanatecMethodEvent(idx) mShiftlightsFanatecMethodIndex = idx - -- get red zone (red zone default value is initialized in gear.lua ) + -- 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 @@ -775,7 +775,7 @@ function shiftLightsFanatecMethodEvent(idx) -- 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(mShiftlightsFanatecMethodIndex) -- if result = 0 bypass the script below and return 0 @@ -785,25 +785,25 @@ function shiftLightsFanatecMethodEvent(idx) local rpm = GetCarInfo("rpm") if rpm == nil then rpm = 0 end - + -- init leds (see global.lua) initLedTable(mRPMLedTable, 0) - + if GetContextInfo("lastgearnorpm") and GetCarInfo("gear") == 7 then -- no shiftlights on last gear local tName = "mRPMLedTable" SetRPMLed(tName) return 1 end - + if (mShiftlightsFanatecMethodIndex < 1) or (mShiftlightsFanatecMethodIndex > 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 mShiftlightsFanatecMethodIndex == 1 then -- alternate method 1 AlternateFanatec(rpm, gRedZone, 7.0, 8.0, 8.9) - + elseif (mShiftlightsFanatecMethodIndex == 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] ) @@ -815,45 +815,45 @@ function shiftLightsFanatecMethodEvent(idx) elseif mShiftlightsFanatecMethodIndex == 4 then -- side to center method 4 SideToCenterFanatec(rpm, gRedZone, 96, 97 ,98 ,99 ,99.5 ) - + elseif mShiftlightsFanatecMethodIndex == 5 then -- KERS + RPM - - -- get kers value, see function in global.lua + + -- 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 mShiftlightsFanatecMethodIndex == 6 then -- Revers KERS + RPM - - -- get kers value, see function in global.lua + + -- 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" SetRPMLed(tName) return 1 @@ -873,7 +873,7 @@ function shiftLightsSRDlxMethodEvent(idx) -- 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_shiftLightsSRDlxMethodEvent(mShiftlightsSRDlxMethodIndex) -- if result = 0 bypass the script below and return 0 @@ -885,69 +885,69 @@ function shiftLightsSRDlxMethodEvent(idx) local rpm = 0 rpm = GetCarInfo("rpm") if rpm == nil then rpm = 0 end - + -- init leds (see global.lua) initLedTable(mRPMLedTable, 0) - + if GetContextInfo("lastgearnorpm") and GetCarInfo("gear") == 7 then -- no shiftlights on last gear local tName = "mRPMLedTable" SetRPMLed(tName) return 1 end - + if mShiftlightsSRDlxMethodIndex == 0 then -- progressive method 0 ProgressiveSRDlx(rpm, gRedZone, 5, 6.5, 7, 7.5, 8, 8.5, 9, 9.5, 9.8, 9.98 ) - + elseif mShiftlightsSRDlxMethodIndex == 1 then -- alternate method 1 AlternateSRDlx(rpm, gRedZone, 7.0, 8.0, 9.9) - + elseif mShiftlightsSRDlxMethodIndex == 2 then -- percentage method 2 PercentageSRDlx(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] ) - + elseif mShiftlightsSRDlxMethodIndex == 3 then - -- abs rpm method 3 (not recommended) + -- abs rpm method 3 (not recommended) RpmSRDlx(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] ) - + elseif mShiftlightsSRDlxMethodIndex == 4 then -- side to center method 4 SideToCenterSRDlx(rpm, gRedZone, 96, 97 ,98 ,99 ,99.5 ) - + elseif mShiftlightsSRDlxMethodIndex == 5 then -- KERS + RPM - + -- get kers value local k_percent = GetKersPercent() - + -- without first 4 green leds AlternateSRDlx(rpm, gRedZone, 100, 8.6, 9.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 >= 33 then mRPMLedTable.RPM1 = 1 end if k_percent >= 66 then mRPMLedTable.RPM2 = 1 end - + elseif mShiftlightsSRDlxMethodIndex == 6 then -- Revers KERS + RPM - + -- get kers value local k_percent = GetKersPercent() - + -- without first 4 green leds AlternateSRDlx(rpm, gRedZone, 0, 8.6, 9.9) - + -- KERS feedback on green leds -- print("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 @@ -970,7 +970,7 @@ function shiftLightsSRF1MethodEvent(idx) -- 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_shiftLightsSRF1MethodEvent(mShiftlightsSRF1MethodIndex) -- if result = 0 bypass the script below and return 0 @@ -982,7 +982,7 @@ function shiftLightsSRF1MethodEvent(idx) local rpm = 0 rpm = GetCarInfo("rpm") if rpm == nil then rpm = 0 end - + -- init leds (see global.lua) initLedTable(mRPMLedTable, 0) @@ -992,63 +992,63 @@ function shiftLightsSRF1MethodEvent(idx) SetRPMLed(tName) return 1 end - + if mShiftlightsSRF1MethodIndex == 0 then -- progressive method 0 ProgressiveSRF1(rpm, gRedZone, 7.5, 8, 8.5, 9, 9.5, 10, 10.5, 11, 11.5, 12, 12.5, 13, 13.5, 14.5, 14.99 ) - + elseif mShiftlightsSRF1MethodIndex == 1 then -- alternate method 1 AlternateSRF1(rpm, gRedZone, 12.0, 13.0, 14.9) - + elseif mShiftlightsSRF1MethodIndex == 2 then -- percentage method 2 PercentageSRF1(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], RPM_PERCENT_VALUES[14], RPM_PERCENT_VALUES[15] ) - + elseif mShiftlightsSRF1MethodIndex == 3 then - -- abs rpm method 3 (not recommended) + -- abs rpm method 3 (not recommended) RpmSRF1(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_PERCENT_VALUES[11], RPM_PERCENT_VALUES[12], RPM_PERCENT_VALUES[13], RPM_PERCENT_VALUES[14], RPM_PERCENT_VALUES[15] ) - + elseif mShiftlightsSRF1MethodIndex == 4 then -- side to center method 4 SideToCenterSRF1(rpm, gRedZone, 94.5, 95, 96, 97 ,98 ,99 ,99.5 ) - + elseif mShiftlightsSRF1MethodIndex == 5 then -- KERS + RPM - + -- get kers value local k_percent = GetKersPercent() - + -- without first 4 green leds AlternateSRF1(rpm, gRedZone, 100, 13.6, 14.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 >= 20 then mRPMLedTable.RPM1 = 1 end if k_percent >= 40 then mRPMLedTable.RPM2 = 1 end if k_percent >= 60 then mRPMLedTable.RPM3 = 1 end if k_percent >= 80 then mRPMLedTable.RPM4 = 1 end - + elseif mShiftlightsSRF1MethodIndex == 6 then -- Revers KERS + RPM - + -- get kers value local k_percent = GetKersPercent() - + -- without first 4 green leds AlternateSRF1(rpm, gRedZone, 0, 13.6, 14.9) - + -- KERS feedback on green leds -- print("KERS: " .. kers_level .. " - " .. k_percent .. "\n") - + if k_percent > 0 then mRPMLedTable.RPM4 = 0 end if k_percent >= 20 then mRPMLedTable.RPM3 = 0 end if k_percent >= 40 then mRPMLedTable.RPM2 = 0 end if k_percent >= 60 then mRPMLedTable.RPM1 = 0 end if k_percent >= 80 then mRPMLedTable.RPM0 = 0 end - + else return 1 end diff --git a/scripts/simracedlx.lua b/scripts/simracedlx.lua index fe716ea..5f32cbe 100644 --- a/scripts/simracedlx.lua +++ b/scripts/simracedlx.lua @@ -1,537 +1,537 @@ --- SIMRACE DELUXE Lua Script v1.5
--- Copyright (c)2012-2013 by Zappadoc - All Rights Reserved.
--- this script builds all functions associated with
--- left and right panels of SIMRACE-DLX device
--- last change by Zappadoc - 2013-09
-
--- ============================================================
--- Left and Right Panel functions
--- ============================================================
-function srdlxLeftDigitsEvent(swFunction)
- return srdlxDigitsEvent(swFunction, 0)
-end
-function srdlxRightDigitsEvent(swFunction)
- return srdlxDigitsEvent(swFunction, 1)
-end
--- IN function of left panel
--- param: recieve from SLI Manager the current switch position
-function srdlxDigitsEvent(swFunction, side)
- swValue = swFunction + 1
-
- -- call custom script
- if side == 0 then
- local result = custom_srdlxLeftDigitsEvent(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_srdlxLeftDigitsEvent(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
- else
- local result = custom_srdlxRightDigitsEvent(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_srdlxRightDigitsEvent(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
- end
-
- local hr = 0
- local mn = 0
- local sc = 0
- local ms = 0
- local hd = 0
- local lpt = 0.0
- local diffTimeFlag = false
- local timeFlag = false
- local systemflag = false
- local unit = false
- local inf = ""
- local spd = 0.0
- local isSlowUpdate = false
- local srdlxPanel = ""
-
- -- 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")
-
- -- lap finished, display lap time a few seconds
- local dlt = false
- dlt = GetContextInfo("displaylaptime")
- if dlt == nil then dlt = false end
- if dlt and side == 1 then
- swValue = 11
- end
-
- -- 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 left and right panel
- local qiInf = 1
- if side == 0 then
- qiInf = GetContextInfo("f1quickinfoleft")
- else
- qiInf = GetContextInfo("f1quickinforight")
- end
- if qiInf == nil then qiInf = 1 end
- -- force position to match QI preference
- swValue = qiInf
- end
-
- -- check if PIT Feedback ON
- local pf = false
- pf = GetContextInfo("pitfeedback")
- if pf == nil or pf == 0 then pf = false end
- if pf then
- -- force position to PIT/SPEED function if car pits
- local pit = GetCarInfo("inpits")
- if pit > 0 then
- if side == 0 then
- swValue = 45
- else
- swValue = 1
- end
- end
- end
-
- -- get current simulation name
- local sim = GetContextInfo("simulation")
-
- --print ( "swValue: " .. swValue .. "\n")
-
- -- check postion and compute left panel string
- if swValue == 1 then
- -- speed only
- srdlxPanel = string.format("%3.0f ", spd )
-
- elseif swValue == 2 then
- -- fuel
- local fuel = GetCarInfo("fuel")
- if fuel ~= nil then
- fuel = GetFuel(fuel, unit)
- if fuel >= 100 then
- srdlxPanel = string.format("F%3d", round(fuel))
- elseif fuel >= 10 then
- srdlxPanel = string.format("F%02d ", round(fuel))
- else
- srdlxPanel = string.format("F%1.1f ", fuel)
- end
- end
- elseif swValue == 3 then
- -- position
- inf = GetContextInfo("position")
- if inf ~= nil then
- if inf >= 100 then
- srdlxPanel = string.format("P%3d", inf)
- else
- srdlxPanel = string.format("P%02d ", inf)
- end
- end
- elseif swValue == 4 then
- -- laps completed
- inf = GetContextInfo("laps")
- if inf ~= nil then
- -- if more then 99 laps
- if inf >= 100 then
- srdlxPanel = string.format("L%3d", inf)
- else
- srdlxPanel = string.format("L%02d ", inf)
- end
- end
- elseif swValue == 5 then
- -- sector
- inf = GetCarInfo("sector")
- if inf ~= nil then
- -- check if sector > 9
- if inf >9 then
- srdlxPanel = string.format("S%02d ", inf)
- else
- srdlxPanel = string.format("S%01d ", inf)
- end
- end
- elseif swValue == 6 then
- -- total laps if available
- local tl = GetContextInfo("lapscount")
- if tl < 1 then tl = 0 end
- -- if more then 99 laps
- if tl >= 100 or tl >= 100 then
- srdlxPanel = string.format("%03d ", tl)
- else
- srdlxPanel = string.format("t%02d ", tl)
- end
-
- elseif swValue == 7 then
- -- water temp
- inf = GetCarInfo("watertemp")
- if inf ~= nil then
- inf = GetTemp(inf, unit)
- srdlxPanel = string.format("%2.1f ", inf)
- end
- elseif swValue == 8 then
- -- oil temp
- inf = GetCarInfo("oiltemp")
- if inf ~= nil then
- inf = GetTemp(inf, unit)
- srdlxPanel = string.format("%2.1f ", inf)
- end
-
- elseif swValue == 9 then
- -- best lap time
- timeFlag = true
- lpt = GetTimeInfo("laptime")
-
- 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
- diffTimeFlag = 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
- diffTimeFlag = true
- timeFlag = true
- lpt = GetTimeInfo("realdiffbest")
-
- elseif swValue == 20 then
- -- real time diff vs your last
- diffTimeFlag = true
- timeFlag = true
- lpt = GetTimeInfo("realdifflast")
-
- elseif swValue == 21 then
- -- get an average consumption of fuel per lap and gives the remaining laps
- local remainintank = GetCarInfo("remainlapsintank")
- srdlxPanel = string.format("L%3.0f", math.floor(remainintank) )
-
- elseif swValue == 22 then
- -- rpm
- isSlowUpdate = true
- diffTimeFlag = true
- local rpm = GetCarInfo("rpm")
- local r = rpm / 10.0
- if r < 1000 then
- srdlxPanel = string.format("%3.1f", r)
- else
- srdlxPanel = string.format("%4d.", round(r))
- end
- elseif swValue == 23 then
- -- track size
- isSlowUpdate = true
- diffTimeFlag = true
- local trcksz = GetContextInfo("tracksize")
- local r = trcksz / 10
- if r < 1000 then
- srdlxPanel = string.format("%3.1f", r)
- else
- srdlxPanel = string.format("%4d.", 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))
- srdlxPanel = string.format("%3d ", p )
-
- elseif swValue == 25 then
- -- kers
- local kers = GetCarInfo("kers")
- srdlxPanel = string.format("%3d ", round(kers/1000))
-
- elseif swValue == 26 then
- -- kers max
- local kmx = GetCarInfo("kersmax")
- srdlxPanel = string.format("%3d ", round(kmx/1000))
-
- elseif swValue == 27 then
- -- drs
- local drs = GetCarInfo("drs")
- if drs == 1 then
- srdlxPanel = "ON "
- else
- srdlxPanel = "OFF"
- end
-
- elseif swValue == 28 then
- -- kers percent
- local kers = GetCarInfo("kers")
- srdlxPanel = 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
- srdlxPanel = 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
- srdlxPanel = 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
- srdlxPanel = 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
- srdlxPanel = string.format("%3.0f ", inf)
- end
-
- elseif swValue == 33 then
- -- wheels pressure if available
- inf = GetCarInfo("wheelpressfrontleft")
- if inf ~= nil then
- -- convert to psi
- srdlxPanel = string.format("%2.1f ", inf / 6.88)
- end
-
- elseif swValue == 34 then
- inf = GetCarInfo("wheelpressfrontright")
- if inf ~= nil then
- srdlxPanel = string.format("%2.1f ", inf / 6.88)
- end
-
- elseif swValue == 35 then
- inf = GetCarInfo("wheelpressrearleft")
- if inf ~= nil then
- srdlxPanel = string.format("%2.1f ", inf / 6.88)
- end
-
- elseif swValue == 36 then
- inf = GetCarInfo("wheelpressrearright")
- if inf ~= nil then
- srdlxPanel = 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
- srdlxPanel = 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
- srdlxPanel = 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
- srdlxPanel = 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
- srdlxPanel = string.format("%3.0f ", inf)
- end
-
- elseif swValue == 41 then
- -- time remaining if available
- lpt = GetTimeInfo("timeremaining")
- timeFlag = true
-
- elseif swValue == 42 then
- -- PC system time
- systemflag = true
- lpt = GetTimeInfo("systemtime")
- timeFlag = true
- diffTimeFlag = true
- elseif swValue == 43 then
- -- time elapsed if available
- lpt = GetTimeInfo("timetotalelapsed")
- timeFlag = true
-
- elseif swValue == 44 then
- -- last sector 1, 2 and 3
- local sector = GetCarInfo("sector")
- timeFlag = true
- diffTimeFlag = true
- if sector == 1 then
- -- sector 3
- local ls1 = GetTimeInfo("lastsector1")
- local ls2 = GetTimeInfo("lastsector2")
- local lt = GetTimeInfo("lastlaptime")
- if ls1 > 0 and ls2 > 0 then
- lpt = lt - (ls1 + ls2)
- end
- elseif sector == 2 then
- local ls1 = GetTimeInfo("lastsector1")
- lpt = ls1
- else
- -- sector 3
- local ls2 = GetTimeInfo("lastsector2")
- lpt = ls2
- end
-
- elseif swValue == 45 then
- -- PIT
- srdlxPanel = "PIt "
-
- elseif swValue == 46 then
- -- sc
- local sc = GetContextInfo("safetycare")
- if sc == 1 then
- srdlxPanel = "SCAR"
- else
- srdlxPanel = "OFF "
- end
-
- else
- srdlxPanel = " "
- end
-
- local refreshRate = mRefreshLapTimeRate
- if diffTimeFlag then
- refreshRate = mDeltaTimeDelay
- 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() > (refreshRate + mDeltaTimeOldTicks ) then
- mDeltaTimeOldTicks = GetTicks()
-
- if lpt == -1 or (mn + sc + ms) == 0.0000 then
- mDeltaTimeBackup = "-.---"
-
- elseif systemflag then
- mDeltaTimeBackup = string.format( "%2d.%02d", mn, sc)
- -- > 9mn
- elseif mn > 9 then
- if c == "" then
- mDeltaTimeBackup = string.format( "%2d.%2d", 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.%01d", mn, sc, hd)
- else
- mDeltaTimeBackup = string.format( "%s%1d.%02d", c, mn, sc)
- end
-
- else
- -- mn == 0 ; sc > 9
- if sc > 9 then
- if c == "" then
- mDeltaTimeBackup = string.format( "0.%2d.%1d", sc, hd)
- else
- mDeltaTimeBackup = string.format( "%s0.%2d.", c, sc)
- end
- else
- -- sc < 10
- if c == "" then
- mDeltaTimeBackup = string.format( "0.%01d.%02d", sc, hd)
- else
- mDeltaTimeBackup = string.format( "%s0.%01d.%01d", c, sc, hd)
- end
- end
- end
- end
-
- --print(srdlxPanel,mDeltaTimeBackup)
- srdlxPanel = mDeltaTimeBackup
- end
-
- if isSlowUpdate then
-
- if GetTicks() > ( refreshRate + mDeltaTimeOldTicks ) then
- mDeltaTimeOldTicks = GetTicks()
- if side == 0 then
- mSRDlxLeftText = srdlxPanel
- else
- mSRDlxRightText = srdlxPanel
- end
- -- print(GetTicks() .. mSRDlxRightText .."\n")
- end
- else
- if side == 0 then
- mSRDlxLeftText = srdlxPanel
- else
- mSRDlxRightText = srdlxPanel
- end
- end
-
- -- print(mSRDlxLeftText, mSRDlxRightText, srdlxPanel)
- -- send string to sli manager
- if side == 0 then
- SetLeftDigits( mSRDlxLeftText )
- else
- SetRightDigits( mSRDlxRightText )
- end
-
- return 1
-end
+-- SIMRACE DELUXE Lua Script v1.5 +-- Copyright (c)2012-2013 by Zappadoc - All Rights Reserved. +-- this script builds all functions associated with +-- left and right panels of SIMRACE-DLX device +-- last change by Zappadoc - 2013-09 + +-- ============================================================ +-- Left and Right Panel functions +-- ============================================================ +function srdlxLeftDigitsEvent(swFunction) + return srdlxDigitsEvent(swFunction, 0) +end +function srdlxRightDigitsEvent(swFunction) + return srdlxDigitsEvent(swFunction, 1) +end +-- IN function of left panel +-- param: recieve from SLI Manager the current switch position +function srdlxDigitsEvent(swFunction, side) + swValue = swFunction + 1 + + -- call custom script + if side == 0 then + local result = custom_srdlxLeftDigitsEvent(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_srdlxLeftDigitsEvent(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 + else + local result = custom_srdlxRightDigitsEvent(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_srdlxRightDigitsEvent(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 + end + + local hr = 0 + local mn = 0 + local sc = 0 + local ms = 0 + local hd = 0 + local lpt = 0.0 + local diffTimeFlag = false + local timeFlag = false + local systemflag = false + local unit = false + local inf = "" + local spd = 0.0 + local isSlowUpdate = false + local srdlxPanel = "" + + -- 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") + + -- lap finished, display lap time a few seconds + local dlt = false + dlt = GetContextInfo("displaylaptime") + if dlt == nil then dlt = false end + if dlt and side == 1 then + swValue = 11 + end + + -- 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 left and right panel + local qiInf = 1 + if side == 0 then + qiInf = GetContextInfo("f1quickinfoleft") + else + qiInf = GetContextInfo("f1quickinforight") + end + if qiInf == nil then qiInf = 1 end + -- force position to match QI preference + swValue = qiInf + end + + -- check if PIT Feedback ON + local pf = false + pf = GetContextInfo("pitfeedback") + if pf == nil or pf == 0 then pf = false end + if pf then + -- force position to PIT/SPEED function if car pits + local pit = GetCarInfo("inpits") + if pit > 0 then + if side == 0 then + swValue = 45 + else + swValue = 1 + end + end + end + + -- get current simulation name + local sim = GetContextInfo("simulation") + + --print ( "swValue: " .. swValue .. "\n") + + -- check postion and compute left panel string + if swValue == 1 then + -- speed only + srdlxPanel = string.format("%3.0f ", spd ) + + elseif swValue == 2 then + -- fuel + local fuel = GetCarInfo("fuel") + if fuel ~= nil then + fuel = GetFuel(fuel, unit) + if fuel >= 100 then + srdlxPanel = string.format("F%3d", round(fuel)) + elseif fuel >= 10 then + srdlxPanel = string.format("F%02d ", round(fuel)) + else + srdlxPanel = string.format("F%1.1f ", fuel) + end + end + elseif swValue == 3 then + -- position + inf = GetContextInfo("position") + if inf ~= nil then + if inf >= 100 then + srdlxPanel = string.format("P%3d", inf) + else + srdlxPanel = string.format("P%02d ", inf) + end + end + elseif swValue == 4 then + -- laps completed + inf = GetContextInfo("laps") + if inf ~= nil then + -- if more then 99 laps + if inf >= 100 then + srdlxPanel = string.format("L%3d", inf) + else + srdlxPanel = string.format("L%02d ", inf) + end + end + elseif swValue == 5 then + -- sector + inf = GetCarInfo("sector") + if inf ~= nil then + -- check if sector > 9 + if inf >9 then + srdlxPanel = string.format("S%02d ", inf) + else + srdlxPanel = string.format("S%01d ", inf) + end + end + elseif swValue == 6 then + -- total laps if available + local tl = GetContextInfo("lapscount") + if tl < 1 then tl = 0 end + -- if more then 99 laps + if tl >= 100 or tl >= 100 then + srdlxPanel = string.format("%03d ", tl) + else + srdlxPanel = string.format("t%02d ", tl) + end + + elseif swValue == 7 then + -- water temp + inf = GetCarInfo("watertemp") + if inf ~= nil then + inf = GetTemp(inf, unit) + srdlxPanel = string.format("%2.1f ", inf) + end + elseif swValue == 8 then + -- oil temp + inf = GetCarInfo("oiltemp") + if inf ~= nil then + inf = GetTemp(inf, unit) + srdlxPanel = string.format("%2.1f ", inf) + end + + elseif swValue == 9 then + -- best lap time + timeFlag = true + lpt = GetTimeInfo("laptime") + + 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 + diffTimeFlag = 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 + diffTimeFlag = true + timeFlag = true + lpt = GetTimeInfo("realdiffbest") + + elseif swValue == 20 then + -- real time diff vs your last + diffTimeFlag = true + timeFlag = true + lpt = GetTimeInfo("realdifflast") + + elseif swValue == 21 then + -- get an average consumption of fuel per lap and gives the remaining laps + local remainintank = GetCarInfo("remainlapsintank") + srdlxPanel = string.format("L%3.0f", math.floor(remainintank) ) + + elseif swValue == 22 then + -- rpm + isSlowUpdate = true + diffTimeFlag = true + local rpm = GetCarInfo("rpm") + local r = rpm / 10.0 + if r < 1000 then + srdlxPanel = string.format("%3.1f", r) + else + srdlxPanel = string.format("%4d.", round(r)) + end + elseif swValue == 23 then + -- track size + isSlowUpdate = true + diffTimeFlag = true + local trcksz = GetContextInfo("tracksize") + local r = trcksz / 10 + if r < 1000 then + srdlxPanel = string.format("%3.1f", r) + else + srdlxPanel = string.format("%4d.", 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)) + srdlxPanel = string.format("%3d ", p ) + + elseif swValue == 25 then + -- kers + local kers = GetCarInfo("kers") + srdlxPanel = string.format("%3d ", round(kers/1000)) + + elseif swValue == 26 then + -- kers max + local kmx = GetCarInfo("kersmax") + srdlxPanel = string.format("%3d ", round(kmx/1000)) + + elseif swValue == 27 then + -- drs + local drs = GetCarInfo("drs") + if drs == 1 then + srdlxPanel = "ON " + else + srdlxPanel = "OFF" + end + + elseif swValue == 28 then + -- kers percent + local kers = GetCarInfo("kers") + srdlxPanel = 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 + srdlxPanel = 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 + srdlxPanel = 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 + srdlxPanel = 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 + srdlxPanel = string.format("%3.0f ", inf) + end + + elseif swValue == 33 then + -- wheels pressure if available + inf = GetCarInfo("wheelpressfrontleft") + if inf ~= nil then + -- convert to psi + srdlxPanel = string.format("%2.1f ", inf / 6.88) + end + + elseif swValue == 34 then + inf = GetCarInfo("wheelpressfrontright") + if inf ~= nil then + srdlxPanel = string.format("%2.1f ", inf / 6.88) + end + + elseif swValue == 35 then + inf = GetCarInfo("wheelpressrearleft") + if inf ~= nil then + srdlxPanel = string.format("%2.1f ", inf / 6.88) + end + + elseif swValue == 36 then + inf = GetCarInfo("wheelpressrearright") + if inf ~= nil then + srdlxPanel = 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 + srdlxPanel = 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 + srdlxPanel = 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 + srdlxPanel = 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 + srdlxPanel = string.format("%3.0f ", inf) + end + + elseif swValue == 41 then + -- time remaining if available + lpt = GetTimeInfo("timeremaining") + timeFlag = true + + elseif swValue == 42 then + -- PC system time + systemflag = true + lpt = GetTimeInfo("systemtime") + timeFlag = true + diffTimeFlag = true + elseif swValue == 43 then + -- time elapsed if available + lpt = GetTimeInfo("timetotalelapsed") + timeFlag = true + + elseif swValue == 44 then + -- last sector 1, 2 and 3 + local sector = GetCarInfo("sector") + timeFlag = true + diffTimeFlag = true + if sector == 1 then + -- sector 3 + local ls1 = GetTimeInfo("lastsector1") + local ls2 = GetTimeInfo("lastsector2") + local lt = GetTimeInfo("lastlaptime") + if ls1 > 0 and ls2 > 0 then + lpt = lt - (ls1 + ls2) + end + elseif sector == 2 then + local ls1 = GetTimeInfo("lastsector1") + lpt = ls1 + else + -- sector 3 + local ls2 = GetTimeInfo("lastsector2") + lpt = ls2 + end + + elseif swValue == 45 then + -- PIT + srdlxPanel = "PIt " + + elseif swValue == 46 then + -- sc + local sc = GetContextInfo("safetycare") + if sc == 1 then + srdlxPanel = "SCAR" + else + srdlxPanel = "OFF " + end + + else + srdlxPanel = " " + end + + local refreshRate = mRefreshLapTimeRate + if diffTimeFlag then + refreshRate = mDeltaTimeDelay + 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() > (refreshRate + mDeltaTimeOldTicks ) then + mDeltaTimeOldTicks = GetTicks() + + if lpt == -1 or (mn + sc + ms) == 0.0000 then + mDeltaTimeBackup = "-.---" + + elseif systemflag then + mDeltaTimeBackup = string.format( "%2d.%02d", mn, sc) + -- > 9mn + elseif mn > 9 then + if c == "" then + mDeltaTimeBackup = string.format( "%2d.%2d", 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.%01d", mn, sc, hd) + else + mDeltaTimeBackup = string.format( "%s%1d.%02d", c, mn, sc) + end + + else + -- mn == 0 ; sc > 9 + if sc > 9 then + if c == "" then + mDeltaTimeBackup = string.format( "0.%2d.%1d", sc, hd) + else + mDeltaTimeBackup = string.format( "%s0.%2d.", c, sc) + end + else + -- sc < 10 + if c == "" then + mDeltaTimeBackup = string.format( "0.%01d.%02d", sc, hd) + else + mDeltaTimeBackup = string.format( "%s0.%01d.%01d", c, sc, hd) + end + end + end + end + + --print(srdlxPanel,mDeltaTimeBackup) + srdlxPanel = mDeltaTimeBackup + end + + if isSlowUpdate then + + if GetTicks() > ( refreshRate + mDeltaTimeOldTicks ) then + mDeltaTimeOldTicks = GetTicks() + if side == 0 then + mSRDlxLeftText = srdlxPanel + else + mSRDlxRightText = srdlxPanel + end + -- print(GetTicks() .. mSRDlxRightText .."\n") + end + else + if side == 0 then + mSRDlxLeftText = srdlxPanel + else + mSRDlxRightText = srdlxPanel + end + end + + -- print(mSRDlxLeftText, mSRDlxRightText, srdlxPanel) + -- send string to sli manager + if side == 0 then + SetLeftDigits( mSRDlxLeftText ) + else + SetRightDigits( mSRDlxRightText ) + end + + return 1 +end diff --git a/scripts/simracedlx_iracing.lua b/scripts/simracedlx_iracing.lua index 3dfb281..1a5b220 100644 --- a/scripts/simracedlx_iracing.lua +++ b/scripts/simracedlx_iracing.lua @@ -1,11 +1,11 @@ --- iRacing Custom Scripts - SLIMax Manager Scripts v1.9
--- Copyright ©2011-2013 by Zappadoc - All Rights Reserved.
--- last change by Zappadoc - 2013-05
-
--- ================================
--- 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
+-- iRacing Custom Scripts - SLIMax Manager Scripts v1.9 +-- Copyright ©2011-2013 by Zappadoc - All Rights Reserved. +-- last change by Zappadoc - 2013-05 + +-- ================================ +-- 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/simracef1.lua b/scripts/simracef1.lua index c7503cd..152b684 100644 --- a/scripts/simracef1.lua +++ b/scripts/simracef1.lua @@ -1,694 +1,694 @@ --- SIMRACE F1 Lua Script v1.1.3
--- Copyright (c)2012-2013 by Zappadoc - All Rights Reserved.
--- this script builds all functions associated with
--- left and right panels of SIMRACE-F1 device
--- last change by Zappadoc - 2013-10
-
--- ============================================================
--- Left and Right Panel functions
--- ============================================================
-function srf1LeftDigitsEvent(swFunction)
- return srf1DigitsEvent(swFunction, 0)
-end
-function srf1RightDigitsEvent(swFunction)
- return srf1DigitsEvent(swFunction, 1)
-end
--- IN function of left panel
--- param: recieve from SLI Manager the current switch position
-function srf1DigitsEvent(swFunction, side)
- swValue = swFunction + 1
-
- -- call custom script
- if side == 0 then
- local result = custom_srf1LeftDigitsEvent(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_srf1LeftDigitsEvent(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
- else
- local result = custom_srf1RightDigitsEvent(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_srf1RightDigitsEvent(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
- end
-
- local hr = 0
- local mn = 0
- local sc = 0
- local ms = 0
- local hd = 0
- local lpt = 0.0
- local diffTimeFlag = false
- local timeFlag = false
- local systemflag = false
- local unit = false
- local inf = ""
- local spd = 0.0
- local isSlowUpdate = false
- local srf1Panel = ""
-
- -- 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")
-
- -- lap finished, display lap time a few seconds
- local dlt = false
- dlt = GetContextInfo("displaylaptime")
- if dlt == nil then dlt = false end
- if dlt and side == 1 and swValue ~= 47 and swValue ~= 48 then
- swValue = 11
- end
-
- -- 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 left and right panel
- local qiInf = 1
- if side == 0 then
- qiInf = GetContextInfo("quickinfoleft")
- else
- qiInf = GetContextInfo("quickinforight")
- end
- if qiInf == nil then qiInf = 1 end
- -- force position to match QI preference
- swValue = qiInf
- end
-
- -- check if PIT Feedback ON
- local pf = false
- pf = GetContextInfo("pitfeedback")
- if pf == nil or pf == 0 then pf = false end
- if pf then
- -- force position to PIT/SPEED function if car pits
- local pit = GetCarInfo("inpits")
- if pit > 0 then
- if side == 0 then
- swValue = 45
- else
- swValue = 1
- end
- end
- end
-
- -- get current simulation name
- local sim = GetContextInfo("simulation")
-
- --print ( "swValue: " .. swValue .. "\n")
-
- -- check postion and compute left panel string
- if swValue == 1 then
- -- speed only
- srf1Panel = string.format("%3.0f ", spd )
-
- elseif swValue == 2 then
- -- fuel
- local fuel = GetCarInfo("fuel")
- if fuel ~= nil then
- fuel = GetFuel(fuel, unit)
- if fuel >= 100 then
- srf1Panel = string.format("F%3d", round(fuel))
- elseif fuel >= 10 then
- srf1Panel = string.format("F%2d ", round(fuel))
- else
- srf1Panel = string.format("F%1.1f ", fuel)
- end
- end
- elseif swValue == 3 then
- -- position
- inf = GetContextInfo("position")
- if inf ~= nil then
- if inf >= 100 then
- srf1Panel = string.format("P%3d", inf)
- elseif inf >= 10 then
- srf1Panel = string.format("P%2d ", inf)
- else
- srf1Panel = string.format("P%1d ", inf)
- end
- end
- elseif swValue == 4 then
- -- laps completed
- inf = GetContextInfo("laps")
- if inf ~= nil then
- -- if more then 99 laps
- if inf >= 100 then
- srf1Panel = string.format("L%3d", inf)
- elseif inf >= 10 then
- srf1Panel = string.format("L%2d ", inf)
- else
- srf1Panel = string.format("L%1d ", inf)
- end
- end
- elseif swValue == 5 then
- -- sector
- inf = GetCarInfo("sector")
- if inf ~= nil then
- -- check if sector > 9
- if inf >9 then
- srf1Panel = string.format("S%2d ", inf)
- else
- srf1Panel = string.format("S%1d ", inf)
- end
- end
- elseif swValue == 6 then
- -- total laps if available
- local tl = GetContextInfo("lapscount")
- if tl < 1 then tl = 0 end
- -- if more then 99 laps
- if tl >= 100 then
- srf1Panel = string.format("T%3d", tl)
- elseif tl >= 10 then
- srf1Panel = string.format("T%2d ", tl)
- else
- srf1Panel = string.format("T%1d ", tl)
- end
-
- elseif swValue == 7 then
- -- water temp
- inf = GetCarInfo("watertemp")
- if inf ~= nil then
- inf = GetTemp(inf, unit)
- srf1Panel = string.format("W%2.1f", inf)
- end
- elseif swValue == 8 then
- -- oil temp
- inf = GetCarInfo("oiltemp")
- if inf ~= nil then
- inf = GetTemp(inf, unit)
- srf1Panel = string.format("o%2.1f", inf)
- end
-
- elseif swValue == 9 then
- -- best lap time
- timeFlag = true
- lpt = GetTimeInfo("laptime")
-
- 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
- diffTimeFlag = 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
- diffTimeFlag = true
- timeFlag = true
- lpt = GetTimeInfo("realdiffbest")
-
- elseif swValue == 20 then
- -- real time diff vs your last
- diffTimeFlag = true
- timeFlag = true
- lpt = GetTimeInfo("realdifflast")
-
- elseif swValue == 21 then
- -- get an average consumption of fuel per lap and gives the remaining laps
- local remainintank = GetCarInfo("remainlapsintank")
- srf1Panel = string.format("L%3.0f", math.floor(remainintank) )
-
- elseif swValue == 22 then
- -- rpm
- isSlowUpdate = true
- --timeFlag = true
- local rpm = GetCarInfo("rpm")
- local r = rpm / 10.0
- if r < 1000 then
- srf1Panel = string.format("%3.1f", r)
- else
- srf1Panel = string.format("%4d.", round(r))
- end
- elseif swValue == 23 then
- -- track size
- isSlowUpdate = true
- --timeFlag = true
- local trcksz = GetContextInfo("tracksize")
- local r = trcksz / 10
- if r < 1000 then
- srf1Panel = string.format("%3.1f", r)
- else
- srf1Panel = string.format("%4d.", 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))
- srf1Panel = string.format("D%3d", p )
-
- elseif swValue == 25 then
- -- kers
- local kers = GetCarInfo("kers")
- srf1Panel = string.format("K%3d", round(kers/1000))
-
- elseif swValue == 26 then
- -- kers max
- local kmx = GetCarInfo("kersmax")
- srf1Panel = string.format("K%3d", round(kmx/1000))
-
- elseif swValue == 27 then
- -- drs
- local drs = GetCarInfo("drs")
- if drs == 1 then
- srf1Panel = "ON "
- else
- srf1Panel = "OFF"
- end
-
- elseif swValue == 28 then
- -- kers percent
- local kers = GetCarInfo("kers")
- srf1Panel = string.format("K%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
- srf1Panel = 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
- srf1Panel = 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
- srf1Panel = 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
- srf1Panel = string.format("%3.0f ", inf)
- end
-
- elseif swValue == 33 then
- -- wheels pressure if available
- inf = GetCarInfo("wheelpressfrontleft")
- if inf ~= nil then
- -- convert to psi
- srf1Panel = string.format("%2.1f ", inf / 6.88)
- end
-
- elseif swValue == 34 then
- inf = GetCarInfo("wheelpressfrontright")
- if inf ~= nil then
- srf1Panel = string.format("%2.1f ", inf / 6.88)
- end
-
- elseif swValue == 35 then
- inf = GetCarInfo("wheelpressrearleft")
- if inf ~= nil then
- srf1Panel = string.format("%2.1f ", inf / 6.88)
- end
-
- elseif swValue == 36 then
- inf = GetCarInfo("wheelpressrearright")
- if inf ~= nil then
- srf1Panel = 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
- srf1Panel = 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
- srf1Panel = 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
- srf1Panel = 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
- srf1Panel = string.format("%3.0f ", inf)
- end
-
- elseif swValue == 41 then
- -- time remaining if available
- lpt = GetTimeInfo("timeremaining")
- timeFlag = true
-
- elseif swValue == 42 then
- -- PC system time
- systemflag = true
- lpt = GetTimeInfo("systemtime")
- timeFlag = true
- --diffTimeFlag = true
- elseif swValue == 43 then
- -- time elapsed if available
- lpt = GetTimeInfo("timetotalelapsed")
- timeFlag = true
-
- elseif swValue == 44 then
- -- last sector 1, 2 and 3
- local sector = GetCarInfo("sector")
- timeFlag = true
- --diffTimeFlag = true
- if sector == 1 then
- -- sector 3
- local ls1 = GetTimeInfo("lastsector1")
- local ls2 = GetTimeInfo("lastsector2")
- local lt = GetTimeInfo("lastlaptime")
- if ls1 > 0 and ls2 > 0 then
- lpt = lt - (ls1 + ls2)
- end
- elseif sector == 2 then
- local ls1 = GetTimeInfo("lastsector1")
- lpt = ls1
- else
- -- sector 3
- local ls2 = GetTimeInfo("lastsector2")
- lpt = ls2
- end
-
- elseif swValue == 45 then
- -- PIT
- srf1Panel = "PIT "
-
- elseif swValue == 46 then
- -- sc
- local sc = GetContextInfo("safetycare")
- if sc == 1 then
- srf1Panel = "SCAR"
- else
- srf1Panel = "OFF "
- end
-
- elseif swValue == 47 then
- -- real time delta vs last + last sector diff 1, 2 and 3
- local sector = GetCarInfo("sector")
- timeFlag = true
- diffTimeFlag = true
- if mDiffSectorDelay == nil or mDiffOldSector == nil or mDiffOldSector ~= sector then
- -- 8s delay, increase it if needed
- mDiffSectorDelay = GetTicks() + 8000
- mDiffOldSector = sector
- end
- -- init backup vars
- if mOld_lt == nil then
- mOld_ls1 = 0.00000
- mOld_ls2 = 0.00000
- mOld_lt = 0.00000
- mDelta_lpt = 0.00000
- mDelta_lptb = 0.00000
- end
-
- -- display delta by default
- lpt = GetTimeInfo("realdifflast")
-
- if mDiffSectorDelay > GetTicks() then
- -- display sector
- if sector == 1 then
- -- sector 3
- --local ls1 = GetTimeInfo("lastsector1")
- --local ls2 = GetTimeInfo("lastsector2")
- local lt = GetTimeInfo("lastlaptime")
-
- --i-- delta sector 3f ls1 > 0 and ls2 > 0 and lt > 0 and mOld_ls1 > 0 and mOld_ls2 > 0 and mOld_lt > 0 then
- -- delta sector 3
- --lpt = (lt - (ls1 + ls2)) - (mOld_lt - (mOld_ls1 + mOld_ls2))
- if lt > 0 and mOld_lt > 0 then
- if lt ~= mOld_lt then
- mDelta_lpt = lt - mOld_lt
- print(mDelta_lpt, lt, mOld_lt)
- end
- lpt = mDelta_lpt
- end
-
- mOld_lt = lt
-
-
- elseif sector == 2 then
- -- sector 1
- local ls1 = GetTimeInfo("lastsector1")
- if ls1 > 0 and mOld_ls1 > 0 then
- lpt = ls1 - mOld_ls1
- end
- mOld_ls2 = GetTimeInfo("lastsector2")
- print(lpt, ls1 , mOld_ls1, mOld_ls2)
-
- else
- -- sector 2
- local ls2 = GetTimeInfo("lastsector2")
- if ls2 > 0 and mOld_ls2 > 0 then
- lpt = ls2 - mOld_ls2
- end
- mOld_ls1 = GetTimeInfo("lastsector1")
- print(lpt, ls2 , mOld_ls1, mOld_ls2)
- end
- end
-
- elseif swValue == 48 then
- -- real time delta vs best + last sector diff 1, 2 and 3
-
- -- get sector
- local sector = GetCarInfo("sector")
- -- set flags
- timeFlag = true
- diffTimeFlag = true
-
- -- set delay
- if mDiffSectorDelay == nil or mDiffOldSector == nil or mDiffOldSector ~= sector then
- -- 8s delay, increase it if needed
- mDiffSectorDelay = GetTicks() + 8000
- mDiffOldSector = sector
- end
-
- -- init backup vars
- if mOld_bt == nil then
- mOld_bs1 = 0.00000
- mOld_bs2 = 0.00000
- mOld_bt = 0.00000
- mDelta_lpt = 0.00000
- mDelta_lptb = 0.00000
- end
-
- -- display delta by default
- lpt = GetTimeInfo("realdiffbest")
-
- if mDiffSectorDelay > GetTicks() then
- -- display sector diff during delay
- if sector == 1 then
- -- sector 3
- --local bs1 = GetTimeInfo("bestsector1")
- --local bs2 = GetTimeInfo("bestsector2")
- local bt = GetTimeInfo("bestlaptime")
-
- --if bs1 > 0 and bs2 > 0 and bt > 0 and mOld_bs1 > 0 and mOld_bs2 > 0 and mOld_bt > 0 then
- -- delta sector 3
- -- lpt = (bt - (bs1 + bs2)) - (mOld_bt - (mOld_bs1 + mOld_bs2))
- if bt > 0 and mOld_bt > 0 then
- if bt ~= mOld_bt then
- mDelta_lptb = bt - mOld_bt
- print(mDelta_lpt, bt, mOld_bt)
- end
- lpt = mDelta_lptb
- end
-
- mOld_bt = bt
-
- elseif sector == 2 then
- -- sector 1
- local bs1 = GetTimeInfo("bestsector1")
- if bs1 > 0 and mOld_bs1 > 0 then
- lpt = bs1 - mOld_bs1
- end
- print(lpt, bs1 )
- mOld_bs2 = GetTimeInfo("bestsector2")
-
- else
- -- sector 2
- local bs2 = GetTimeInfo("bestsector2")
- if bs2 > 0 and mOld_bs2 > 0 then
- lpt = bs2 - mOld_bs2
- end
- print(lpt, bs2 )
- mOld_bs1 = GetTimeInfo("bestsector1")
- end
- end
-
- else
- srf1Panel = " "
- end
- -- check if diff time is ready
- local diffOK = GetTimeInfo("realdifftimeready")
- if diffTimeFlag and diffOK == false then
- diffTimeFlag = false
- timeFlag = false
- srf1Panel = "NPEF"
-
- mOld_ls1 = 0.00000
- mOld_ls2 = 0.00000
- mOld_lt = 0.00000
- mDelta_lpt = 0.00000
- mDelta_lptb = 0.00000
- end
-
- local c = ""
- local refreshRate = mRefreshLapTimeRate
- if diffTimeFlag then
- c = "+"
- refreshRate = mDeltaTimeDelay
- end
-
- if timeFlag and lpt ~= nil then
-
- -- set char of negative number
- if diffTimeFlag then
- if lpt < 0 then c = "-" end
- 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() > (refreshRate + mDeltaTimeOldTicks ) then
- mDeltaTimeOldTicks = GetTicks()
-
- if lpt == -1 or (mn + sc + ms) == 0.0000 then
- mDeltaTimeBackup = "-.---"
-
- elseif systemflag then
- mDeltaTimeBackup = string.format( "%2d.%02d", mn, sc)
-
- elseif mn > 9 then
- -- > 9mn
- if c == "" then
- mDeltaTimeBackup = string.format( "%2d.%2d", mn, sc)
- else
- mDeltaTimeBackup = string.format( "%s%2d ", c, mn)
- end
-
- elseif mn > 0 and mn < 10 then
- -- < 10mn
- if c == "" then
- mDeltaTimeBackup = string.format( "%1d.%02d.%01d", mn, sc, hd)
- else
- mDeltaTimeBackup = string.format( "%s%1d.%02d", c, mn, sc)
- end
-
- else
- -- sc > 9
- if sc > 9 then
- if c == "" then
- mDeltaTimeBackup = string.format( "0.%2d.%1d", sc, hd)
- else
- mDeltaTimeBackup = string.format( "%s%02d.%01d", c, sc, hd)
- end
-
- else
- -- sc < 0
- if c == "" then
- mDeltaTimeBackup = string.format( "0.%01d.%02d", sc, hd)
- else
- mDeltaTimeBackup = string.format( "%s%01d.%02d", c, sc, hd)
- end
-
- end
- end
- end
-
- --print(srf1Panel,mDeltaTimeBackup)
- srf1Panel = mDeltaTimeBackup
- end
-
- if isSlowUpdate then
-
- if GetTicks() > ( refreshRate + mDeltaTimeOldTicks ) then
- mDeltaTimeOldTicks = GetTicks()
- if side == 0 then
- mSRF1LeftText = srf1Panel
- else
- mSRF1RightText = srf1Panel
- end
- -- print(GetTicks() .. mSRF1RightText .."\n")
- end
- else
- if side == 0 then
- mSRF1LeftText = srf1Panel
- else
- mSRF1RightText = srf1Panel
- end
- end
-
- -- print(mSRF1LeftText, mSRF1RightText, srf1Panel)
- -- send string to sli manager
- if side == 0 then
- SetLeftDigits( mSRF1LeftText )
- else
- SetRightDigits( mSRF1RightText )
- end
-
- return 1
-end
+-- SIMRACE F1 Lua Script v1.1.3 +-- Copyright (c)2012-2013 by Zappadoc - All Rights Reserved. +-- this script builds all functions associated with +-- left and right panels of SIMRACE-F1 device +-- last change by Zappadoc - 2013-10 + +-- ============================================================ +-- Left and Right Panel functions +-- ============================================================ +function srf1LeftDigitsEvent(swFunction) + return srf1DigitsEvent(swFunction, 0) +end +function srf1RightDigitsEvent(swFunction) + return srf1DigitsEvent(swFunction, 1) +end +-- IN function of left panel +-- param: recieve from SLI Manager the current switch position +function srf1DigitsEvent(swFunction, side) + swValue = swFunction + 1 + + -- call custom script + if side == 0 then + local result = custom_srf1LeftDigitsEvent(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_srf1LeftDigitsEvent(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 + else + local result = custom_srf1RightDigitsEvent(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_srf1RightDigitsEvent(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 + end + + local hr = 0 + local mn = 0 + local sc = 0 + local ms = 0 + local hd = 0 + local lpt = 0.0 + local diffTimeFlag = false + local timeFlag = false + local systemflag = false + local unit = false + local inf = "" + local spd = 0.0 + local isSlowUpdate = false + local srf1Panel = "" + + -- 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") + + -- lap finished, display lap time a few seconds + local dlt = false + dlt = GetContextInfo("displaylaptime") + if dlt == nil then dlt = false end + if dlt and side == 1 and swValue ~= 47 and swValue ~= 48 then + swValue = 11 + end + + -- 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 left and right panel + local qiInf = 1 + if side == 0 then + qiInf = GetContextInfo("quickinfoleft") + else + qiInf = GetContextInfo("quickinforight") + end + if qiInf == nil then qiInf = 1 end + -- force position to match QI preference + swValue = qiInf + end + + -- check if PIT Feedback ON + local pf = false + pf = GetContextInfo("pitfeedback") + if pf == nil or pf == 0 then pf = false end + if pf then + -- force position to PIT/SPEED function if car pits + local pit = GetCarInfo("inpits") + if pit > 0 then + if side == 0 then + swValue = 45 + else + swValue = 1 + end + end + end + + -- get current simulation name + local sim = GetContextInfo("simulation") + + --print ( "swValue: " .. swValue .. "\n") + + -- check postion and compute left panel string + if swValue == 1 then + -- speed only + srf1Panel = string.format("%3.0f ", spd ) + + elseif swValue == 2 then + -- fuel + local fuel = GetCarInfo("fuel") + if fuel ~= nil then + fuel = GetFuel(fuel, unit) + if fuel >= 100 then + srf1Panel = string.format("F%3d", round(fuel)) + elseif fuel >= 10 then + srf1Panel = string.format("F%2d ", round(fuel)) + else + srf1Panel = string.format("F%1.1f ", fuel) + end + end + elseif swValue == 3 then + -- position + inf = GetContextInfo("position") + if inf ~= nil then + if inf >= 100 then + srf1Panel = string.format("P%3d", inf) + elseif inf >= 10 then + srf1Panel = string.format("P%2d ", inf) + else + srf1Panel = string.format("P%1d ", inf) + end + end + elseif swValue == 4 then + -- laps completed + inf = GetContextInfo("laps") + if inf ~= nil then + -- if more then 99 laps + if inf >= 100 then + srf1Panel = string.format("L%3d", inf) + elseif inf >= 10 then + srf1Panel = string.format("L%2d ", inf) + else + srf1Panel = string.format("L%1d ", inf) + end + end + elseif swValue == 5 then + -- sector + inf = GetCarInfo("sector") + if inf ~= nil then + -- check if sector > 9 + if inf >9 then + srf1Panel = string.format("S%2d ", inf) + else + srf1Panel = string.format("S%1d ", inf) + end + end + elseif swValue == 6 then + -- total laps if available + local tl = GetContextInfo("lapscount") + if tl < 1 then tl = 0 end + -- if more then 99 laps + if tl >= 100 then + srf1Panel = string.format("T%3d", tl) + elseif tl >= 10 then + srf1Panel = string.format("T%2d ", tl) + else + srf1Panel = string.format("T%1d ", tl) + end + + elseif swValue == 7 then + -- water temp + inf = GetCarInfo("watertemp") + if inf ~= nil then + inf = GetTemp(inf, unit) + srf1Panel = string.format("W%2.1f", inf) + end + elseif swValue == 8 then + -- oil temp + inf = GetCarInfo("oiltemp") + if inf ~= nil then + inf = GetTemp(inf, unit) + srf1Panel = string.format("o%2.1f", inf) + end + + elseif swValue == 9 then + -- best lap time + timeFlag = true + lpt = GetTimeInfo("laptime") + + 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 + diffTimeFlag = 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 + diffTimeFlag = true + timeFlag = true + lpt = GetTimeInfo("realdiffbest") + + elseif swValue == 20 then + -- real time diff vs your last + diffTimeFlag = true + timeFlag = true + lpt = GetTimeInfo("realdifflast") + + elseif swValue == 21 then + -- get an average consumption of fuel per lap and gives the remaining laps + local remainintank = GetCarInfo("remainlapsintank") + srf1Panel = string.format("L%3.0f", math.floor(remainintank) ) + + elseif swValue == 22 then + -- rpm + isSlowUpdate = true + --timeFlag = true + local rpm = GetCarInfo("rpm") + local r = rpm / 10.0 + if r < 1000 then + srf1Panel = string.format("%3.1f", r) + else + srf1Panel = string.format("%4d.", round(r)) + end + elseif swValue == 23 then + -- track size + isSlowUpdate = true + --timeFlag = true + local trcksz = GetContextInfo("tracksize") + local r = trcksz / 10 + if r < 1000 then + srf1Panel = string.format("%3.1f", r) + else + srf1Panel = string.format("%4d.", 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)) + srf1Panel = string.format("D%3d", p ) + + elseif swValue == 25 then + -- kers + local kers = GetCarInfo("kers") + srf1Panel = string.format("K%3d", round(kers/1000)) + + elseif swValue == 26 then + -- kers max + local kmx = GetCarInfo("kersmax") + srf1Panel = string.format("K%3d", round(kmx/1000)) + + elseif swValue == 27 then + -- drs + local drs = GetCarInfo("drs") + if drs == 1 then + srf1Panel = "ON " + else + srf1Panel = "OFF" + end + + elseif swValue == 28 then + -- kers percent + local kers = GetCarInfo("kers") + srf1Panel = string.format("K%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 + srf1Panel = 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 + srf1Panel = 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 + srf1Panel = 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 + srf1Panel = string.format("%3.0f ", inf) + end + + elseif swValue == 33 then + -- wheels pressure if available + inf = GetCarInfo("wheelpressfrontleft") + if inf ~= nil then + -- convert to psi + srf1Panel = string.format("%2.1f ", inf / 6.88) + end + + elseif swValue == 34 then + inf = GetCarInfo("wheelpressfrontright") + if inf ~= nil then + srf1Panel = string.format("%2.1f ", inf / 6.88) + end + + elseif swValue == 35 then + inf = GetCarInfo("wheelpressrearleft") + if inf ~= nil then + srf1Panel = string.format("%2.1f ", inf / 6.88) + end + + elseif swValue == 36 then + inf = GetCarInfo("wheelpressrearright") + if inf ~= nil then + srf1Panel = 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 + srf1Panel = 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 + srf1Panel = 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 + srf1Panel = 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 + srf1Panel = string.format("%3.0f ", inf) + end + + elseif swValue == 41 then + -- time remaining if available + lpt = GetTimeInfo("timeremaining") + timeFlag = true + + elseif swValue == 42 then + -- PC system time + systemflag = true + lpt = GetTimeInfo("systemtime") + timeFlag = true + --diffTimeFlag = true + elseif swValue == 43 then + -- time elapsed if available + lpt = GetTimeInfo("timetotalelapsed") + timeFlag = true + + elseif swValue == 44 then + -- last sector 1, 2 and 3 + local sector = GetCarInfo("sector") + timeFlag = true + --diffTimeFlag = true + if sector == 1 then + -- sector 3 + local ls1 = GetTimeInfo("lastsector1") + local ls2 = GetTimeInfo("lastsector2") + local lt = GetTimeInfo("lastlaptime") + if ls1 > 0 and ls2 > 0 then + lpt = lt - (ls1 + ls2) + end + elseif sector == 2 then + local ls1 = GetTimeInfo("lastsector1") + lpt = ls1 + else + -- sector 3 + local ls2 = GetTimeInfo("lastsector2") + lpt = ls2 + end + + elseif swValue == 45 then + -- PIT + srf1Panel = "PIT " + + elseif swValue == 46 then + -- sc + local sc = GetContextInfo("safetycare") + if sc == 1 then + srf1Panel = "SCAR" + else + srf1Panel = "OFF " + end + + elseif swValue == 47 then + -- real time delta vs last + last sector diff 1, 2 and 3 + local sector = GetCarInfo("sector") + timeFlag = true + diffTimeFlag = true + if mDiffSectorDelay == nil or mDiffOldSector == nil or mDiffOldSector ~= sector then + -- 8s delay, increase it if needed + mDiffSectorDelay = GetTicks() + 8000 + mDiffOldSector = sector + end + -- init backup vars + if mOld_lt == nil then + mOld_ls1 = 0.00000 + mOld_ls2 = 0.00000 + mOld_lt = 0.00000 + mDelta_lpt = 0.00000 + mDelta_lptb = 0.00000 + end + + -- display delta by default + lpt = GetTimeInfo("realdifflast") + + if mDiffSectorDelay > GetTicks() then + -- display sector + if sector == 1 then + -- sector 3 + --local ls1 = GetTimeInfo("lastsector1") + --local ls2 = GetTimeInfo("lastsector2") + local lt = GetTimeInfo("lastlaptime") + + --i-- delta sector 3f ls1 > 0 and ls2 > 0 and lt > 0 and mOld_ls1 > 0 and mOld_ls2 > 0 and mOld_lt > 0 then + -- delta sector 3 + --lpt = (lt - (ls1 + ls2)) - (mOld_lt - (mOld_ls1 + mOld_ls2)) + if lt > 0 and mOld_lt > 0 then + if lt ~= mOld_lt then + mDelta_lpt = lt - mOld_lt + print(mDelta_lpt, lt, mOld_lt) + end + lpt = mDelta_lpt + end + + mOld_lt = lt + + + elseif sector == 2 then + -- sector 1 + local ls1 = GetTimeInfo("lastsector1") + if ls1 > 0 and mOld_ls1 > 0 then + lpt = ls1 - mOld_ls1 + end + mOld_ls2 = GetTimeInfo("lastsector2") + print(lpt, ls1 , mOld_ls1, mOld_ls2) + + else + -- sector 2 + local ls2 = GetTimeInfo("lastsector2") + if ls2 > 0 and mOld_ls2 > 0 then + lpt = ls2 - mOld_ls2 + end + mOld_ls1 = GetTimeInfo("lastsector1") + print(lpt, ls2 , mOld_ls1, mOld_ls2) + end + end + + elseif swValue == 48 then + -- real time delta vs best + last sector diff 1, 2 and 3 + + -- get sector + local sector = GetCarInfo("sector") + -- set flags + timeFlag = true + diffTimeFlag = true + + -- set delay + if mDiffSectorDelay == nil or mDiffOldSector == nil or mDiffOldSector ~= sector then + -- 8s delay, increase it if needed + mDiffSectorDelay = GetTicks() + 8000 + mDiffOldSector = sector + end + + -- init backup vars + if mOld_bt == nil then + mOld_bs1 = 0.00000 + mOld_bs2 = 0.00000 + mOld_bt = 0.00000 + mDelta_lpt = 0.00000 + mDelta_lptb = 0.00000 + end + + -- display delta by default + lpt = GetTimeInfo("realdiffbest") + + if mDiffSectorDelay > GetTicks() then + -- display sector diff during delay + if sector == 1 then + -- sector 3 + --local bs1 = GetTimeInfo("bestsector1") + --local bs2 = GetTimeInfo("bestsector2") + local bt = GetTimeInfo("bestlaptime") + + --if bs1 > 0 and bs2 > 0 and bt > 0 and mOld_bs1 > 0 and mOld_bs2 > 0 and mOld_bt > 0 then + -- delta sector 3 + -- lpt = (bt - (bs1 + bs2)) - (mOld_bt - (mOld_bs1 + mOld_bs2)) + if bt > 0 and mOld_bt > 0 then + if bt ~= mOld_bt then + mDelta_lptb = bt - mOld_bt + print(mDelta_lpt, bt, mOld_bt) + end + lpt = mDelta_lptb + end + + mOld_bt = bt + + elseif sector == 2 then + -- sector 1 + local bs1 = GetTimeInfo("bestsector1") + if bs1 > 0 and mOld_bs1 > 0 then + lpt = bs1 - mOld_bs1 + end + print(lpt, bs1 ) + mOld_bs2 = GetTimeInfo("bestsector2") + + else + -- sector 2 + local bs2 = GetTimeInfo("bestsector2") + if bs2 > 0 and mOld_bs2 > 0 then + lpt = bs2 - mOld_bs2 + end + print(lpt, bs2 ) + mOld_bs1 = GetTimeInfo("bestsector1") + end + end + + else + srf1Panel = " " + end + -- check if diff time is ready + local diffOK = GetTimeInfo("realdifftimeready") + if diffTimeFlag and diffOK == false then + diffTimeFlag = false + timeFlag = false + srf1Panel = "NPEF" + + mOld_ls1 = 0.00000 + mOld_ls2 = 0.00000 + mOld_lt = 0.00000 + mDelta_lpt = 0.00000 + mDelta_lptb = 0.00000 + end + + local c = "" + local refreshRate = mRefreshLapTimeRate + if diffTimeFlag then + c = "+" + refreshRate = mDeltaTimeDelay + end + + if timeFlag and lpt ~= nil then + + -- set char of negative number + if diffTimeFlag then + if lpt < 0 then c = "-" end + 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() > (refreshRate + mDeltaTimeOldTicks ) then + mDeltaTimeOldTicks = GetTicks() + + if lpt == -1 or (mn + sc + ms) == 0.0000 then + mDeltaTimeBackup = "-.---" + + elseif systemflag then + mDeltaTimeBackup = string.format( "%2d.%02d", mn, sc) + + elseif mn > 9 then + -- > 9mn + if c == "" then + mDeltaTimeBackup = string.format( "%2d.%2d", mn, sc) + else + mDeltaTimeBackup = string.format( "%s%2d ", c, mn) + end + + elseif mn > 0 and mn < 10 then + -- < 10mn + if c == "" then + mDeltaTimeBackup = string.format( "%1d.%02d.%01d", mn, sc, hd) + else + mDeltaTimeBackup = string.format( "%s%1d.%02d", c, mn, sc) + end + + else + -- sc > 9 + if sc > 9 then + if c == "" then + mDeltaTimeBackup = string.format( "0.%2d.%1d", sc, hd) + else + mDeltaTimeBackup = string.format( "%s%02d.%01d", c, sc, hd) + end + + else + -- sc < 0 + if c == "" then + mDeltaTimeBackup = string.format( "0.%01d.%02d", sc, hd) + else + mDeltaTimeBackup = string.format( "%s%01d.%02d", c, sc, hd) + end + + end + end + end + + --print(srf1Panel,mDeltaTimeBackup) + srf1Panel = mDeltaTimeBackup + end + + if isSlowUpdate then + + if GetTicks() > ( refreshRate + mDeltaTimeOldTicks ) then + mDeltaTimeOldTicks = GetTicks() + if side == 0 then + mSRF1LeftText = srf1Panel + else + mSRF1RightText = srf1Panel + end + -- print(GetTicks() .. mSRF1RightText .."\n") + end + else + if side == 0 then + mSRF1LeftText = srf1Panel + else + mSRF1RightText = srf1Panel + end + end + + -- print(mSRF1LeftText, mSRF1RightText, srf1Panel) + -- send string to sli manager + if side == 0 then + SetLeftDigits( mSRF1LeftText ) + else + SetRightDigits( mSRF1RightText ) + end + + return 1 +end diff --git a/scripts/simracef1_iracing.lua b/scripts/simracef1_iracing.lua index e50287c..0f1e693 100644 --- a/scripts/simracef1_iracing.lua +++ b/scripts/simracef1_iracing.lua @@ -1,11 +1,11 @@ --- iRacing Custom Scripts - SLIMax Manager Scripts v1.9
--- Copyright ©2011-2013 by Zappadoc - All Rights Reserved.
--- last change by Zappadoc - 2013-08
-
--- ================================
--- 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
+-- iRacing Custom Scripts - SLIMax Manager Scripts v1.9 +-- Copyright ©2011-2013 by Zappadoc - All Rights Reserved. +-- last change by Zappadoc - 2013-08 + +-- ================================ +-- 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/slidevice.lua b/scripts/slidevice.lua index 2f05552..a5ef3de 100644 --- a/scripts/slidevice.lua +++ b/scripts/slidevice.lua @@ -1,30 +1,30 @@ --- Load SLIMax Mgr Lua Scripts v3.3
--- Copyright (c)2012-2013 by Zappadoc - All Rights Reserved.
--- changed by Zappadoc - 2013-09
--- main device script, do not modify this script
-
-require "scripts/led"
-require "scripts/enter_exit_session"
-require "scripts/gear"
-require "scripts/simracef1"
-require "scripts/simracedlx"
-require "scripts/fanatec"
-require "scripts/slipro"
-require "scripts/shiftlights"
-require "scripts/speedlimiter"
-require "scripts/osp"
-require "scripts/controls"
-require "scripts/devhook"
-require "scripts/global_custom_scripts"
-require "scripts/custom_events"
-
--- load the custom scripts if exists
-scr = GetCustomScripts("scriptname")
--- print ( scr )
-if scr ~= nil and scr ~= "" then
- mCustomScriptsFileName = scr
- require(mCustomScriptsFileName)
- custom_initEvent(scr)
-end
-
-
+-- Load SLIMax Mgr Lua Scripts v3.3 +-- Copyright (c)2012-2013 by Zappadoc - All Rights Reserved. +-- changed by Zappadoc - 2013-09 +-- main device script, do not modify this script + +require "scripts/led" +require "scripts/enter_exit_session" +require "scripts/gear" +require "scripts/simracef1" +require "scripts/simracedlx" +require "scripts/fanatec" +require "scripts/slipro" +require "scripts/shiftlights" +require "scripts/speedlimiter" +require "scripts/osp" +require "scripts/controls" +require "scripts/devhook" +require "scripts/global_custom_scripts" +require "scripts/custom_events" + +-- load the custom scripts if exists +scr = GetCustomScripts("scriptname") +-- print ( scr ) +if scr ~= nil and scr ~= "" then + mCustomScriptsFileName = scr + require(mCustomScriptsFileName) + custom_initEvent(scr) +end + + diff --git a/scripts/sliemu_iracing.lua b/scripts/sliemu_iracing.lua index 2d5b5ba..f1a9c06 100644 --- a/scripts/sliemu_iracing.lua +++ b/scripts/sliemu_iracing.lua @@ -1,11 +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
+-- 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 index 2d5b5ba..f1a9c06 100644 --- a/scripts/slim_iracing.lua +++ b/scripts/slim_iracing.lua @@ -1,11 +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
+-- 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/slipro.lua b/scripts/slipro.lua index df4833c..431f836 100644 --- a/scripts/slipro.lua +++ b/scripts/slipro.lua @@ -1,865 +1,865 @@ --- SLIPRO Lua Script v3.3.2
--- Copyright (c)2012-2013 by Zappadoc - All Rights Reserved.
--- this script builds all functions associated with
--- left and right panels of SLIPRO device
--- last change by Zappadoc - 2013-09
-
--- ============================================================
--- Left and Right Panel functions
--- ============================================================
-
--- IN function of left panel
--- param: recieve from SLI Manager the current switch position
-function leftDigitsEvent(swFunction)
- swValue = swFunction + 1
- -- call custom script
- local result = custom_leftDigitsEvent(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_leftDigitsEvent(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 lPanel = ""
- local inf = ""
- local unit = false
- local spd = 0.0
- -- 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 left panel
- local qiLeft = GetContextInfo("quickinfoleft")
- if qiLeft == nil then qiLeft = 1 end
- -- force position to match QI preference
- swValue = qiLeft
- end
-
- -- check if PIT Feedback ON
- local pf = false
- pf = GetContextInfo("pitfeedback")
- if pf == nil or pf == 0 then pf = false end
- if pf then
- -- force position to PIT/SPEED function if car pits
- local pit = GetCarInfo("inpits")
- if pit > 0 then
- swValue = 35
- end
- end
-
- -- get current simulation name
- local sim = GetContextInfo("simulation")
-
- --print ( "swValue: " .. swValue .. "\n")
-
- -- check postion and compute left panel string
- if swValue == 1 then
- -- speed only
- lPanel = string.format(" %3.0f ", spd )
-
- elseif swValue == 2 then
- -- fuel:speed
- local fuel = GetCarInfo("fuel")
- if fuel ~= nil then
- fuel = GetFuel(fuel, unit)
- if fuel >= 100 then
- lPanel = string.format("%03d:%3d", round(fuel), spd)
- elseif fuel >= 10 then
- lPanel = string.format("F%02d:%3d", round(fuel), spd)
- else
- lPanel = string.format("F%1.1f:%3d", fuel, spd)
- end
- end
- elseif swValue == 3 then
- -- position:speed
- inf = GetContextInfo("position")
- if inf ~= nil then
- if inf >= 100 then
- lPanel = string.format("%03d:%3.0f", inf, spd)
- else
- lPanel = string.format("P%02d:%3.0f", inf, spd)
- end
- end
- elseif swValue == 4 then
- -- laps completed:speed
- inf = GetContextInfo("laps")
- if inf ~= nil then
- -- if more then 99 laps
- if inf >= 100 then
- lPanel = string.format("%03d:%3.0f", inf, spd)
- else
- lPanel = string.format("L%02d:%3.0f", inf, spd)
- end
- end
- elseif swValue == 5 then
- -- sector:speed
- inf = GetCarInfo("sector")
- if inf ~= nil then
- -- check if sector > 9
- if inf >9 then
- lPanel = string.format("S%02d:%3.0f", inf, spd)
- else
- lPanel = string.format("S%01d :%3.0f", inf, spd)
- end
- end
- elseif swValue == 6 then
- -- laps completed:total laps if available
- inf = GetContextInfo("laps")
- if inf ~= nil then
- local tl = GetContextInfo("lapscount")
- if tl < 1 then tl = 0 end
- -- if more then 99 laps
- if inf >= 100 or tl >= 100 then
- lPanel = string.format("%03d:%03d", inf, tl)
- else
- lPanel = string.format("L%02d:t%02d", inf, tl)
- end
- end
- elseif swValue == 7 then
- -- water temp
- inf = GetCarInfo("watertemp")
- if inf ~= nil then
- inf = GetTemp(inf, unit)
- lPanel = string.format("H2o:%2.1f", inf)
- end
- elseif swValue == 8 then
- -- oil temp
- inf = GetCarInfo("oiltemp")
- if inf ~= nil then
- inf = GetTemp(inf, unit)
- lPanel = string.format("OIL:%2.1f", inf)
- end
-
- elseif swValue == 9 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
- lPanel = string.format("tFL:%3.0f", inf)
- end
- elseif swValue == 10 then
- inf = GetCarInfo("wheeltempfrontright")
- if inf ~= nil then
- if isAppRFactor(sim) then inf = KtoC(inf) end
- lPanel = string.format("tFr:%3.0f", inf)
- end
- elseif swValue == 11 then
- inf = GetCarInfo("wheeltemprearleft")
- if inf ~= nil then
- if isAppRFactor(sim) then inf = KtoC(inf) end
- lPanel = string.format("trL:%3.0f", inf)
- end
- elseif swValue == 12 then
- inf = GetCarInfo("wheeltemprearright")
- if inf ~= nil then
- if isAppRFactor(sim) then inf = KtoC(inf) end
- lPanel = string.format("trr:%3.0f", inf)
- end
-
- elseif swValue == 13 then
- -- wheels pressure if available
- inf = GetCarInfo("wheelpressfrontleft")
- if inf ~= nil then
- -- convert to psi
- lPanel = string.format("PFL:%2.1f", inf / 6.88)
- end
- elseif swValue == 14 then
- inf = GetCarInfo("wheelpressfrontright")
- if inf ~= nil then
- lPanel = string.format("PFr:%2.1f", inf / 6.88)
- end
- elseif swValue == 15 then
- inf = GetCarInfo("wheelpressrearleft")
- if inf ~= nil then
- lPanel = string.format("PrL:%2.1f", inf / 6.88)
- end
- elseif swValue == 16 then
- inf = GetCarInfo("wheelpressrearright")
- if inf ~= nil then
- lPanel = string.format("Prr:%2.1f", inf / 6.88)
- end
-
- elseif swValue == 17 then
- -- brakes temp if available
- inf = GetCarInfo("braketempfrontleft")
- if inf ~= nil then
- if isAppRFactor(sim) or sim == "GTR2.exe" then inf = KtoC(inf) end
- lPanel = string.format("BFL:%3.0f", inf)
- end
- elseif swValue == 18 then
- inf = GetCarInfo("braketempfrontright")
- if inf ~= nil then
- if isAppRFactor(sim) or sim == "GTR2.exe" then inf = KtoC(inf) end
- lPanel = string.format("BFr:%3.0f", inf)
- end
- elseif swValue == 19 then
- inf = GetCarInfo("braketemprearleft")
- if inf ~= nil then
- if isAppRFactor(sim) or sim == "GTR2.exe" then inf = KtoC(inf) end
- lPanel = string.format("BrL:%3.0f", inf)
- end
- elseif swValue == 20 then
- inf = GetCarInfo("braketemprearright")
- if inf ~= nil then
- if isAppRFactor(sim) or sim == "GTR2.exe" then inf = KtoC(inf) end
- lPanel = string.format("Brr:%3.0f", inf)
- end
- elseif swValue == 21 then
- -- position
- local pos = GetContextInfo("position")
- lPanel = string.format(" P%02d ", pos )
-
- elseif swValue == 22 then
- -- get an average consumption of fuel per lap and gives the remaining laps
- local remainintank = GetCarInfo("remainlapsintank")
- lPanel = string.format(" FL%3.0f", math.floor(remainintank) )
-
- elseif swValue == 23 then
- -- rpm
- local rpm = GetCarInfo("rpm")
- lPanel = string.format("%5d ", rpm)
-
- elseif swValue == 24 then
- -- track size
- local trcksz = GetContextInfo("tracksize")
- lPanel = string.format("%5d ", trcksz)
-
- elseif swValue == 25 then
- -- 25.fuel
- local fuel = GetCarInfo("fuel")
- if fuel ~= nil then
- fuel = GetFuel(fuel, unit)
- if fuel >= 100 then
- lPanel = string.format(" F%03d ", round(fuel))
- elseif fuel >= 10 then
- lPanel = string.format(" F%02d ", round(fuel))
- else
- lPanel = string.format(" F%1.1f ", fuel)
- end
- end
-
- elseif swValue == 26 then
- -- 26.distance
- local dist = GetContextInfo("lapdistance")
- lPanel = string.format(" %5d", dist )
-
- elseif swValue == 27 then
- --27.lap completed
- local laps = GetContextInfo("laps")
- lPanel = string.format(" %3d ", laps )
-
- elseif swValue == 28 then
- --28.total laps
- local lpcnt = GetContextInfo("lapscount")
- lPanel = string.format(" %3d ", lpcnt )
-
- elseif swValue == 29 then
- --29.sector
- local sect = GetCarInfo("sector")
- -- check if sector > 9
- if sect >9 then
- lPanel = string.format(" S%02d ", sect)
- else
- lPanel = string.format(" S%01d ", sect)
- end
-
- elseif swValue == 30 then
- --30.kers
- local kers = GetCarInfo("kers")
- lPanel = string.format(" E:%3d", round(kers/1000))
-
- elseif swValue == 31 then
- --31.kers max
- local kmx = GetCarInfo("kersmax")
- lPanel = string.format(" E:%03d", round(kmx/1000))
-
- elseif swValue == 32 then
- --32.drs
- local drs = GetCarInfo("drs")
- if drs == 1 then
- lPanel = "DrS:ON "
- else
- lPanel = "DrS:OFF"
- end
-
- elseif swValue == 33 then
- --33.kers percent
- local kers = GetCarInfo("kers")
- lPanel = string.format(" E:%3d", round((kers/1000)/4))
-
- elseif swValue == 34 then
- --33.kers percent:speed
- local kers = GetCarInfo("kers")
- lPanel = string.format("%3d:%3.0f", round((kers/1000)/4), spd)
-
- elseif swValue == 35 then
- -- PIT
- lPanel = " PIt "
-
- elseif swValue == 36 then
- -- sc
- local sc = GetContextInfo("safetycare")
- if sc == 1 then
- lPanel = " SCAR "
- else
- lPanel = " OFF "
- end
-
- else
- lPanel = "-:--.---"
- end
- -- send string to sli manager
- SetLeftDigits( lPanel )
- return 1
-end
-
--- IN function of right panel
--- param: recieve from SLI Manager the current switch position
-function rightDigitsEvent(swFunction)
- swValue = swFunction + 1
- -- call custom script
- local result = custom_rightDigitsEvent(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_rightDigitsEvent(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 rPanel = ""
- local lpt = 0.0
- local diffFlag = false
- local unit = false
-
- -- is OSP Tracking ON
- local ospt = false
- ospt = GetContextInfo("osptracking")
- if ospt == nil then ospt = false end
- if ospt then
- swValue = 23
- end
-
- -- lap finished, display lap time a few seconds
- local dlt = false
- dlt = GetContextInfo("displaylaptime")
- if dlt == nil then dlt = false end
- if dlt and swValue ~= 37 and swValue ~= 38 then
- swValue = 3
- end
-
- -- 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 right panel
- local qiRight = GetContextInfo("quickinforight")
- if qiRight == nil then qiRight = 1 end
- swValue = qiRight
- end
- -- get current display unit metric or imperial
- unit = GetContextInfo("speedmetric")
-
- -- check if PIT Feedback ON
- local pf = false
- pf = GetContextInfo("pitfeedback")
- if pf == nil or pf == 0 then pf = false end
- if pf then
- -- force position to SPEED function
- local pit = GetCarInfo("inpits")
- if pit > 0 then
- swValue = 20
- end
- end
-
- --print ( "swValue: " .. swValue .. "\n")
-
- -- get sim name
- local sim = GetContextInfo("simulation")
- if sim ~= nil then
- if swValue == 1 then
- -- current lap time
- lpt = GetTimeInfo("laptime")
- elseif swValue == 2 then
- -- best lap time (PB)
- lpt = GetTimeInfo("bestlaptime")
- elseif swValue == 3 then
- -- last lap time
- lpt = GetTimeInfo("lastlaptime")
-
- elseif swValue >= 4 and swValue <= 10 and isAppIRacing(sim) then
- -- iRacing partials
- local ts = GetContextInfo("partialcount")
- local sector = GetCarInfo("sector")
- if ts ~= nil and ts > 0 then
- if swValue == 4 then
- lpt = GetPartialTimeInfo("currentpartial", sector)
- elseif swValue == 5 then
- diffFlag = true
- lpt = GetPartialTimeInfo("vsbestlap", sector)
- elseif swValue == 6 then
- diffFlag = true
- lpt = GetPartialTimeInfo("vsoptimallap", sector)
- elseif swValue == 7 then
- diffFlag = true
- lpt = GetPartialTimeInfo("vsoptimalsector", sector)
- elseif swValue == 8 then
- diffFlag = true
- lpt = GetPartialTimeInfo("vssessionbestlap", sector)
- elseif swValue == 9 then
- diffFlag = true
- lpt = GetPartialTimeInfo("vssessionoptimallap", sector)
- elseif swValue == 10 then
- diffFlag = true
- lpt = GetPartialTimeInfo("vssessionoptimalsector", sector)
- end
- else
- lpt = 0.0
- end
-
- elseif swValue == 11 then
- -- real time diff vs your best
- diffFlag = true
- lpt = GetTimeInfo("realdiffbest")
-
- elseif swValue == 12 then
- -- real time diff vs your last
- diffFlag = true
- lpt = GetTimeInfo("realdifflast")
-
- elseif swValue == 13 then
- -- current sector
- local sector = GetCarInfo("sector")
- if sector == 1 then
- lpt = GetTimeInfo("sector1")
- elseif sector == 2 then
- lpt = GetTimeInfo("sector2")
- else
- -- sector 3
- local s1 = GetTimeInfo("sector1")
- local s2 = GetTimeInfo("sector2")
- local lt = GetTimeInfo("laptime")
- lpt = lt - (s1 + s2)
- end
- elseif swValue == 14 then
- -- best sector 1
- lpt = GetTimeInfo("bestsector1")
- elseif swValue == 15 then
- -- best sector 2
- lpt = GetTimeInfo("bestsector2")
- elseif swValue == 16 then
- -- last sector 1
- lpt = GetTimeInfo("lastsector1")
- elseif swValue == 17 then
- -- last sector 2
- lpt = GetTimeInfo("lastsector2")
- elseif swValue == 18 then
- -- position
- local pos = GetContextInfo("position")
- if pos >= 100 then
- rPanel = string.format(" P%03d ", pos )
- else
- rPanel = string.format(" P%02d ", pos )
- end
- SetRightDigits( rPanel )
- return 1
- elseif swValue == 19 then
- -- get an average consumption of fuel per lap and gives the remaining laps
- local remainintank = GetCarInfo("remainlapsintank")
- rPanel = string.format(" FL%3.0f", math.floor(remainintank) )
-
- elseif swValue == 20 then
- -- speed on right panel
- local spd = GetCarInfo("speed")
- rPanel = string.format(" %3d ", spd )
- SetRightDigits( rPanel )
- return 1
-
- elseif swValue == 21 then
- -- time remaining if available
- lpt = GetTimeInfo("timeremaining")
-
- -- explod time
- hr, mn, sc, hd, ms = timeDispatcher(lpt)
- if hr > 0 then
- rPanel = string.format( "%02dh%02d ", hr, mn)
- else
- rPanel = string.format( " %02d.%02d ", mn, sc)
- end
- SetRightDigits( rPanel )
- return 1
-
- elseif swValue == 22 then
- -- PC system time
- lpt = GetTimeInfo("systemtime")
- -- explod time
- hr, mn, sc, hd, ms = timeDispatcher(lpt)
- rPanel = string.format( " %02d.%02d ", hr, mn)
- SetRightDigits( rPanel )
- return 1
-
- elseif swValue == 23 then
- -- rpm:gear
- local rpm = GetCarInfo("rpm")
- if rpm == nil then
- return 1
- end
- local gear = GetCarInfo("gear")
- if gear ~= nil then
- rPanel = string.format("%5d:%d", rpm, gear)
- SetRightDigits( rPanel )
- end
- return 1
-
- elseif swValue == 24 then
- -- time elapsed if available
- lpt = GetTimeInfo("timetotalelapsed")
-
- -- explod time
- hr, mn, sc, hd, ms = timeDispatcher(lpt)
- if hr > 0 then
- rPanel = string.format( "%02dh%02d ", hr, mn)
- else
- rPanel = string.format( " %02d.%02d ", mn, sc)
- end
- SetRightDigits( rPanel )
- return 1
- elseif swValue == 25 then
- -- 25.fuel
- local fuel = GetCarInfo("fuel")
- if fuel ~= nil then
- fuel = GetFuel(fuel, unit)
- if fuel >= 100 then
- rPanel = string.format(" F%03d ", round(fuel))
- elseif fuel >= 10 then
- rPanel = string.format(" F%02d ", round(fuel))
- else
- rPanel = string.format(" F%1.1f ", fuel)
- end
-
- SetRightDigits( rPanel )
- return 1
- end
-
- elseif swValue == 26 then
- -- 26.distance
- local dist = GetContextInfo("lapdistance")
- rPanel = string.format(" %5d", dist )
- SetRightDigits( rPanel )
- return 1
-
- elseif swValue == 27 then
- --27.lap completed
- local laps = GetContextInfo("laps")
- rPanel = string.format(" %3d ", laps )
- SetRightDigits( rPanel )
- return 1
-
- elseif swValue == 28 then
- --28.total laps
- local lpcnt = GetContextInfo("lapscount")
- rPanel = string.format(" %3d ", lpcnt )
- SetRightDigits( rPanel )
- return 1
-
- elseif swValue == 29 then
- --29.sector
- local sect = GetCarInfo("sector")
- -- check if sector > 9
- if sect >9 then
- rPanel = string.format(" S%02d ", sect)
- else
- rPanel = string.format(" S%01d ", sect)
- end
- SetRightDigits( rPanel )
- return 1
-
- elseif swValue == 30 then
- --30.kers
- local kers = GetCarInfo("kers")
- rPanel = string.format(" E%03d ", round(kers/1000) )
- SetRightDigits( rPanel )
- return 1
-
- elseif swValue == 31 then
- --31.kers max
- local kmx = GetCarInfo("kersmax")
- rPanel = string.format(" E%03d ", round(kmx/1000) )
- SetRightDigits( rPanel )
- return 1
-
- elseif swValue == 32 then
- --32.drs
- rPanel = "DrS.OFF"
- local drs = GetCarInfo("drs")
- if drs >= 1 then
- rPanel = "DrS. ON"
- end
- SetRightDigits( rPanel )
- return 1
-
- elseif swValue == 33 then
- --33.kers percent
- local kers = GetCarInfo("kers")
- rPanel = string.format(" %3d ", round((kers/1000)/4))
- SetRightDigits( rPanel )
- return 1
-
- elseif swValue == 34 then
- --34 track size
- local trcksz = GetContextInfo("tracksize")
- rPanel = string.format("%5d ", trcksz)
- SetRightDigits( rPanel )
- return 1
-
- elseif swValue == 35 then
- --35 last sector 1, 2 and 3
- local sector = GetCarInfo("sector")
- if sector == 1 then
- -- sector 3
- local ls1 = GetTimeInfo("lastsector1")
- local ls2 = GetTimeInfo("lastsector2")
- local lt = GetTimeInfo("lastlaptime")
- if ls1 > 0 and ls2 > 0 then
- lpt = lt - (ls1 + ls2)
- end
- elseif sector == 2 then
- local ls1 = GetTimeInfo("lastsector1")
- lpt = ls1
- else
- -- sector 3
- local ls2 = GetTimeInfo("lastsector2")
- lpt = ls2
- end
-
- elseif swValue == 36 then
- --36.rpm
- local rpm = GetCarInfo("rpm")
- rPanel = string.format("%5d ", rpm)
- SetRightDigits( rPanel )
- return 1
-
- elseif swValue == 37 then
- -- real time delta vs last + last sector diff 1, 2 and 3
- local sector = GetCarInfo("sector")
- diffFlag = true
- if mDiffSectorDelay == nil or mDiffOldSector == nil or mDiffOldSector ~= sector then
- -- 8s delay, increase it if needed
- mDiffSectorDelay = GetTicks() + 8000
- mDiffOldSector = sector
- end
- -- init backup vars
- if mOld_lt == nil then
- mOld_ls1 = 0.00000
- mOld_ls2 = 0.00000
- mOld_lt = 0.00000
- mDelta_lpt = 0.00000
- mDelta_lptb = 0.00000
- end
-
- -- display delta by default
- lpt = GetTimeInfo("realdifflast")
-
- if mDiffSectorDelay > GetTicks() then
- -- display sector
- if sector == 1 then
- -- sector 3
- local lt = GetTimeInfo("lastlaptime")
-
- -- if ls1 > 0 and ls2 > 0 and lt > 0 and mOld_ls1 > 0 and mOld_ls2 > 0 and mOld_lt > 0 then
- -- delta sector 3
- --lpt = (lt - (ls1 + ls2)) - (mOld_lt - (mOld_ls1 + mOld_ls2))
- if lt > 0 and mOld_lt > 0 then
- if lt ~= mOld_lt then
- mDelta_lpt = lt - mOld_lt
- print(mDelta_lpt, lt, mOld_lt)
- end
- lpt = mDelta_lpt
- end
-
- mOld_lt = lt
-
-
- elseif sector == 2 then
- -- sector 1
- local ls1 = GetTimeInfo("lastsector1")
- if ls1 > 0 and mOld_ls1 > 0 then
- lpt = ls1 - mOld_ls1
- end
- mOld_ls2 = GetTimeInfo("lastsector2")
- print(lpt, ls1 , mOld_ls1, mOld_ls2)
-
- else
- -- sector 2
- local ls2 = GetTimeInfo("lastsector2")
- if ls2 > 0 and mOld_ls2 > 0 then
- lpt = ls2 - mOld_ls2
- end
- mOld_ls1 = GetTimeInfo("lastsector1")
- print(lpt, ls2 , mOld_ls1, mOld_ls2)
- end
- end
-
- elseif swValue == 38 then
- -- real time delta vs best + last sector diff 1, 2 and 3
-
- -- get sector
- local sector = GetCarInfo("sector")
- -- set flags
- diffFlag = true
-
- -- set delay
- if mDiffSectorDelay == nil or mDiffOldSector == nil or mDiffOldSector ~= sector then
- -- 8s delay, increase it if needed
- mDiffSectorDelay = GetTicks() + 8000
- mDiffOldSector = sector
- end
-
- -- init backup vars
- if mOld_bt == nil then
- mOld_bs1 = 0.00000
- mOld_bs2 = 0.00000
- mOld_bt = 0.00000
- mDelta_lpt = 0.00000
- mDelta_lptb = 0.00000
- end
-
- -- display delta by default
- lpt = GetTimeInfo("realdiffbest")
-
- if mDiffSectorDelay > GetTicks() then
- -- display sector diff during delay
- if sector == 1 then
- -- sector 3
- local bt = GetTimeInfo("bestlaptime")
-
- --if bs1 > 0 and bs2 > 0 and bt > 0 and mOld_bs1 > 0 and mOld_bs2 > 0 and mOld_bt > 0 then
- -- delta sector 3
- -- lpt = (bt - (bs1 + bs2)) - (mOld_bt - (mOld_bs1 + mOld_bs2))
- if bt > 0 and mOld_bt > 0 then
- if bt ~= mOld_bt then
- mDelta_lptb = bt - mOld_bt
- print(mDelta_lpt, bt, mOld_bt)
- end
- lpt = mDelta_lptb
- end
-
- mOld_bt = bt
-
- elseif sector == 2 then
- -- sector 1
- local bs1 = GetTimeInfo("bestsector1")
- if bs1 > 0 and mOld_bs1 > 0 then
- lpt = bs1 - mOld_bs1
- end
- print(lpt, bs1 )
- mOld_bs2 = GetTimeInfo("bestsector2")
-
- else
- -- sector 2
- local bs2 = GetTimeInfo("bestsector2")
- if bs2 > 0 and mOld_bs2 > 0 then
- lpt = bs2 - mOld_bs2
- end
- print(lpt, bs2 )
- mOld_bs1 = GetTimeInfo("bestsector1")
- end
- end
-
- else
- -- none
- rPanel = "-:--.---"
- SetRightDigits( rPanel )
- return 1
- end
- end
-
- if lpt == nil then return 0 end
-
- local refreshRate = mRefreshLapTimeRate
- if diffFlag then
- refreshRate = mDeltaTimeDelay
- end
-
- -- check if diff time is ready
- local diffOK = GetTimeInfo("realdifftimeready")
- if diffFlag and diffOK == false then
- diffFlag = false
- rPanel = " nPEF "
-
- mOld_ls1 = 0.00000
- mOld_ls2 = 0.00000
- mOld_lt = 0.00000
- mDelta_lpt = 0.00000
- mDelta_lptb = 0.00000
-
- SetRightDigits( rPanel )
- return 1
- end
-
- local c = " "
- if lpt < 0 then
- c = "-"
- end
- -- explod time
- hr, mn, sc, hd, ms = timeDispatcher(lpt)
-
- -- print("lpt: " .. lpt .. " m: " .. mn .. " - s: " .. sc .. " - ms: " .. ms .. )
- if GetTicks() > ( refreshRate + mDeltaTimeOldTicks ) then
- mDeltaTimeOldTicks = GetTicks()
-
- if diffFlag then
- --
- if lpt == -1 or (mn + sc + ms) == 0.0000 then
- mDeltaTimeBackup = " --.---"
- elseif mn > 0 then
- mDeltaTimeBackup = string.format( "%s%2d.%02d.%01d", c, mn, sc, ms)
- else
- mDeltaTimeBackup = string.format( "%s%2d.%03d", c, sc, ms)
- end
-
- rPanel = mDeltaTimeBackup
-
- else
- --if mTimeBackup == nil then mTimeBackup = 0.0000 end
- if lpt == -1 or (mn + sc + ms) == 0.0000 then
- mDeltaTimeBackup = "-:--.---"
- elseif mn < 10 then
- mDeltaTimeBackup = string.format( "%1d:%02d.%03d", mn, sc, ms)
- elseif hr > 0 then
- mDeltaTimeBackup = string.format( " %02d.%02d ", hr, mn)
- else
- mDeltaTimeBackup = string.format( " %02d.%02d.%01d", mn, sc, ms)
- end
-
-
- end
- end
- rPanel = mDeltaTimeBackup
- -- send time to sli manager
- SetRightDigits( rPanel )
- return 1
-end
-
+-- SLIPRO Lua Script v3.3.2 +-- Copyright (c)2012-2013 by Zappadoc - All Rights Reserved. +-- this script builds all functions associated with +-- left and right panels of SLIPRO device +-- last change by Zappadoc - 2013-09 + +-- ============================================================ +-- Left and Right Panel functions +-- ============================================================ + +-- IN function of left panel +-- param: recieve from SLI Manager the current switch position +function leftDigitsEvent(swFunction) + swValue = swFunction + 1 + -- call custom script + local result = custom_leftDigitsEvent(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_leftDigitsEvent(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 lPanel = "" + local inf = "" + local unit = false + local spd = 0.0 + -- 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 left panel + local qiLeft = GetContextInfo("quickinfoleft") + if qiLeft == nil then qiLeft = 1 end + -- force position to match QI preference + swValue = qiLeft + end + + -- check if PIT Feedback ON + local pf = false + pf = GetContextInfo("pitfeedback") + if pf == nil or pf == 0 then pf = false end + if pf then + -- force position to PIT/SPEED function if car pits + local pit = GetCarInfo("inpits") + if pit > 0 then + swValue = 35 + end + end + + -- get current simulation name + local sim = GetContextInfo("simulation") + + --print ( "swValue: " .. swValue .. "\n") + + -- check postion and compute left panel string + if swValue == 1 then + -- speed only + lPanel = string.format(" %3.0f ", spd ) + + elseif swValue == 2 then + -- fuel:speed + local fuel = GetCarInfo("fuel") + if fuel ~= nil then + fuel = GetFuel(fuel, unit) + if fuel >= 100 then + lPanel = string.format("%03d:%3d", round(fuel), spd) + elseif fuel >= 10 then + lPanel = string.format("F%02d:%3d", round(fuel), spd) + else + lPanel = string.format("F%1.1f:%3d", fuel, spd) + end + end + elseif swValue == 3 then + -- position:speed + inf = GetContextInfo("position") + if inf ~= nil then + if inf >= 100 then + lPanel = string.format("%03d:%3.0f", inf, spd) + else + lPanel = string.format("P%02d:%3.0f", inf, spd) + end + end + elseif swValue == 4 then + -- laps completed:speed + inf = GetContextInfo("laps") + if inf ~= nil then + -- if more then 99 laps + if inf >= 100 then + lPanel = string.format("%03d:%3.0f", inf, spd) + else + lPanel = string.format("L%02d:%3.0f", inf, spd) + end + end + elseif swValue == 5 then + -- sector:speed + inf = GetCarInfo("sector") + if inf ~= nil then + -- check if sector > 9 + if inf >9 then + lPanel = string.format("S%02d:%3.0f", inf, spd) + else + lPanel = string.format("S%01d :%3.0f", inf, spd) + end + end + elseif swValue == 6 then + -- laps completed:total laps if available + inf = GetContextInfo("laps") + if inf ~= nil then + local tl = GetContextInfo("lapscount") + if tl < 1 then tl = 0 end + -- if more then 99 laps + if inf >= 100 or tl >= 100 then + lPanel = string.format("%03d:%03d", inf, tl) + else + lPanel = string.format("L%02d:t%02d", inf, tl) + end + end + elseif swValue == 7 then + -- water temp + inf = GetCarInfo("watertemp") + if inf ~= nil then + inf = GetTemp(inf, unit) + lPanel = string.format("H2o:%2.1f", inf) + end + elseif swValue == 8 then + -- oil temp + inf = GetCarInfo("oiltemp") + if inf ~= nil then + inf = GetTemp(inf, unit) + lPanel = string.format("OIL:%2.1f", inf) + end + + elseif swValue == 9 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 + lPanel = string.format("tFL:%3.0f", inf) + end + elseif swValue == 10 then + inf = GetCarInfo("wheeltempfrontright") + if inf ~= nil then + if isAppRFactor(sim) then inf = KtoC(inf) end + lPanel = string.format("tFr:%3.0f", inf) + end + elseif swValue == 11 then + inf = GetCarInfo("wheeltemprearleft") + if inf ~= nil then + if isAppRFactor(sim) then inf = KtoC(inf) end + lPanel = string.format("trL:%3.0f", inf) + end + elseif swValue == 12 then + inf = GetCarInfo("wheeltemprearright") + if inf ~= nil then + if isAppRFactor(sim) then inf = KtoC(inf) end + lPanel = string.format("trr:%3.0f", inf) + end + + elseif swValue == 13 then + -- wheels pressure if available + inf = GetCarInfo("wheelpressfrontleft") + if inf ~= nil then + -- convert to psi + lPanel = string.format("PFL:%2.1f", inf / 6.88) + end + elseif swValue == 14 then + inf = GetCarInfo("wheelpressfrontright") + if inf ~= nil then + lPanel = string.format("PFr:%2.1f", inf / 6.88) + end + elseif swValue == 15 then + inf = GetCarInfo("wheelpressrearleft") + if inf ~= nil then + lPanel = string.format("PrL:%2.1f", inf / 6.88) + end + elseif swValue == 16 then + inf = GetCarInfo("wheelpressrearright") + if inf ~= nil then + lPanel = string.format("Prr:%2.1f", inf / 6.88) + end + + elseif swValue == 17 then + -- brakes temp if available + inf = GetCarInfo("braketempfrontleft") + if inf ~= nil then + if isAppRFactor(sim) or sim == "GTR2.exe" then inf = KtoC(inf) end + lPanel = string.format("BFL:%3.0f", inf) + end + elseif swValue == 18 then + inf = GetCarInfo("braketempfrontright") + if inf ~= nil then + if isAppRFactor(sim) or sim == "GTR2.exe" then inf = KtoC(inf) end + lPanel = string.format("BFr:%3.0f", inf) + end + elseif swValue == 19 then + inf = GetCarInfo("braketemprearleft") + if inf ~= nil then + if isAppRFactor(sim) or sim == "GTR2.exe" then inf = KtoC(inf) end + lPanel = string.format("BrL:%3.0f", inf) + end + elseif swValue == 20 then + inf = GetCarInfo("braketemprearright") + if inf ~= nil then + if isAppRFactor(sim) or sim == "GTR2.exe" then inf = KtoC(inf) end + lPanel = string.format("Brr:%3.0f", inf) + end + elseif swValue == 21 then + -- position + local pos = GetContextInfo("position") + lPanel = string.format(" P%02d ", pos ) + + elseif swValue == 22 then + -- get an average consumption of fuel per lap and gives the remaining laps + local remainintank = GetCarInfo("remainlapsintank") + lPanel = string.format(" FL%3.0f", math.floor(remainintank) ) + + elseif swValue == 23 then + -- rpm + local rpm = GetCarInfo("rpm") + lPanel = string.format("%5d ", rpm) + + elseif swValue == 24 then + -- track size + local trcksz = GetContextInfo("tracksize") + lPanel = string.format("%5d ", trcksz) + + elseif swValue == 25 then + -- 25.fuel + local fuel = GetCarInfo("fuel") + if fuel ~= nil then + fuel = GetFuel(fuel, unit) + if fuel >= 100 then + lPanel = string.format(" F%03d ", round(fuel)) + elseif fuel >= 10 then + lPanel = string.format(" F%02d ", round(fuel)) + else + lPanel = string.format(" F%1.1f ", fuel) + end + end + + elseif swValue == 26 then + -- 26.distance + local dist = GetContextInfo("lapdistance") + lPanel = string.format(" %5d", dist ) + + elseif swValue == 27 then + --27.lap completed + local laps = GetContextInfo("laps") + lPanel = string.format(" %3d ", laps ) + + elseif swValue == 28 then + --28.total laps + local lpcnt = GetContextInfo("lapscount") + lPanel = string.format(" %3d ", lpcnt ) + + elseif swValue == 29 then + --29.sector + local sect = GetCarInfo("sector") + -- check if sector > 9 + if sect >9 then + lPanel = string.format(" S%02d ", sect) + else + lPanel = string.format(" S%01d ", sect) + end + + elseif swValue == 30 then + --30.kers + local kers = GetCarInfo("kers") + lPanel = string.format(" E:%3d", round(kers/1000)) + + elseif swValue == 31 then + --31.kers max + local kmx = GetCarInfo("kersmax") + lPanel = string.format(" E:%03d", round(kmx/1000)) + + elseif swValue == 32 then + --32.drs + local drs = GetCarInfo("drs") + if drs == 1 then + lPanel = "DrS:ON " + else + lPanel = "DrS:OFF" + end + + elseif swValue == 33 then + --33.kers percent + local kers = GetCarInfo("kers") + lPanel = string.format(" E:%3d", round((kers/1000)/4)) + + elseif swValue == 34 then + --33.kers percent:speed + local kers = GetCarInfo("kers") + lPanel = string.format("%3d:%3.0f", round((kers/1000)/4), spd) + + elseif swValue == 35 then + -- PIT + lPanel = " PIt " + + elseif swValue == 36 then + -- sc + local sc = GetContextInfo("safetycare") + if sc == 1 then + lPanel = " SCAR " + else + lPanel = " OFF " + end + + else + lPanel = "-:--.---" + end + -- send string to sli manager + SetLeftDigits( lPanel ) + return 1 +end + +-- IN function of right panel +-- param: recieve from SLI Manager the current switch position +function rightDigitsEvent(swFunction) + swValue = swFunction + 1 + -- call custom script + local result = custom_rightDigitsEvent(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_rightDigitsEvent(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 rPanel = "" + local lpt = 0.0 + local diffFlag = false + local unit = false + + -- is OSP Tracking ON + local ospt = false + ospt = GetContextInfo("osptracking") + if ospt == nil then ospt = false end + if ospt then + swValue = 23 + end + + -- lap finished, display lap time a few seconds + local dlt = false + dlt = GetContextInfo("displaylaptime") + if dlt == nil then dlt = false end + if dlt and swValue ~= 37 and swValue ~= 38 then + swValue = 3 + end + + -- 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 right panel + local qiRight = GetContextInfo("quickinforight") + if qiRight == nil then qiRight = 1 end + swValue = qiRight + end + -- get current display unit metric or imperial + unit = GetContextInfo("speedmetric") + + -- check if PIT Feedback ON + local pf = false + pf = GetContextInfo("pitfeedback") + if pf == nil or pf == 0 then pf = false end + if pf then + -- force position to SPEED function + local pit = GetCarInfo("inpits") + if pit > 0 then + swValue = 20 + end + end + + --print ( "swValue: " .. swValue .. "\n") + + -- get sim name + local sim = GetContextInfo("simulation") + if sim ~= nil then + if swValue == 1 then + -- current lap time + lpt = GetTimeInfo("laptime") + elseif swValue == 2 then + -- best lap time (PB) + lpt = GetTimeInfo("bestlaptime") + elseif swValue == 3 then + -- last lap time + lpt = GetTimeInfo("lastlaptime") + + elseif swValue >= 4 and swValue <= 10 and isAppIRacing(sim) then + -- iRacing partials + local ts = GetContextInfo("partialcount") + local sector = GetCarInfo("sector") + if ts ~= nil and ts > 0 then + if swValue == 4 then + lpt = GetPartialTimeInfo("currentpartial", sector) + elseif swValue == 5 then + diffFlag = true + lpt = GetPartialTimeInfo("vsbestlap", sector) + elseif swValue == 6 then + diffFlag = true + lpt = GetPartialTimeInfo("vsoptimallap", sector) + elseif swValue == 7 then + diffFlag = true + lpt = GetPartialTimeInfo("vsoptimalsector", sector) + elseif swValue == 8 then + diffFlag = true + lpt = GetPartialTimeInfo("vssessionbestlap", sector) + elseif swValue == 9 then + diffFlag = true + lpt = GetPartialTimeInfo("vssessionoptimallap", sector) + elseif swValue == 10 then + diffFlag = true + lpt = GetPartialTimeInfo("vssessionoptimalsector", sector) + end + else + lpt = 0.0 + end + + elseif swValue == 11 then + -- real time diff vs your best + diffFlag = true + lpt = GetTimeInfo("realdiffbest") + + elseif swValue == 12 then + -- real time diff vs your last + diffFlag = true + lpt = GetTimeInfo("realdifflast") + + elseif swValue == 13 then + -- current sector + local sector = GetCarInfo("sector") + if sector == 1 then + lpt = GetTimeInfo("sector1") + elseif sector == 2 then + lpt = GetTimeInfo("sector2") + else + -- sector 3 + local s1 = GetTimeInfo("sector1") + local s2 = GetTimeInfo("sector2") + local lt = GetTimeInfo("laptime") + lpt = lt - (s1 + s2) + end + elseif swValue == 14 then + -- best sector 1 + lpt = GetTimeInfo("bestsector1") + elseif swValue == 15 then + -- best sector 2 + lpt = GetTimeInfo("bestsector2") + elseif swValue == 16 then + -- last sector 1 + lpt = GetTimeInfo("lastsector1") + elseif swValue == 17 then + -- last sector 2 + lpt = GetTimeInfo("lastsector2") + elseif swValue == 18 then + -- position + local pos = GetContextInfo("position") + if pos >= 100 then + rPanel = string.format(" P%03d ", pos ) + else + rPanel = string.format(" P%02d ", pos ) + end + SetRightDigits( rPanel ) + return 1 + elseif swValue == 19 then + -- get an average consumption of fuel per lap and gives the remaining laps + local remainintank = GetCarInfo("remainlapsintank") + rPanel = string.format(" FL%3.0f", math.floor(remainintank) ) + + elseif swValue == 20 then + -- speed on right panel + local spd = GetCarInfo("speed") + rPanel = string.format(" %3d ", spd ) + SetRightDigits( rPanel ) + return 1 + + elseif swValue == 21 then + -- time remaining if available + lpt = GetTimeInfo("timeremaining") + + -- explod time + hr, mn, sc, hd, ms = timeDispatcher(lpt) + if hr > 0 then + rPanel = string.format( "%02dh%02d ", hr, mn) + else + rPanel = string.format( " %02d.%02d ", mn, sc) + end + SetRightDigits( rPanel ) + return 1 + + elseif swValue == 22 then + -- PC system time + lpt = GetTimeInfo("systemtime") + -- explod time + hr, mn, sc, hd, ms = timeDispatcher(lpt) + rPanel = string.format( " %02d.%02d ", hr, mn) + SetRightDigits( rPanel ) + return 1 + + elseif swValue == 23 then + -- rpm:gear + local rpm = GetCarInfo("rpm") + if rpm == nil then + return 1 + end + local gear = GetCarInfo("gear") + if gear ~= nil then + rPanel = string.format("%5d:%d", rpm, gear) + SetRightDigits( rPanel ) + end + return 1 + + elseif swValue == 24 then + -- time elapsed if available + lpt = GetTimeInfo("timetotalelapsed") + + -- explod time + hr, mn, sc, hd, ms = timeDispatcher(lpt) + if hr > 0 then + rPanel = string.format( "%02dh%02d ", hr, mn) + else + rPanel = string.format( " %02d.%02d ", mn, sc) + end + SetRightDigits( rPanel ) + return 1 + elseif swValue == 25 then + -- 25.fuel + local fuel = GetCarInfo("fuel") + if fuel ~= nil then + fuel = GetFuel(fuel, unit) + if fuel >= 100 then + rPanel = string.format(" F%03d ", round(fuel)) + elseif fuel >= 10 then + rPanel = string.format(" F%02d ", round(fuel)) + else + rPanel = string.format(" F%1.1f ", fuel) + end + + SetRightDigits( rPanel ) + return 1 + end + + elseif swValue == 26 then + -- 26.distance + local dist = GetContextInfo("lapdistance") + rPanel = string.format(" %5d", dist ) + SetRightDigits( rPanel ) + return 1 + + elseif swValue == 27 then + --27.lap completed + local laps = GetContextInfo("laps") + rPanel = string.format(" %3d ", laps ) + SetRightDigits( rPanel ) + return 1 + + elseif swValue == 28 then + --28.total laps + local lpcnt = GetContextInfo("lapscount") + rPanel = string.format(" %3d ", lpcnt ) + SetRightDigits( rPanel ) + return 1 + + elseif swValue == 29 then + --29.sector + local sect = GetCarInfo("sector") + -- check if sector > 9 + if sect >9 then + rPanel = string.format(" S%02d ", sect) + else + rPanel = string.format(" S%01d ", sect) + end + SetRightDigits( rPanel ) + return 1 + + elseif swValue == 30 then + --30.kers + local kers = GetCarInfo("kers") + rPanel = string.format(" E%03d ", round(kers/1000) ) + SetRightDigits( rPanel ) + return 1 + + elseif swValue == 31 then + --31.kers max + local kmx = GetCarInfo("kersmax") + rPanel = string.format(" E%03d ", round(kmx/1000) ) + SetRightDigits( rPanel ) + return 1 + + elseif swValue == 32 then + --32.drs + rPanel = "DrS.OFF" + local drs = GetCarInfo("drs") + if drs >= 1 then + rPanel = "DrS. ON" + end + SetRightDigits( rPanel ) + return 1 + + elseif swValue == 33 then + --33.kers percent + local kers = GetCarInfo("kers") + rPanel = string.format(" %3d ", round((kers/1000)/4)) + SetRightDigits( rPanel ) + return 1 + + elseif swValue == 34 then + --34 track size + local trcksz = GetContextInfo("tracksize") + rPanel = string.format("%5d ", trcksz) + SetRightDigits( rPanel ) + return 1 + + elseif swValue == 35 then + --35 last sector 1, 2 and 3 + local sector = GetCarInfo("sector") + if sector == 1 then + -- sector 3 + local ls1 = GetTimeInfo("lastsector1") + local ls2 = GetTimeInfo("lastsector2") + local lt = GetTimeInfo("lastlaptime") + if ls1 > 0 and ls2 > 0 then + lpt = lt - (ls1 + ls2) + end + elseif sector == 2 then + local ls1 = GetTimeInfo("lastsector1") + lpt = ls1 + else + -- sector 3 + local ls2 = GetTimeInfo("lastsector2") + lpt = ls2 + end + + elseif swValue == 36 then + --36.rpm + local rpm = GetCarInfo("rpm") + rPanel = string.format("%5d ", rpm) + SetRightDigits( rPanel ) + return 1 + + elseif swValue == 37 then + -- real time delta vs last + last sector diff 1, 2 and 3 + local sector = GetCarInfo("sector") + diffFlag = true + if mDiffSectorDelay == nil or mDiffOldSector == nil or mDiffOldSector ~= sector then + -- 8s delay, increase it if needed + mDiffSectorDelay = GetTicks() + 8000 + mDiffOldSector = sector + end + -- init backup vars + if mOld_lt == nil then + mOld_ls1 = 0.00000 + mOld_ls2 = 0.00000 + mOld_lt = 0.00000 + mDelta_lpt = 0.00000 + mDelta_lptb = 0.00000 + end + + -- display delta by default + lpt = GetTimeInfo("realdifflast") + + if mDiffSectorDelay > GetTicks() then + -- display sector + if sector == 1 then + -- sector 3 + local lt = GetTimeInfo("lastlaptime") + + -- if ls1 > 0 and ls2 > 0 and lt > 0 and mOld_ls1 > 0 and mOld_ls2 > 0 and mOld_lt > 0 then + -- delta sector 3 + --lpt = (lt - (ls1 + ls2)) - (mOld_lt - (mOld_ls1 + mOld_ls2)) + if lt > 0 and mOld_lt > 0 then + if lt ~= mOld_lt then + mDelta_lpt = lt - mOld_lt + print(mDelta_lpt, lt, mOld_lt) + end + lpt = mDelta_lpt + end + + mOld_lt = lt + + + elseif sector == 2 then + -- sector 1 + local ls1 = GetTimeInfo("lastsector1") + if ls1 > 0 and mOld_ls1 > 0 then + lpt = ls1 - mOld_ls1 + end + mOld_ls2 = GetTimeInfo("lastsector2") + print(lpt, ls1 , mOld_ls1, mOld_ls2) + + else + -- sector 2 + local ls2 = GetTimeInfo("lastsector2") + if ls2 > 0 and mOld_ls2 > 0 then + lpt = ls2 - mOld_ls2 + end + mOld_ls1 = GetTimeInfo("lastsector1") + print(lpt, ls2 , mOld_ls1, mOld_ls2) + end + end + + elseif swValue == 38 then + -- real time delta vs best + last sector diff 1, 2 and 3 + + -- get sector + local sector = GetCarInfo("sector") + -- set flags + diffFlag = true + + -- set delay + if mDiffSectorDelay == nil or mDiffOldSector == nil or mDiffOldSector ~= sector then + -- 8s delay, increase it if needed + mDiffSectorDelay = GetTicks() + 8000 + mDiffOldSector = sector + end + + -- init backup vars + if mOld_bt == nil then + mOld_bs1 = 0.00000 + mOld_bs2 = 0.00000 + mOld_bt = 0.00000 + mDelta_lpt = 0.00000 + mDelta_lptb = 0.00000 + end + + -- display delta by default + lpt = GetTimeInfo("realdiffbest") + + if mDiffSectorDelay > GetTicks() then + -- display sector diff during delay + if sector == 1 then + -- sector 3 + local bt = GetTimeInfo("bestlaptime") + + --if bs1 > 0 and bs2 > 0 and bt > 0 and mOld_bs1 > 0 and mOld_bs2 > 0 and mOld_bt > 0 then + -- delta sector 3 + -- lpt = (bt - (bs1 + bs2)) - (mOld_bt - (mOld_bs1 + mOld_bs2)) + if bt > 0 and mOld_bt > 0 then + if bt ~= mOld_bt then + mDelta_lptb = bt - mOld_bt + print(mDelta_lpt, bt, mOld_bt) + end + lpt = mDelta_lptb + end + + mOld_bt = bt + + elseif sector == 2 then + -- sector 1 + local bs1 = GetTimeInfo("bestsector1") + if bs1 > 0 and mOld_bs1 > 0 then + lpt = bs1 - mOld_bs1 + end + print(lpt, bs1 ) + mOld_bs2 = GetTimeInfo("bestsector2") + + else + -- sector 2 + local bs2 = GetTimeInfo("bestsector2") + if bs2 > 0 and mOld_bs2 > 0 then + lpt = bs2 - mOld_bs2 + end + print(lpt, bs2 ) + mOld_bs1 = GetTimeInfo("bestsector1") + end + end + + else + -- none + rPanel = "-:--.---" + SetRightDigits( rPanel ) + return 1 + end + end + + if lpt == nil then return 0 end + + local refreshRate = mRefreshLapTimeRate + if diffFlag then + refreshRate = mDeltaTimeDelay + end + + -- check if diff time is ready + local diffOK = GetTimeInfo("realdifftimeready") + if diffFlag and diffOK == false then + diffFlag = false + rPanel = " nPEF " + + mOld_ls1 = 0.00000 + mOld_ls2 = 0.00000 + mOld_lt = 0.00000 + mDelta_lpt = 0.00000 + mDelta_lptb = 0.00000 + + SetRightDigits( rPanel ) + return 1 + end + + local c = " " + if lpt < 0 then + c = "-" + end + -- explod time + hr, mn, sc, hd, ms = timeDispatcher(lpt) + + -- print("lpt: " .. lpt .. " m: " .. mn .. " - s: " .. sc .. " - ms: " .. ms .. ) + if GetTicks() > ( refreshRate + mDeltaTimeOldTicks ) then + mDeltaTimeOldTicks = GetTicks() + + if diffFlag then + -- + if lpt == -1 or (mn + sc + ms) == 0.0000 then + mDeltaTimeBackup = " --.---" + elseif mn > 0 then + mDeltaTimeBackup = string.format( "%s%2d.%02d.%01d", c, mn, sc, ms) + else + mDeltaTimeBackup = string.format( "%s%2d.%03d", c, sc, ms) + end + + rPanel = mDeltaTimeBackup + + else + --if mTimeBackup == nil then mTimeBackup = 0.0000 end + if lpt == -1 or (mn + sc + ms) == 0.0000 then + mDeltaTimeBackup = "-:--.---" + elseif mn < 10 then + mDeltaTimeBackup = string.format( "%1d:%02d.%03d", mn, sc, ms) + elseif hr > 0 then + mDeltaTimeBackup = string.format( " %02d.%02d ", hr, mn) + else + mDeltaTimeBackup = string.format( " %02d.%02d.%01d", mn, sc, ms) + end + + + end + end + rPanel = mDeltaTimeBackup + -- send time to sli manager + SetRightDigits( rPanel ) + return 1 +end + diff --git a/scripts/slipro_gus.lua b/scripts/slipro_gus.lua index a83c6eb..fa58db6 100644 --- a/scripts/slipro_gus.lua +++ b/scripts/slipro_gus.lua @@ -1,218 +1,218 @@ --- 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
--- see the scripting section of the forum for more info...
-
--- IMPORTANT:
--- this script will not be deleted by uninstalling the software
-
--- ================================
--- CONSTANTS
-
-
--- ================================
--- additional lua extension module dll
-
-
--- ================================
--- additional scripts file ( use 'require' statement )
-
--- ================================
--- custom globals
-
--- ================================
--- custom functions
-
--- ================================
--- custom events
-
-function global_custom_controlsEvent(devType, ctrlType, ctrlPos, value, funcIndex)
- -- type your custom controls script here (manage buttons, switches and encoders)
- return 2
-end
-
-function global_custom_deviceReport(devType)
- -- type your script here (just before sending report to the device )
- return 2
-end
-
-function global_custom_enterSessionEvent(devType)
- -- type your custom script on session start, here
- print ()
- print ( "vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv")
- print (string.format("simu : %s",GetContextInfo("simulation")))
- print (string.format("car : %s",GetContextInfo("carname")))
- print (string.format("track : %s",GetContextInfo("trackname")))
- --print (string.format("session: %s",GetContextInfo("session")))
- print ()
- if GetContextInfo("ospcustom") then print ("has ospcustom") end
-
- print (string.format("shiftlightsmethod: %s",GetContextInfo("shiftlightsmethod")))
- print (string.format("ospmethod : %s",GetContextInfo("ospmethod")))
- print (string.format("speedlimitemethod: %s",GetContextInfo("speedlimitermethod")))
- return 2
-end
-
-function global_custom_exitSessionEvent(devType)
- -- type your custom script on session ending, here
- if GetContextInfo("ospcustom") then print ("has ospcustom") end
- print ()
- print (string.format("shiftlightsmethod: %s",GetContextInfo("shiftlightsmethod")))
- print (string.format("ospmethod : %s",GetContextInfo("ospmethod")))
- print (string.format("speedlimitemethod: %s",GetContextInfo("speedlimitermethod")))
- print ( "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^")
- print ()
-
- --my_setups=io.open("gus_cars.cfg", "a")
- --my_setups:write(GetContextInfo("carname"), " shiftligts ", GetContextInfo("shiftlightsmethod"), "\n")
- --my_setups:write(GetContextInfo("carname"), " speedlimiter ", GetContextInfo("speedlimitermethod"), "\n")
- --my_setups:close()
-
- 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
- return 2
-end
-
-function global_custom_shiftLightsBU0710Event(idx)
- -- type your custom shiftlights method for BU0710 device only here
- return 2
-end
-
-function global_custom_leftDigitsEvent(swPosition)
- -- type your custom script related to left SLI-PRO digits panel here
- return 2
-end
-
-function global_custom_rightDigitsEvent(swPosition)
- -- type your custom script related to right SLI-PRO digits panel here
- return 2
-end
-
-function global_custom_spdLmtMethodEvent(idx)
- -- type your custom speedlimiter method here
- return 2
-end
-
-function global_custom_gearEvent(gear)
- -- manage gear when ´E´
- if gear == 69 then
- local ignition = 1
- if GetContextInfo("simulation") == "rFactor2.exe" then
- ignition = GetCarInfo("ignition")
- end
- local g = GetCarInfo("gear")
-
- --print ( string.format("gear %d/ignition %d" , g, ignition))
-
- toggleAllLed(0)
- if ignition == 2 then
- SetLeftDigits(" ---- ")
- SetRightDigits(" ---- ")
- else
- SetLeftDigits(" ")
- SetRightDigits(" ")
- end
-
- if ignition == 0 then
- SetGearDigit(" ")
- elseif ignition == 1 then
- SetGearDigit(GetCurrentGear())
- end
-
- SLISendReport(1)
- return 1
- end
-
- return 2
-end
-
-function global_custom_ledEvent(idx, ledFunction, state)
- -- type your custom script on session ending, here
- return 2
-end
-
--- ================================
--- LOGITECH G27 SUPPORT
-
-function global_custom_shiftLightsG27LedsMethodEvent(idx)
- -- type your custom shiftlights method for G27 device only here
- return 2
-end
-
-function global_custom_ospG27MethodEvent(idx)
- -- type your custom Optimal Shift Points (OSP) method here
- return 2
-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_fanatecDigitsEvent(swPosition)
- -- type your custom script related to Fanatec digits panel here
- return 2
-end
-
-function global_custom_ospFanatecMethodEvent(idx)
- -- type your custom Optimal Shift Points (OSP) method here
- return 2
-end
-
-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
--- DO NOT CHANGE THE SCRIPT BELOW
--- ================================
-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
+-- 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 +-- see the scripting section of the forum for more info... + +-- IMPORTANT: +-- this script will not be deleted by uninstalling the software + +-- ================================ +-- CONSTANTS + + +-- ================================ +-- additional lua extension module dll + + +-- ================================ +-- additional scripts file ( use 'require' statement ) + +-- ================================ +-- custom globals + +-- ================================ +-- custom functions + +-- ================================ +-- custom events + +function global_custom_controlsEvent(devType, ctrlType, ctrlPos, value, funcIndex) + -- type your custom controls script here (manage buttons, switches and encoders) + return 2 +end + +function global_custom_deviceReport(devType) + -- type your script here (just before sending report to the device ) + return 2 +end + +function global_custom_enterSessionEvent(devType) + -- type your custom script on session start, here + print () + print ( "vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv") + print (string.format("simu : %s",GetContextInfo("simulation"))) + print (string.format("car : %s",GetContextInfo("carname"))) + print (string.format("track : %s",GetContextInfo("trackname"))) + --print (string.format("session: %s",GetContextInfo("session"))) + print () + if GetContextInfo("ospcustom") then print ("has ospcustom") end + + print (string.format("shiftlightsmethod: %s",GetContextInfo("shiftlightsmethod"))) + print (string.format("ospmethod : %s",GetContextInfo("ospmethod"))) + print (string.format("speedlimitemethod: %s",GetContextInfo("speedlimitermethod"))) + return 2 +end + +function global_custom_exitSessionEvent(devType) + -- type your custom script on session ending, here + if GetContextInfo("ospcustom") then print ("has ospcustom") end + print () + print (string.format("shiftlightsmethod: %s",GetContextInfo("shiftlightsmethod"))) + print (string.format("ospmethod : %s",GetContextInfo("ospmethod"))) + print (string.format("speedlimitemethod: %s",GetContextInfo("speedlimitermethod"))) + print ( "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^") + print () + + --my_setups=io.open("gus_cars.cfg", "a") + --my_setups:write(GetContextInfo("carname"), " shiftligts ", GetContextInfo("shiftlightsmethod"), "\n") + --my_setups:write(GetContextInfo("carname"), " speedlimiter ", GetContextInfo("speedlimitermethod"), "\n") + --my_setups:close() + + 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 + return 2 +end + +function global_custom_shiftLightsBU0710Event(idx) + -- type your custom shiftlights method for BU0710 device only here + return 2 +end + +function global_custom_leftDigitsEvent(swPosition) + -- type your custom script related to left SLI-PRO digits panel here + return 2 +end + +function global_custom_rightDigitsEvent(swPosition) + -- type your custom script related to right SLI-PRO digits panel here + return 2 +end + +function global_custom_spdLmtMethodEvent(idx) + -- type your custom speedlimiter method here + return 2 +end + +function global_custom_gearEvent(gear) + -- manage gear when ´E´ + if gear == 69 then + local ignition = 1 + if GetContextInfo("simulation") == "rFactor2.exe" then + ignition = GetCarInfo("ignition") + end + local g = GetCarInfo("gear") + + --print ( string.format("gear %d/ignition %d" , g, ignition)) + + toggleAllLed(0) + if ignition == 2 then + SetLeftDigits(" ---- ") + SetRightDigits(" ---- ") + else + SetLeftDigits(" ") + SetRightDigits(" ") + end + + if ignition == 0 then + SetGearDigit(" ") + elseif ignition == 1 then + SetGearDigit(GetCurrentGear()) + end + + SLISendReport(1) + return 1 + end + + return 2 +end + +function global_custom_ledEvent(idx, ledFunction, state) + -- type your custom script on session ending, here + return 2 +end + +-- ================================ +-- LOGITECH G27 SUPPORT + +function global_custom_shiftLightsG27LedsMethodEvent(idx) + -- type your custom shiftlights method for G27 device only here + return 2 +end + +function global_custom_ospG27MethodEvent(idx) + -- type your custom Optimal Shift Points (OSP) method here + return 2 +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_fanatecDigitsEvent(swPosition) + -- type your custom script related to Fanatec digits panel here + return 2 +end + +function global_custom_ospFanatecMethodEvent(idx) + -- type your custom Optimal Shift Points (OSP) method here + return 2 +end + +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 +-- DO NOT CHANGE THE SCRIPT BELOW +-- ================================ +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/slipro_iracing.lua b/scripts/slipro_iracing.lua index 2d5b5ba..f1a9c06 100644 --- a/scripts/slipro_iracing.lua +++ b/scripts/slipro_iracing.lua @@ -1,11 +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
+-- 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 81bef78..d579672 100644 --- a/scripts/speedlimiter.lua +++ b/scripts/speedlimiter.lua @@ -1,1018 +1,1018 @@ --- SLIMax Mgr Lua Script v3.3.1
--- Copyright (c)2012-2013 by Zappadoc - All Rights Reserved.
--- this script builds all speed/pit-limiter feedback methods
--- last change by Zappadoc - 2013-10
-
--- SLI-M, SLI-PRO speed limiter Methods
-function spdLmtMethodEvent(idx)
- mSpdLimitMethod = idx
- mLeftSpdLmtText = " "
- mRightSpdLmtText = " "
- -- call custom script
- local result = custom_spdLmtMethodEvent(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_spdLmtMethodEvent(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()
-
- if mSpdLimitMethod >= 2 then
- -- init table
- initLedTable(mRPMLedTable, 0)
- SetRPMLed("mRPMLedTable")
- end
-
- if mNoBlink or (mSpdLimitMethod == 0) then
- -- speedlimiter led NOT blinking
- SetWarnLed(mSpeedLimiterLED, 1)
-
- 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
- if mLimiterChar then SetGearDigit("L") end
- SetWarnLed(mSpeedLimiterLED, 1)
- end
-
- if mSpdLmtBlink > (mBlinkTime / 2) then
- if mLimiterChar then SetGearDigit(" ") end
- SetWarnLed(mSpeedLimiterLED, 0)
- end
-
- elseif mSpdLimitMethod == 2 then
- -- speedlimiter led + RPM blinking, method 2
- if GetTicks() > mOldTickCount then
- mSpdLmtBlink = mSpdLmtBlink + 1
- end
-
- if mSpdLmtBlink >= mBlinkTime then
- mSpdLmtBlink = 0
- end
-
- if mSpdLmtBlink <= (mBlinkTime / 2) then
- if mLimiterChar then SetGearDigit("L") end
- initLedTable(mRPMLedTable, 1)
- if not mSpdLmtRPMLedOnly then
- SetWarnLed(mSpeedLimiterLED, 1)
- end
- end
-
- if mSpdLmtBlink > (mBlinkTime / 2) then
- if mLimiterChar then SetGearDigit(" ") end
- initLedTable(mRPMLedTable, 0)
- if not mSpdLmtRPMLedOnly then
- SetWarnLed(mSpeedLimiterLED, 0)
- end
- end
- SetRPMLed("mRPMLedTable")
-
- elseif mSpdLimitMethod == 3 then
- -- speedlimiter led + alternate RPM blinking, method 3
- if GetTicks() > mOldTickCount then
- mSpdLmtBlink = mSpdLmtBlink + 1
- end
- if mSpdLmtBlink >= mBlinkTime then
- mSpdLmtBlink = 0
- end
- if mSpdLmtBlink <= (mBlinkTime / 2) then
- if mLimiterChar then
- SetGearDigit("L")
- end
- for i = 0,12 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
- SetWarnLed(mSpeedLimiterLED, 1)
- end
- end
-
- if mSpdLmtBlink > (mBlinkTime / 2) then
- if mLimiterChar then
- SetGearDigit(" ")
- end
- for i = 0,13 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
- SetWarnLed(mSpeedLimiterLED, 0)
- end
- end
- SetRPMLed("mRPMLedTable")
-
- elseif mSpdLimitMethod == 4 then
- -- speedlimiter led + RPM + digits blinking, method 4
- if GetTicks() > mOldTickCount then
- mSpdLmtBlink = mSpdLmtBlink + 1
- end
-
- if mSpdLmtBlink >= mBlinkTime then
- mSpdLmtBlink = 0
- end
-
- if mSpdLmtBlink <= (mBlinkTime / 2) then
-
- if mLimiterChar then SetGearDigit("L") end
- SetDigitsAllowed(true)
-
- for i = 0,2 do
- led = led.format("RPM%d",i)
- mRPMLedTable[led] = 0
- end
- for i = 10,12 do
- led = led.format("RPM%d",i)
- mRPMLedTable[led] = 0
- end
-
- if not mSpdLmtRPMLedOnly then
- SetWarnLed(mSpeedLimiterLED, 0)
- end
- end
-
- if mSpdLmtBlink > (mBlinkTime / 2) then
- if mLimiterChar then SetGearDigit(" ") end
-
- SetDigitsAllowed(false)
-
- SetLeftDigits (mLeftSpdLmtText)
- SetRightDigits (mRightSpdLmtText)
-
- for i = 0,2 do
- led = led.format("RPM%d",i)
- mRPMLedTable[led] = 1
- end
- for i = 10,12 do
- led = led.format("RPM%d",i)
- mRPMLedTable[led] = 1
- end
- if not mSpdLmtRPMLedOnly then
- SetWarnLed(mSpeedLimiterLED, 0)
- end
- end
- SetRPMLed("mRPMLedTable")
-
- elseif mSpdLimitMethod == 5 or mSpdLimitMethod == 6 then
- -- speedlimiter led + digits blinking, method 5
- -- speedlimiter led + RPM fixed + Digits blinking, method 6
- if GetTicks() > mOldTickCount then
- mSpdLmtBlink = mSpdLmtBlink + 1
- end
-
- if mSpdLmtBlink >= mBlinkTime then
- mSpdLmtBlink = 0
- end
-
- if mSpdLmtBlink <= (mBlinkTime / 2) then
- if mLimiterChar then SetGearDigit("L") end
-
- SetDigitsAllowed (true)
-
- local state = 0
- if mSpdLimitMethod == 6 then state = 1 end
- initLedTable(mRPMLedTable, state)
-
- if not mSpdLmtRPMLedOnly then
- SetWarnLed(mSpeedLimiterLED, 0)
- end
- end
-
- if mSpdLmtBlink > (mBlinkTime / 2) then
- if mLimiterChar then SetGearDigit(" ") end
-
- SetLeftDigits ( mLeftSpdLmtText)
- SetRightDigits ( mRightSpdLmtText)
-
- SetDigitsAllowed(false)
-
- local state = 0
- if mSpdLimitMethod == 6 then state = 1 end
- initLedTable(mRPMLedTable, state)
-
- if not mSpdLmtRPMLedOnly then
- SetWarnLed(mSpeedLimiterLED, 0)
- end
- end
- SetRPMLed("mRPMLedTable")
-
- else
- return 1
- end
-
- -- timebase
- if GetTicks() > mOldTickCount then
- mOldTickCount = GetTicks() + 20
- end
- return 1
-end
-
-
--- G27 speed limiter Methods
-function spdLmtG27MethodEvent(idx)
- mSpdLimitG27Method = idx
- -- call custom script
- local result = custom_spdLmtG27MethodEvent(mSpdLimitG27Method)
- -- 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(mSpdLimitG27Method)
- -- 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 mSpdLimitG27Method == 0 then
- -- speedlimiter led NOT blinking
- mG27Leds = 0x1F
-
- elseif mSpdLimitG27Method == 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 mSpdLimitG27Method >= 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
- end
- return 1
-end
-
-
- -- Fanatec speed/pit limiter Methods
-function spdLmtFanatecMethodEvent(idx)
- mSpdLimitFanatecMethod = idx
- mFanatecSpdLmtText = " "
- -- call custom script
- local result = custom_spdLmtFanatecMethodEvent(mSpdLimitFanatecMethod)
- -- 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(mSpdLimitFanatecMethod)
- -- 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)
- SetRPMLed("mRPMLedTable")
-
- if mNoBlink or mSpdLimitFanatecMethod == 0 then
- -- speedlimiter first rpm led NOT blinking
- SetFanatecDigitsAllowed(true)
- mRPMLedTable["RPM0"]= 1
- SetRPMLed("mRPMLedTable")
- if mLimiterChar then
- SetFanatecDigitsAllowed(false)
- SetFanatecDigits( " L " )
- oldGear = 110
- else
- SetFanatecDigitsAllowed(true)
- end
-
- elseif mSpdLimitFanatecMethod == 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
-
- if mLimiterChar then
- SetFanatecDigitsAllowed(false)
- SetFanatecDigits( " L " )
- oldGear = 110
- end
- end
-
- if mSpdLmtBlink > (mBlinkTime / 2) then
- mRPMLedTable["RPM0"]= 0
- if mLimiterChar then
- oldGear = 110
- SetFanatecDigitsAllowed(true)
- end
- end
- SetRPMLed("mRPMLedTable")
-
- elseif mSpdLimitFanatecMethod == 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)
-
- if mLimiterChar then
- SetFanatecDigitsAllowed(false)
- SetFanatecDigits( " L " )
- oldGear = 110
- end
- end
-
- if mSpdLmtBlink > (mBlinkTime / 2) then
- initLedTable(mRPMLedTable, 0)
-
- if mLimiterChar then
- oldGear = 110
- SetFanatecDigitsAllowed(true)
- end
- end
- SetRPMLed("mRPMLedTable")
-
- elseif mSpdLimitFanatecMethod == 3 or mSpdLimitFanatecMethod > 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
- SetFanatecDigitsAllowed(false)
- if mLimiterChar then
- SetFanatecDigits( " L " )
- oldGear = 110
- else
- SetFanatecDigits( "---" )
- 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
-
- SetFanatecDigitsAllowed(true)
- end
- SetRPMLed("mRPMLedTable")
-
-
- elseif mSpdLimitFanatecMethod == 4 or mSpdLimitFanatecMethod == 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 mLimiterChar then
- SetFanatecDigitsAllowed(false)
- SetFanatecDigits( " L " )
- oldGear = 110
- else
- SetFanatecDigitsAllowed(false)
- SetFanatecDigits( "---" )
- end
- end
-
- if mSpdLmtBlink > (mBlinkTime / 2) then
-
- if mSpdLimitFanatecMethod == 4 then
- SetFanatecDigitsAllowed(true)
- else
- SetFanatecDigitsAllowed(false)
- SetFanatecDigits( " " )
- end
-
- initLedTable(mRPMLedTable, 0)
- end
- SetRPMLed("mRPMLedTable")
-
- elseif mSpdLimitFanatecMethod == 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 mLimiterChar then
- SetFanatecDigitsAllowed(false)
- SetFanatecDigits( " L " )
- oldGear = 110
- else
- SetFanatecDigitsAllowed(true)
- end
- end
-
- if mSpdLmtBlink > (mBlinkTime / 2) then
-
- SetFanatecDigitsAllowed(false)
- SetFanatecDigits( " " )
-
- initLedTable(mRPMLedTable, 1)
- end
- SetRPMLed("mRPMLedTable")
-
- else
- return 1
- end
-
- -- timebase
- if GetTicks() > mOldTickCount then
- mOldTickCount = GetTicks() + 20
- end
- return 1
-end
-
--- SIM RACE Deluxe speed limiter Methods
-function spdLmtSRDlxMethodEvent(idx)
- mSpdLimitSRDlxMethod = idx
- mLeftSpdLmtText = " "
- mRightSpdLmtText = " "
- -- call custom script
- local result = custom_spdLmtSRDlxMethodEvent(mSpdLimitSRDlxMethod)
- -- 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_spdLmtSRDlxMethodEvent(mSpdLimitSRDlxMethod)
- -- 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)
- SetRPMLed("mRPMLedTable")
-
- if mNoBlink or (mSpdLimitSRDlxMethod == 0) then
- -- speedlimiter led NOT blinking
- SetWarnLed(mSpeedLimiterLED, 1)
-
- elseif mSpdLimitSRDlxMethod == 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
- if mLimiterChar then SetGearDigit("L") end
- SetWarnLed(mSpeedLimiterLED, 1)
- end
-
- if mSpdLmtBlink > (mBlinkTime / 2) then
- if mLimiterChar then SetGearDigit(" ") end
- SetWarnLed(mSpeedLimiterLED, 0)
- end
-
- elseif mSpdLimitSRDlxMethod == 2 then
- -- speedlimiter led + RPM blinking, method 2
- if GetTicks() > mOldTickCount then
- mSpdLmtBlink = mSpdLmtBlink + 1
- end
-
- if mSpdLmtBlink >= mBlinkTime then
- mSpdLmtBlink = 0
- end
-
- if mSpdLmtBlink <= (mBlinkTime / 2) then
- if mLimiterChar then SetGearDigit("L") end
- initLedTable(mRPMLedTable, 1)
- if not mSpdLmtRPMLedOnly then
- SetWarnLed(mSpeedLimiterLED, 1)
- end
- end
-
- if mSpdLmtBlink > (mBlinkTime / 2) then
- if mLimiterChar then SetGearDigit(" ") end
- initLedTable(mRPMLedTable, 0)
- if not mSpdLmtRPMLedOnly then
- SetWarnLed(mSpeedLimiterLED, 0)
- end
- end
- SetRPMLed("mRPMLedTable")
-
- elseif mSpdLimitSRDlxMethod == 3 then
- -- speedlimiter led + alternate RPM blinking, method 3
- if GetTicks() > mOldTickCount then
- mSpdLmtBlink = mSpdLmtBlink + 1
- end
- if mSpdLmtBlink >= mBlinkTime then
- mSpdLmtBlink = 0
- end
- if mSpdLmtBlink <= (mBlinkTime / 2) then
- if mLimiterChar then
- SetGearDigit("L")
- end
- for i = 0,12 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
- SetWarnLed(mSpeedLimiterLED, 1)
- end
- end
-
- if mSpdLmtBlink > (mBlinkTime / 2) then
- if mLimiterChar then
- SetGearDigit(" ")
- end
- for i = 0,13 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
- SetWarnLed(mSpeedLimiterLED, 0)
- end
- end
- SetRPMLed("mRPMLedTable")
-
- elseif mSpdLimitSRDlxMethod == 4 then
- -- speedlimiter led + RPM + digits blinking, method 4
- if GetTicks() > mOldTickCount then
- mSpdLmtBlink = mSpdLmtBlink + 1
- end
-
- if mSpdLmtBlink >= mBlinkTime then
- mSpdLmtBlink = 0
- end
-
- if mSpdLmtBlink <= (mBlinkTime / 2) then
-
- if mLimiterChar then SetGearDigit("L") end
- SetDigitsAllowed(true)
-
- for i = 0,2 do
- led = led.format("RPM%d",i)
- mRPMLedTable[led] = 0
- end
- for i = 10,12 do
- led = led.format("RPM%d",i)
- mRPMLedTable[led] = 0
- end
-
- if not mSpdLmtRPMLedOnly then
- SetWarnLed(mSpeedLimiterLED, 0)
- end
- end
-
- if mSpdLmtBlink > (mBlinkTime / 2) then
- if mLimiterChar then SetGearDigit(" ") end
-
- SetDigitsAllowed(false)
-
- SetLeftDigits (mLeftSpdLmtText)
- SetRightDigits (mRightSpdLmtText)
-
- for i = 0,2 do
- led = led.format("RPM%d",i)
- mRPMLedTable[led] = 1
- end
- for i = 10,12 do
- led = led.format("RPM%d",i)
- mRPMLedTable[led] = 1
- end
- if not mSpdLmtRPMLedOnly then
- SetWarnLed(mSpeedLimiterLED, 0)
- end
- end
- SetRPMLed("mRPMLedTable")
-
- elseif mSpdLimitSRDlxMethod == 5 or mSpdLimitSRDlxMethod == 6 then
- -- speedlimiter led + digits blinking, method 5
- -- speedlimiter led + RPM fixed + Digits blinking, method 6
- if GetTicks() > mOldTickCount then
- mSpdLmtBlink = mSpdLmtBlink + 1
- end
-
- if mSpdLmtBlink >= mBlinkTime then
- mSpdLmtBlink = 0
- end
-
- if mSpdLmtBlink <= (mBlinkTime / 2) then
- if mLimiterChar then SetGearDigit("L") end
-
- SetDigitsAllowed (true)
-
- local state = 0
- if mSpdLimitSRDlxMethod == 6 then state = 1 end
- initLedTable(mRPMLedTable, state)
-
- if not mSpdLmtRPMLedOnly then
- SetWarnLed(mSpeedLimiterLED, 0)
- end
- end
-
- if mSpdLmtBlink > (mBlinkTime / 2) then
- if mLimiterChar then SetGearDigit(" ") end
-
- SetLeftDigits ( mLeftSpdLmtText)
- SetRightDigits ( mRightSpdLmtText)
-
- SetDigitsAllowed(false)
-
- local state = 0
- if mSpdLimitSRDlxMethod == 6 then state = 1 end
- initLedTable(mRPMLedTable, state)
-
- if not mSpdLmtRPMLedOnly then
- SetWarnLed(mSpeedLimiterLED, 0)
- end
- end
- SetRPMLed("mRPMLedTable")
-
- else
- return 1
- end
-
- -- timebase
- if GetTicks() > mOldTickCount then
- mOldTickCount = GetTicks() + 20
- end
- return 1
-end
--- SIM RACE F1 speed limiter Methods
-function spdLmtSRF1MethodEvent(idx)
- mSpdLimitSRF1Method = idx
- mLeftSpdLmtText = " "
- mRightSpdLmtText = " "
- -- call custom script
- local result = custom_spdLmtSRF1MethodEvent(mSpdLimitSRF1Method)
- -- 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_spdLmtSRF1MethodEvent(mSpdLimitSRF1Method)
- -- 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)
- SetRPMLed("mRPMLedTable")
-
- if mNoBlink or (mSpdLimitSRF1Method == 0) then
- -- speedlimiter led NOT blinking
- SetWarnLed(mSpeedLimiterLED, 1)
-
- elseif mSpdLimitSRF1Method == 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
- if mLimiterChar then SetGearDigit("L") end
- SetWarnLed(mSpeedLimiterLED, 1)
- end
-
- if mSpdLmtBlink > (mBlinkTime / 2) then
- if mLimiterChar then SetGearDigit(" ") end
- SetWarnLed(mSpeedLimiterLED, 0)
- end
-
- elseif mSpdLimitSRF1Method == 2 then
- -- speedlimiter led + RPM blinking, method 2
- if GetTicks() > mOldTickCount then
- mSpdLmtBlink = mSpdLmtBlink + 1
- end
-
- if mSpdLmtBlink >= mBlinkTime then
- mSpdLmtBlink = 0
- end
-
- if mSpdLmtBlink <= (mBlinkTime / 2) then
- if mLimiterChar then SetGearDigit("L") end
- initLedTable(mRPMLedTable, 1)
- if not mSpdLmtRPMLedOnly then
- SetWarnLed(mSpeedLimiterLED, 1)
- end
- end
-
- if mSpdLmtBlink > (mBlinkTime / 2) then
- if mLimiterChar then SetGearDigit(" ") end
- initLedTable(mRPMLedTable, 0)
- if not mSpdLmtRPMLedOnly then
- SetWarnLed(mSpeedLimiterLED, 0)
- end
- end
- SetRPMLed("mRPMLedTable")
-
- elseif mSpdLimitSRF1Method == 3 then
- -- speedlimiter led + alternate RPM blinking, method 3
- if GetTicks() > mOldTickCount then
- mSpdLmtBlink = mSpdLmtBlink + 1
- end
- if mSpdLmtBlink >= mBlinkTime then
- mSpdLmtBlink = 0
- end
- if mSpdLmtBlink <= (mBlinkTime / 2) then
- if mLimiterChar then
- SetGearDigit("L")
- end
- for i = 0,14 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
- SetWarnLed(mSpeedLimiterLED, 1)
- end
- end
-
- if mSpdLmtBlink > (mBlinkTime / 2) then
- if mLimiterChar then
- SetGearDigit(" ")
- end
- for i = 0,15 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
- SetWarnLed(mSpeedLimiterLED, 0)
- end
- end
- SetRPMLed("mRPMLedTable")
-
- elseif mSpdLimitSRF1Method == 4 then
- -- speedlimiter led + RPM + digits blinking, method 4
- if GetTicks() > mOldTickCount then
- mSpdLmtBlink = mSpdLmtBlink + 1
- end
-
- if mSpdLmtBlink >= mBlinkTime then
- mSpdLmtBlink = 0
- end
-
- if mSpdLmtBlink <= (mBlinkTime / 2) then
-
- if mLimiterChar then SetGearDigit("L") end
- SetDigitsAllowed(true)
-
- for i = 0,4 do
- led = led.format("RPM%d",i)
- mRPMLedTable[led] = 0
- end
- for i = 10,14 do
- led = led.format("RPM%d",i)
- mRPMLedTable[led] = 0
- end
-
- if not mSpdLmtRPMLedOnly then
- SetWarnLed(mSpeedLimiterLED, 0)
- end
- end
-
- if mSpdLmtBlink > (mBlinkTime / 2) then
- if mLimiterChar then SetGearDigit(" ") end
-
- SetDigitsAllowed(false)
-
- SetLeftDigits (mLeftSpdLmtText)
- SetRightDigits (mRightSpdLmtText)
-
- for i = 0,4 do
- led = led.format("RPM%d",i)
- mRPMLedTable[led] = 1
- end
- for i = 10,14 do
- led = led.format("RPM%d",i)
- mRPMLedTable[led] = 1
- end
- if not mSpdLmtRPMLedOnly then
- SetWarnLed(mSpeedLimiterLED, 0)
- end
- end
- SetRPMLed("mRPMLedTable")
-
- elseif mSpdLimitSRF1Method == 5 or mSpdLimitSRF1Method == 6 then
- -- speedlimiter led + digits blinking, method 5
- -- speedlimiter led + RPM fixed + Digits blinking, method 6
- if GetTicks() > mOldTickCount then
- mSpdLmtBlink = mSpdLmtBlink + 1
- end
-
- if mSpdLmtBlink >= mBlinkTime then
- mSpdLmtBlink = 0
- end
-
- if mSpdLmtBlink <= (mBlinkTime / 2) then
- if mLimiterChar then SetGearDigit("L") end
-
- SetDigitsAllowed (true)
-
- local state = 0
- if mSpdLimitSRF1Method == 6 then state = 1 end
- initLedTable(mRPMLedTable, state)
-
- if not mSpdLmtRPMLedOnly then
- SetWarnLed(mSpeedLimiterLED, 0)
- end
- end
-
- if mSpdLmtBlink > (mBlinkTime / 2) then
- if mLimiterChar then SetGearDigit(" ") end
-
- SetLeftDigits ( mLeftSpdLmtText)
- SetRightDigits ( mRightSpdLmtText)
-
- SetDigitsAllowed(false)
-
- local state = 0
- if mSpdLimitSRF1Method == 6 then state = 1 end
- initLedTable(mRPMLedTable, state)
-
- if not mSpdLmtRPMLedOnly then
- SetWarnLed(mSpeedLimiterLED, 0)
- end
- end
- SetRPMLed("mRPMLedTable")
-
-
- else
- return 1
- end
-
- -- timebase
- if GetTicks() > mOldTickCount then
- mOldTickCount = GetTicks() + 20
- end
- return 1
-end
+-- SLIMax Mgr Lua Script v3.3.1 +-- Copyright (c)2012-2013 by Zappadoc - All Rights Reserved. +-- this script builds all speed/pit-limiter feedback methods +-- last change by Zappadoc - 2013-10 + +-- SLI-M, SLI-PRO speed limiter Methods +function spdLmtMethodEvent(idx) + mSpdLimitMethod = idx + mLeftSpdLmtText = " " + mRightSpdLmtText = " " + -- call custom script + local result = custom_spdLmtMethodEvent(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_spdLmtMethodEvent(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() + + if mSpdLimitMethod >= 2 then + -- init table + initLedTable(mRPMLedTable, 0) + SetRPMLed("mRPMLedTable") + end + + if mNoBlink or (mSpdLimitMethod == 0) then + -- speedlimiter led NOT blinking + SetWarnLed(mSpeedLimiterLED, 1) + + 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 + if mLimiterChar then SetGearDigit("L") end + SetWarnLed(mSpeedLimiterLED, 1) + end + + if mSpdLmtBlink > (mBlinkTime / 2) then + if mLimiterChar then SetGearDigit(" ") end + SetWarnLed(mSpeedLimiterLED, 0) + end + + elseif mSpdLimitMethod == 2 then + -- speedlimiter led + RPM blinking, method 2 + if GetTicks() > mOldTickCount then + mSpdLmtBlink = mSpdLmtBlink + 1 + end + + if mSpdLmtBlink >= mBlinkTime then + mSpdLmtBlink = 0 + end + + if mSpdLmtBlink <= (mBlinkTime / 2) then + if mLimiterChar then SetGearDigit("L") end + initLedTable(mRPMLedTable, 1) + if not mSpdLmtRPMLedOnly then + SetWarnLed(mSpeedLimiterLED, 1) + end + end + + if mSpdLmtBlink > (mBlinkTime / 2) then + if mLimiterChar then SetGearDigit(" ") end + initLedTable(mRPMLedTable, 0) + if not mSpdLmtRPMLedOnly then + SetWarnLed(mSpeedLimiterLED, 0) + end + end + SetRPMLed("mRPMLedTable") + + elseif mSpdLimitMethod == 3 then + -- speedlimiter led + alternate RPM blinking, method 3 + if GetTicks() > mOldTickCount then + mSpdLmtBlink = mSpdLmtBlink + 1 + end + if mSpdLmtBlink >= mBlinkTime then + mSpdLmtBlink = 0 + end + if mSpdLmtBlink <= (mBlinkTime / 2) then + if mLimiterChar then + SetGearDigit("L") + end + for i = 0,12 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 + SetWarnLed(mSpeedLimiterLED, 1) + end + end + + if mSpdLmtBlink > (mBlinkTime / 2) then + if mLimiterChar then + SetGearDigit(" ") + end + for i = 0,13 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 + SetWarnLed(mSpeedLimiterLED, 0) + end + end + SetRPMLed("mRPMLedTable") + + elseif mSpdLimitMethod == 4 then + -- speedlimiter led + RPM + digits blinking, method 4 + if GetTicks() > mOldTickCount then + mSpdLmtBlink = mSpdLmtBlink + 1 + end + + if mSpdLmtBlink >= mBlinkTime then + mSpdLmtBlink = 0 + end + + if mSpdLmtBlink <= (mBlinkTime / 2) then + + if mLimiterChar then SetGearDigit("L") end + SetDigitsAllowed(true) + + for i = 0,2 do + led = led.format("RPM%d",i) + mRPMLedTable[led] = 0 + end + for i = 10,12 do + led = led.format("RPM%d",i) + mRPMLedTable[led] = 0 + end + + if not mSpdLmtRPMLedOnly then + SetWarnLed(mSpeedLimiterLED, 0) + end + end + + if mSpdLmtBlink > (mBlinkTime / 2) then + if mLimiterChar then SetGearDigit(" ") end + + SetDigitsAllowed(false) + + SetLeftDigits (mLeftSpdLmtText) + SetRightDigits (mRightSpdLmtText) + + for i = 0,2 do + led = led.format("RPM%d",i) + mRPMLedTable[led] = 1 + end + for i = 10,12 do + led = led.format("RPM%d",i) + mRPMLedTable[led] = 1 + end + if not mSpdLmtRPMLedOnly then + SetWarnLed(mSpeedLimiterLED, 0) + end + end + SetRPMLed("mRPMLedTable") + + elseif mSpdLimitMethod == 5 or mSpdLimitMethod == 6 then + -- speedlimiter led + digits blinking, method 5 + -- speedlimiter led + RPM fixed + Digits blinking, method 6 + if GetTicks() > mOldTickCount then + mSpdLmtBlink = mSpdLmtBlink + 1 + end + + if mSpdLmtBlink >= mBlinkTime then + mSpdLmtBlink = 0 + end + + if mSpdLmtBlink <= (mBlinkTime / 2) then + if mLimiterChar then SetGearDigit("L") end + + SetDigitsAllowed (true) + + local state = 0 + if mSpdLimitMethod == 6 then state = 1 end + initLedTable(mRPMLedTable, state) + + if not mSpdLmtRPMLedOnly then + SetWarnLed(mSpeedLimiterLED, 0) + end + end + + if mSpdLmtBlink > (mBlinkTime / 2) then + if mLimiterChar then SetGearDigit(" ") end + + SetLeftDigits ( mLeftSpdLmtText) + SetRightDigits ( mRightSpdLmtText) + + SetDigitsAllowed(false) + + local state = 0 + if mSpdLimitMethod == 6 then state = 1 end + initLedTable(mRPMLedTable, state) + + if not mSpdLmtRPMLedOnly then + SetWarnLed(mSpeedLimiterLED, 0) + end + end + SetRPMLed("mRPMLedTable") + + else + return 1 + end + + -- timebase + if GetTicks() > mOldTickCount then + mOldTickCount = GetTicks() + 20 + end + return 1 +end + + +-- G27 speed limiter Methods +function spdLmtG27MethodEvent(idx) + mSpdLimitG27Method = idx + -- call custom script + local result = custom_spdLmtG27MethodEvent(mSpdLimitG27Method) + -- 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(mSpdLimitG27Method) + -- 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 mSpdLimitG27Method == 0 then + -- speedlimiter led NOT blinking + mG27Leds = 0x1F + + elseif mSpdLimitG27Method == 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 mSpdLimitG27Method >= 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 + end + return 1 +end + + + -- Fanatec speed/pit limiter Methods +function spdLmtFanatecMethodEvent(idx) + mSpdLimitFanatecMethod = idx + mFanatecSpdLmtText = " " + -- call custom script + local result = custom_spdLmtFanatecMethodEvent(mSpdLimitFanatecMethod) + -- 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(mSpdLimitFanatecMethod) + -- 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) + SetRPMLed("mRPMLedTable") + + if mNoBlink or mSpdLimitFanatecMethod == 0 then + -- speedlimiter first rpm led NOT blinking + SetFanatecDigitsAllowed(true) + mRPMLedTable["RPM0"]= 1 + SetRPMLed("mRPMLedTable") + if mLimiterChar then + SetFanatecDigitsAllowed(false) + SetFanatecDigits( " L " ) + oldGear = 110 + else + SetFanatecDigitsAllowed(true) + end + + elseif mSpdLimitFanatecMethod == 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 + + if mLimiterChar then + SetFanatecDigitsAllowed(false) + SetFanatecDigits( " L " ) + oldGear = 110 + end + end + + if mSpdLmtBlink > (mBlinkTime / 2) then + mRPMLedTable["RPM0"]= 0 + if mLimiterChar then + oldGear = 110 + SetFanatecDigitsAllowed(true) + end + end + SetRPMLed("mRPMLedTable") + + elseif mSpdLimitFanatecMethod == 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) + + if mLimiterChar then + SetFanatecDigitsAllowed(false) + SetFanatecDigits( " L " ) + oldGear = 110 + end + end + + if mSpdLmtBlink > (mBlinkTime / 2) then + initLedTable(mRPMLedTable, 0) + + if mLimiterChar then + oldGear = 110 + SetFanatecDigitsAllowed(true) + end + end + SetRPMLed("mRPMLedTable") + + elseif mSpdLimitFanatecMethod == 3 or mSpdLimitFanatecMethod > 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 + SetFanatecDigitsAllowed(false) + if mLimiterChar then + SetFanatecDigits( " L " ) + oldGear = 110 + else + SetFanatecDigits( "---" ) + 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 + + SetFanatecDigitsAllowed(true) + end + SetRPMLed("mRPMLedTable") + + + elseif mSpdLimitFanatecMethod == 4 or mSpdLimitFanatecMethod == 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 mLimiterChar then + SetFanatecDigitsAllowed(false) + SetFanatecDigits( " L " ) + oldGear = 110 + else + SetFanatecDigitsAllowed(false) + SetFanatecDigits( "---" ) + end + end + + if mSpdLmtBlink > (mBlinkTime / 2) then + + if mSpdLimitFanatecMethod == 4 then + SetFanatecDigitsAllowed(true) + else + SetFanatecDigitsAllowed(false) + SetFanatecDigits( " " ) + end + + initLedTable(mRPMLedTable, 0) + end + SetRPMLed("mRPMLedTable") + + elseif mSpdLimitFanatecMethod == 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 mLimiterChar then + SetFanatecDigitsAllowed(false) + SetFanatecDigits( " L " ) + oldGear = 110 + else + SetFanatecDigitsAllowed(true) + end + end + + if mSpdLmtBlink > (mBlinkTime / 2) then + + SetFanatecDigitsAllowed(false) + SetFanatecDigits( " " ) + + initLedTable(mRPMLedTable, 1) + end + SetRPMLed("mRPMLedTable") + + else + return 1 + end + + -- timebase + if GetTicks() > mOldTickCount then + mOldTickCount = GetTicks() + 20 + end + return 1 +end + +-- SIM RACE Deluxe speed limiter Methods +function spdLmtSRDlxMethodEvent(idx) + mSpdLimitSRDlxMethod = idx + mLeftSpdLmtText = " " + mRightSpdLmtText = " " + -- call custom script + local result = custom_spdLmtSRDlxMethodEvent(mSpdLimitSRDlxMethod) + -- 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_spdLmtSRDlxMethodEvent(mSpdLimitSRDlxMethod) + -- 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) + SetRPMLed("mRPMLedTable") + + if mNoBlink or (mSpdLimitSRDlxMethod == 0) then + -- speedlimiter led NOT blinking + SetWarnLed(mSpeedLimiterLED, 1) + + elseif mSpdLimitSRDlxMethod == 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 + if mLimiterChar then SetGearDigit("L") end + SetWarnLed(mSpeedLimiterLED, 1) + end + + if mSpdLmtBlink > (mBlinkTime / 2) then + if mLimiterChar then SetGearDigit(" ") end + SetWarnLed(mSpeedLimiterLED, 0) + end + + elseif mSpdLimitSRDlxMethod == 2 then + -- speedlimiter led + RPM blinking, method 2 + if GetTicks() > mOldTickCount then + mSpdLmtBlink = mSpdLmtBlink + 1 + end + + if mSpdLmtBlink >= mBlinkTime then + mSpdLmtBlink = 0 + end + + if mSpdLmtBlink <= (mBlinkTime / 2) then + if mLimiterChar then SetGearDigit("L") end + initLedTable(mRPMLedTable, 1) + if not mSpdLmtRPMLedOnly then + SetWarnLed(mSpeedLimiterLED, 1) + end + end + + if mSpdLmtBlink > (mBlinkTime / 2) then + if mLimiterChar then SetGearDigit(" ") end + initLedTable(mRPMLedTable, 0) + if not mSpdLmtRPMLedOnly then + SetWarnLed(mSpeedLimiterLED, 0) + end + end + SetRPMLed("mRPMLedTable") + + elseif mSpdLimitSRDlxMethod == 3 then + -- speedlimiter led + alternate RPM blinking, method 3 + if GetTicks() > mOldTickCount then + mSpdLmtBlink = mSpdLmtBlink + 1 + end + if mSpdLmtBlink >= mBlinkTime then + mSpdLmtBlink = 0 + end + if mSpdLmtBlink <= (mBlinkTime / 2) then + if mLimiterChar then + SetGearDigit("L") + end + for i = 0,12 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 + SetWarnLed(mSpeedLimiterLED, 1) + end + end + + if mSpdLmtBlink > (mBlinkTime / 2) then + if mLimiterChar then + SetGearDigit(" ") + end + for i = 0,13 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 + SetWarnLed(mSpeedLimiterLED, 0) + end + end + SetRPMLed("mRPMLedTable") + + elseif mSpdLimitSRDlxMethod == 4 then + -- speedlimiter led + RPM + digits blinking, method 4 + if GetTicks() > mOldTickCount then + mSpdLmtBlink = mSpdLmtBlink + 1 + end + + if mSpdLmtBlink >= mBlinkTime then + mSpdLmtBlink = 0 + end + + if mSpdLmtBlink <= (mBlinkTime / 2) then + + if mLimiterChar then SetGearDigit("L") end + SetDigitsAllowed(true) + + for i = 0,2 do + led = led.format("RPM%d",i) + mRPMLedTable[led] = 0 + end + for i = 10,12 do + led = led.format("RPM%d",i) + mRPMLedTable[led] = 0 + end + + if not mSpdLmtRPMLedOnly then + SetWarnLed(mSpeedLimiterLED, 0) + end + end + + if mSpdLmtBlink > (mBlinkTime / 2) then + if mLimiterChar then SetGearDigit(" ") end + + SetDigitsAllowed(false) + + SetLeftDigits (mLeftSpdLmtText) + SetRightDigits (mRightSpdLmtText) + + for i = 0,2 do + led = led.format("RPM%d",i) + mRPMLedTable[led] = 1 + end + for i = 10,12 do + led = led.format("RPM%d",i) + mRPMLedTable[led] = 1 + end + if not mSpdLmtRPMLedOnly then + SetWarnLed(mSpeedLimiterLED, 0) + end + end + SetRPMLed("mRPMLedTable") + + elseif mSpdLimitSRDlxMethod == 5 or mSpdLimitSRDlxMethod == 6 then + -- speedlimiter led + digits blinking, method 5 + -- speedlimiter led + RPM fixed + Digits blinking, method 6 + if GetTicks() > mOldTickCount then + mSpdLmtBlink = mSpdLmtBlink + 1 + end + + if mSpdLmtBlink >= mBlinkTime then + mSpdLmtBlink = 0 + end + + if mSpdLmtBlink <= (mBlinkTime / 2) then + if mLimiterChar then SetGearDigit("L") end + + SetDigitsAllowed (true) + + local state = 0 + if mSpdLimitSRDlxMethod == 6 then state = 1 end + initLedTable(mRPMLedTable, state) + + if not mSpdLmtRPMLedOnly then + SetWarnLed(mSpeedLimiterLED, 0) + end + end + + if mSpdLmtBlink > (mBlinkTime / 2) then + if mLimiterChar then SetGearDigit(" ") end + + SetLeftDigits ( mLeftSpdLmtText) + SetRightDigits ( mRightSpdLmtText) + + SetDigitsAllowed(false) + + local state = 0 + if mSpdLimitSRDlxMethod == 6 then state = 1 end + initLedTable(mRPMLedTable, state) + + if not mSpdLmtRPMLedOnly then + SetWarnLed(mSpeedLimiterLED, 0) + end + end + SetRPMLed("mRPMLedTable") + + else + return 1 + end + + -- timebase + if GetTicks() > mOldTickCount then + mOldTickCount = GetTicks() + 20 + end + return 1 +end +-- SIM RACE F1 speed limiter Methods +function spdLmtSRF1MethodEvent(idx) + mSpdLimitSRF1Method = idx + mLeftSpdLmtText = " " + mRightSpdLmtText = " " + -- call custom script + local result = custom_spdLmtSRF1MethodEvent(mSpdLimitSRF1Method) + -- 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_spdLmtSRF1MethodEvent(mSpdLimitSRF1Method) + -- 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) + SetRPMLed("mRPMLedTable") + + if mNoBlink or (mSpdLimitSRF1Method == 0) then + -- speedlimiter led NOT blinking + SetWarnLed(mSpeedLimiterLED, 1) + + elseif mSpdLimitSRF1Method == 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 + if mLimiterChar then SetGearDigit("L") end + SetWarnLed(mSpeedLimiterLED, 1) + end + + if mSpdLmtBlink > (mBlinkTime / 2) then + if mLimiterChar then SetGearDigit(" ") end + SetWarnLed(mSpeedLimiterLED, 0) + end + + elseif mSpdLimitSRF1Method == 2 then + -- speedlimiter led + RPM blinking, method 2 + if GetTicks() > mOldTickCount then + mSpdLmtBlink = mSpdLmtBlink + 1 + end + + if mSpdLmtBlink >= mBlinkTime then + mSpdLmtBlink = 0 + end + + if mSpdLmtBlink <= (mBlinkTime / 2) then + if mLimiterChar then SetGearDigit("L") end + initLedTable(mRPMLedTable, 1) + if not mSpdLmtRPMLedOnly then + SetWarnLed(mSpeedLimiterLED, 1) + end + end + + if mSpdLmtBlink > (mBlinkTime / 2) then + if mLimiterChar then SetGearDigit(" ") end + initLedTable(mRPMLedTable, 0) + if not mSpdLmtRPMLedOnly then + SetWarnLed(mSpeedLimiterLED, 0) + end + end + SetRPMLed("mRPMLedTable") + + elseif mSpdLimitSRF1Method == 3 then + -- speedlimiter led + alternate RPM blinking, method 3 + if GetTicks() > mOldTickCount then + mSpdLmtBlink = mSpdLmtBlink + 1 + end + if mSpdLmtBlink >= mBlinkTime then + mSpdLmtBlink = 0 + end + if mSpdLmtBlink <= (mBlinkTime / 2) then + if mLimiterChar then + SetGearDigit("L") + end + for i = 0,14 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 + SetWarnLed(mSpeedLimiterLED, 1) + end + end + + if mSpdLmtBlink > (mBlinkTime / 2) then + if mLimiterChar then + SetGearDigit(" ") + end + for i = 0,15 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 + SetWarnLed(mSpeedLimiterLED, 0) + end + end + SetRPMLed("mRPMLedTable") + + elseif mSpdLimitSRF1Method == 4 then + -- speedlimiter led + RPM + digits blinking, method 4 + if GetTicks() > mOldTickCount then + mSpdLmtBlink = mSpdLmtBlink + 1 + end + + if mSpdLmtBlink >= mBlinkTime then + mSpdLmtBlink = 0 + end + + if mSpdLmtBlink <= (mBlinkTime / 2) then + + if mLimiterChar then SetGearDigit("L") end + SetDigitsAllowed(true) + + for i = 0,4 do + led = led.format("RPM%d",i) + mRPMLedTable[led] = 0 + end + for i = 10,14 do + led = led.format("RPM%d",i) + mRPMLedTable[led] = 0 + end + + if not mSpdLmtRPMLedOnly then + SetWarnLed(mSpeedLimiterLED, 0) + end + end + + if mSpdLmtBlink > (mBlinkTime / 2) then + if mLimiterChar then SetGearDigit(" ") end + + SetDigitsAllowed(false) + + SetLeftDigits (mLeftSpdLmtText) + SetRightDigits (mRightSpdLmtText) + + for i = 0,4 do + led = led.format("RPM%d",i) + mRPMLedTable[led] = 1 + end + for i = 10,14 do + led = led.format("RPM%d",i) + mRPMLedTable[led] = 1 + end + if not mSpdLmtRPMLedOnly then + SetWarnLed(mSpeedLimiterLED, 0) + end + end + SetRPMLed("mRPMLedTable") + + elseif mSpdLimitSRF1Method == 5 or mSpdLimitSRF1Method == 6 then + -- speedlimiter led + digits blinking, method 5 + -- speedlimiter led + RPM fixed + Digits blinking, method 6 + if GetTicks() > mOldTickCount then + mSpdLmtBlink = mSpdLmtBlink + 1 + end + + if mSpdLmtBlink >= mBlinkTime then + mSpdLmtBlink = 0 + end + + if mSpdLmtBlink <= (mBlinkTime / 2) then + if mLimiterChar then SetGearDigit("L") end + + SetDigitsAllowed (true) + + local state = 0 + if mSpdLimitSRF1Method == 6 then state = 1 end + initLedTable(mRPMLedTable, state) + + if not mSpdLmtRPMLedOnly then + SetWarnLed(mSpeedLimiterLED, 0) + end + end + + if mSpdLmtBlink > (mBlinkTime / 2) then + if mLimiterChar then SetGearDigit(" ") end + + SetLeftDigits ( mLeftSpdLmtText) + SetRightDigits ( mRightSpdLmtText) + + SetDigitsAllowed(false) + + local state = 0 + if mSpdLimitSRF1Method == 6 then state = 1 end + initLedTable(mRPMLedTable, state) + + if not mSpdLmtRPMLedOnly then + SetWarnLed(mSpeedLimiterLED, 0) + end + end + SetRPMLed("mRPMLedTable") + + + else + return 1 + end + + -- timebase + if GetTicks() > mOldTickCount then + mOldTickCount = GetTicks() + 20 + end + return 1 +end diff --git a/scripts/srf1emu_iracing.lua b/scripts/srf1emu_iracing.lua index e50287c..0f1e693 100644 --- a/scripts/srf1emu_iracing.lua +++ b/scripts/srf1emu_iracing.lua @@ -1,11 +1,11 @@ --- iRacing Custom Scripts - SLIMax Manager Scripts v1.9
--- Copyright ©2011-2013 by Zappadoc - All Rights Reserved.
--- last change by Zappadoc - 2013-08
-
--- ================================
--- 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
+-- iRacing Custom Scripts - SLIMax Manager Scripts v1.9 +-- Copyright ©2011-2013 by Zappadoc - All Rights Reserved. +-- last change by Zappadoc - 2013-08 + +-- ================================ +-- 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 |