summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugues Hiegel <hugues@hiegel.fr>2013-11-20 03:42:19 +0100
committerHugues Hiegel <hugues@hiegel.fr>2013-11-20 03:42:19 +0100
commit9495c1a909d12294979803959dcb001f1d011141 (patch)
tree53d69a7a023818571ed48ca015e35c713c9f73a8
parent90556f8566691d1be6d19333e317e94936c4f1bb (diff)
[gugus] ignignignignigngition
-rw-r--r--scripts/gugus/gear.lua99
1 files changed, 75 insertions, 24 deletions
diff --git a/scripts/gugus/gear.lua b/scripts/gugus/gear.lua
index 57820e6..079f428 100644
--- a/scripts/gugus/gear.lua
+++ b/scripts/gugus/gear.lua
@@ -1,37 +1,88 @@
+mIgnitionTicks = nil
+oldIgnition = nil
+oldGear = nil
+
+function Ignition(gear, isFanatec)
+ -- print ( " Gear : " .. gear )
+ local ignition = GetCarInfo("ignition")
+
+ --print ( string.format("gear %d/ignition %d" , g, ignition))
+
+ if isFanatec == false then
+ SetLeftDigits(" ")
+ SetRightDigits(" ")
+ else
+ SetfanatecDigits(" ")
+ end
+
+ toggleAllLed(0)
+
+ if ignition == 2 then
+ -- Ignition ON, Starting engine
+ initLedTable(mRPMLedTable, 1)
+ SetRPMLed("mRPMLedTable")
+ else
+ -- Ignition ON, Engine OFF
+ initLedTable(mRPMLedTable, 0)
+ SetRPMLed("mRPMLedTable")
+
+ -- blink damage led
+ if mIgnitionTicks == nil or GetTicks() > mIgnitionTicks then
+ mIgnitionTicks = GetTicks() + 1000
+ SetWarnLed(GetLedIndex("damage"), 1)
+ end
+ end
+
+ if ignition == 0 and GetContextInfo("simulation") == "rFactor2.exe" then
+ -- Don¿t display gear when Ignition OFF
+ SetGearDigit(" ")
+ else
+ -- Ignition ON (or can¿t tell on other sims)
+ SetGearDigit(GetCurrentGear())
+ end
+
+ SLISendReport(1)
+
+ -- bypasses gearEvent
+ return 1
+end
+
function custom_gearEvent(gear)
- -- manage gear when ´E´
+
+ -- 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")
+
if gear == 69 then
- local ignition = GetCarInfo("ignition")
+ -- specific case when gear == 'E'
+
local g = GetCarInfo("gear")
+ oldGear = g
- --print ( string.format("gear %d/ignition %d" , g, ignition))
+ Ignition(g, false)
- toggleAllLed(0)
+ return 1
- if ignition == 2 then
- initLedTable(mRPMLedTable, 1)
- SetRPMLed("mRPMLedTable")
- SetLeftDigits("[ ]")
- SetRightDigits("[ ]")
+ elseif oldGear == nil or oldGear ~= gear then
+ -- backup gear state
+ oldGear = gear
+ -- set neutral, reverse or current gear
+ if gear == 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 gear < 0 then
+ SetGearDigit(r)
else
- initLedTable(mRPMLedTable, 0)
- SetRPMLed("mRPMLedTable")
- SetLeftDigits(" ")
- SetRightDigits(" ")
- end
-
- if ignition == 0 and GetContextInfo("simulation") == "rFactor2.exe" then
- SetGearDigit(" ")
- elseif ignition == 1 then
- SetGearDigit(GetCurrentGear())
+ SetGearDigit(string.char(gear))
end
-
- SLISendReport(1)
- return 1
end
- return 2
+ return 1
end
-print ( "gugus> + gear" )
+print ( "gugus> + gear (ignition)" )