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