summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugues Hiegel <hugues@hiegel.fr>2013-11-15 17:27:33 +0100
committerHugues Hiegel <hugues@hiegel.fr>2013-11-15 17:27:33 +0100
commit11da2520ff2d0c610d9324ef1688fca54bfd12b7 (patch)
treedfba7c837783edf723c482aac2457e7332088ef2
parentf1d1ed5ddda21ffe735e49a400405fc02079564d (diff)
[Gugus scripts] reorganization.
-rw-r--r--scripts/gear.lua2
-rw-r--r--scripts/gugus/enterExit.lua36
-rw-r--r--scripts/gugus/gear.lua32
-rw-r--r--scripts/gugus/sliproDigits.lua (renamed from scripts/slipro_digits.lua)36
-rw-r--r--scripts/gugus/speedlimiter.lua1001
-rw-r--r--scripts/slidevice.lua1
-rw-r--r--scripts/slipro_gus.lua226
-rw-r--r--scripts/speedlimiter.lua8
8 files changed, 1086 insertions, 256 deletions
diff --git a/scripts/gear.lua b/scripts/gear.lua
index bcf0361..7015eef 100644
--- a/scripts/gear.lua
+++ b/scripts/gear.lua
@@ -173,4 +173,4 @@ function gearFanatecEvent(gear)
end
return 2
-end \ No newline at end of file
+end
diff --git a/scripts/gugus/enterExit.lua b/scripts/gugus/enterExit.lua
new file mode 100644
index 0000000..0b11ba3
--- /dev/null
+++ b/scripts/gugus/enterExit.lua
@@ -0,0 +1,36 @@
+
+function 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
+
diff --git a/scripts/gugus/gear.lua b/scripts/gugus/gear.lua
new file mode 100644
index 0000000..463449a
--- /dev/null
+++ b/scripts/gugus/gear.lua
@@ -0,0 +1,32 @@
+function 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
diff --git a/scripts/slipro_digits.lua b/scripts/gugus/sliproDigits.lua
index f49080f..0ffbfb2 100644
--- a/scripts/slipro_digits.lua
+++ b/scripts/gugus/sliproDigits.lua
@@ -1,30 +1,11 @@
--- 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)
+function custom_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 = ""
@@ -350,21 +331,8 @@ end
-- IN function of right panel
-- param: recieve from SLI Manager the current switch position
-function rightDigitsEvent(swFunction)
+function custom_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
diff --git a/scripts/gugus/speedlimiter.lua b/scripts/gugus/speedlimiter.lua
new file mode 100644
index 0000000..8468038
--- /dev/null
+++ b/scripts/gugus/speedlimiter.lua
@@ -0,0 +1,1001 @@
+
+-- SLI-M, SLI-PRO speed limiter Methods
+function custom_spdLmtMethodEvent(idx)
+ mSpdLimitMethod = idx
+ mLeftSpdLmtText = " "
+ mRightSpdLmtText = " "
+
+ 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/slidevice.lua b/scripts/slidevice.lua
index a5ef3de..1004fa2 100644
--- a/scripts/slidevice.lua
+++ b/scripts/slidevice.lua
@@ -23,6 +23,7 @@ scr = GetCustomScripts("scriptname")
-- print ( scr )
if scr ~= nil and scr ~= "" then
mCustomScriptsFileName = scr
+ print ( string.format("Loading custom script %s ...\n", scr) )
require(mCustomScriptsFileName)
custom_initEvent(scr)
end
diff --git a/scripts/slipro_gus.lua b/scripts/slipro_gus.lua
index 8e7f4c2..bd9d680 100644
--- a/scripts/slipro_gus.lua
+++ b/scripts/slipro_gus.lua
@@ -1,220 +1,14 @@
--- 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...
+require "scripts/gugus/enterExit"
+require "scripts/gugus/sliproDigits"
+require "scripts/gugus/speedlimiter"
+require "scripts/gugus/gear"
--- IMPORTANT:
--- this script will not be deleted by uninstalling the software
-
--- ================================
--- CONSTANTS
-
-
--- ================================
--- additional lua extension module dll
-
-
--- ================================
--- additional scripts file ( use 'require' statement )
-
-require "scripts/slipro_digits"
-
--- ================================
--- 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
+-- MANDATORY --
+function custom_initEvent(scriptFile)
+ print ( "\n" )
+ print ( "Loaded specific gugus scripts\n" )
+ print ( "\n" )
+ return 0
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/speedlimiter.lua b/scripts/speedlimiter.lua
index d579672..9382675 100644
--- a/scripts/speedlimiter.lua
+++ b/scripts/speedlimiter.lua
@@ -33,11 +33,9 @@ function spdLmtMethodEvent(idx)
-- get global prefs
GetSLIMaxInfo()
- if mSpdLimitMethod >= 2 then
- -- init table
- initLedTable(mRPMLedTable, 0)
- SetRPMLed("mRPMLedTable")
- end
+ -- init table
+ initLedTable(mRPMLedTable, 0)
+ SetRPMLed("mRPMLedTable")
if mNoBlink or (mSpdLimitMethod == 0) then
-- speedlimiter led NOT blinking