summaryrefslogtreecommitdiff
path: root/scripts/gear.lua
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/gear.lua')
-rwxr-xr-xscripts/gear.lua67
1 files changed, 55 insertions, 12 deletions
diff --git a/scripts/gear.lua b/scripts/gear.lua
index d7cb61e..88dad9f 100755
--- a/scripts/gear.lua
+++ b/scripts/gear.lua
@@ -1,7 +1,7 @@
--- SLIMax Mgr Lua Script v2
--- Copyright (c)2011-2013 by EK and Zappadoc - All Rights Reserved.
+-- SLIMax Mgr Lua Script v3
+-- Copyright (c)2012-2013 by Zappadoc - All Rights Reserved.
-- gear event
--- last change by Zappadoc - 2012-04-08
+-- last change by Zappadoc - 2013-02-15
-- SLI-M, SLI-PRO Gear Event
function gearEvent(gear)
@@ -27,7 +27,7 @@ function gearEvent(gear)
if result <= 1 then return result end
local g = gear
- if oldGear == nil then oldGear = GetContextInfo("neutral") end
+ if oldGear == nil then oldGear = -1 end
-- get neutral
local n = GetContextInfo("neutral")
@@ -35,9 +35,11 @@ function gearEvent(gear)
local r = string.char(GetContextInfo("reverse"))
-- get state of custom Optimal Shift Point (OSP) records
local ospcustom_on = GetContextInfo("ospcustom")
-
+
-- optimize display, call if changed
- if oldGear ~= g or g == 0 then
+ if oldGear ~= g then
+ -- backup gear state
+ oldGear = g
-- set neutral, reverse or current gear
if g == 0 then
-- if neutral and using custom OSP record then add a dot to gear digit
@@ -46,20 +48,61 @@ function gearEvent(gear)
elseif g < 0 then
SetGearDigit(r)
else
- -- if gear = 'E' give the hand to SLIMax Manager II
+ -- if gear = 'E' give the hand to SLIMax Manager
if g == 69 then
return 0
end
SetGearDigit(string.char(g))
end
-
+ end
+
+ return 1
+end
- -- print( string.format("Gear: %d\n", gear))
+-- Fanatec Gear Event
+function gearFanatecEvent(gear)
+ -- get the rpm limit already computed by my OSP method
+ -- using OSP Factor parameter
+ -- value used in OSP, Shiftlights, car setup,... and can be overwritten
+ gOSPLimit = 0
+ gOSPLimit = GetContextInfo("osplimitrpm")
+ if gOSPLimit == nil then gOSPLimit = 0 end
+
+ -- get the red zone already computed by my SLIMax Mgr
+ -- value used in Shiftlights and can be overwritten
+ gRedZone = 0
+ gRedZone = GetCarInfo("redzone")
+ if gRedZone == nil then gRedZone = 18000 end
+
+ -- call custom script
+ local result = custom_gearEvent(gear)
+ if result <= 1 then return result end
+
+ -- call global custom script
+ result = global_custom_gearEvent(gear)
+ if result <= 1 then return result end
+
+ local g = gear
+ if oldGear == nil then oldGear = -1 end
+
+ if oldGear ~= g then
+ local rumbbleGear = GetContextInfo("gearshock")
+ local rumbbleGearDelay = GetContextInfo("gearshockdelay")
+
+ -- gear schock effect restricted to 1 to 7
+ if rumbbleGear and g > 0 then
+ if g < oldGear then
+ SetFanatecWheelMotor(0, 100, rumbbleGearDelay)
+ elseif g > oldGear then
+ SetFanatecWheelMotor(1, 100, rumbbleGearDelay)
+ end
+ end
+
+ -- backup gear state
+ oldGear = g
end
- -- backup gear state
- oldGear = g
return 1
-end \ No newline at end of file
+end