summaryrefslogtreecommitdiff
path: root/scripts/shiftlights.lua
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/shiftlights.lua')
-rw-r--r--scripts/shiftlights.lua200
1 files changed, 100 insertions, 100 deletions
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