Headlights also restore when vehicle is respawned
This commit is contained in:
@@ -78,7 +78,6 @@ local function getDiff(diffObj)
|
||||
end
|
||||
|
||||
local function openDiff(diffObj)
|
||||
print("Opening diff")
|
||||
local diff = getDiff(diffObj)
|
||||
if next(diff) == nil then
|
||||
return {}
|
||||
@@ -89,7 +88,6 @@ local function openDiff(diffObj)
|
||||
end
|
||||
|
||||
local function lockDiff(diffObj)
|
||||
print("Locking diff")
|
||||
local diff = getDiff(diffObj)
|
||||
if next(diff) == nil then
|
||||
return
|
||||
|
||||
@@ -28,7 +28,6 @@ end
|
||||
-- HeadLight handling
|
||||
----------------------------------------------------------------------------------------------------
|
||||
local function toggleHighBeams()
|
||||
print("toggling high beams")
|
||||
if currentHeadlightMode == highBeams then
|
||||
setHeadlightsTo(headlightsOff)
|
||||
else
|
||||
@@ -37,7 +36,6 @@ local function toggleHighBeams()
|
||||
end
|
||||
|
||||
local function toggleLowBeams()
|
||||
print("toggling low beams")
|
||||
if currentHeadlightMode == lowBeams then
|
||||
setHeadlightsTo(headlightsOff)
|
||||
else
|
||||
@@ -53,23 +51,25 @@ local lightbarOn = 1
|
||||
local lightbarWithSound = 2
|
||||
local lightbarCurrentMode = 0
|
||||
|
||||
|
||||
local function setLightbarMode(mode)
|
||||
electrics.set_lightbar_signal(mode)
|
||||
lightbarCurrentMode = mode
|
||||
end
|
||||
|
||||
local function turnLightbarLight()
|
||||
if lightbarCurrentMode == lightbarOn then
|
||||
electrics.set_lightbar_signal(lightbarOff)
|
||||
lightbarCurrentMode = lightbarOff
|
||||
setLightbarMode(lightbarOff)
|
||||
else
|
||||
electrics.set_lightbar_signal(lightbarOn)
|
||||
lightbarCurrentMode = lightbarOn
|
||||
setLightbarMode(lightbarOn)
|
||||
end
|
||||
end
|
||||
|
||||
local function turnLightbarSound()
|
||||
if lightbarCurrentMode == lightbarWithSound then
|
||||
electrics.set_lightbar_signal(lightbarOff)
|
||||
lightbarCurrentMode = lightbarOff
|
||||
setLightbarMode(lightbarOff)
|
||||
else
|
||||
electrics.set_lightbar_signal(lightbarWithSound)
|
||||
lightbarCurrentMode = lightbarWithSound
|
||||
setLightbarMode(lightbarWithSound)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -78,4 +78,27 @@ M.toggleLowBeams = toggleLowBeams
|
||||
M.toggleLigthbarLight = turnLightbarLight
|
||||
M.toggleLigthbarSound = turnLightbarSound
|
||||
|
||||
local myTimer = 0
|
||||
local requestToReset = false
|
||||
local function updateGFX(dt)
|
||||
if not requestToReset then
|
||||
return
|
||||
end
|
||||
|
||||
myTimer = myTimer + dt
|
||||
if myTimer > 1 then
|
||||
setLightbarMode(lightbarCurrentMode)
|
||||
requestToReset = false
|
||||
myTimer = 0
|
||||
end
|
||||
end
|
||||
|
||||
local function onReset()
|
||||
requestToReset = true
|
||||
end
|
||||
|
||||
|
||||
M.onReset = onReset
|
||||
M.updateGFX = updateGFX
|
||||
|
||||
return M
|
||||
@@ -84,12 +84,9 @@ M.turnStarter = turnStarter
|
||||
M.releaseStarter = releaseStarter
|
||||
|
||||
local function restoreIgnition(level)
|
||||
print("Restoring ignition to " .. level)
|
||||
if level == ignitionAcc then
|
||||
print("Setting ignition to acc")
|
||||
setIgnitionAcc()
|
||||
elseif level == ignitionOn then
|
||||
print("Setting ignition to on")
|
||||
setIgnitionOn()
|
||||
end
|
||||
end
|
||||
@@ -108,6 +105,7 @@ local function updateGFX(dt)
|
||||
myTimer = myTimer + dt
|
||||
if myTimer > 1 then
|
||||
restoreIgnition(curIgnitionPos)
|
||||
requestToReset = false
|
||||
myTimer = 0
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user