--
--fueldisplay Specialization
--zeigt den Tankfüllstand in Leds an - 8 Leds leuchten Tank voll
--weniger als 15 l im Tank wird ein Warnton ausgegeben und ein Reserve Symbol im Dashboard leuchtet auf
--
--ModDes.xml
--
--
--
--Vehicle.xml
--
--
--
--
--
--
--
--
--
--
--
--
--
fueldisplay = {};
function fueldisplay.prerequisitesPresent(specializations)
return SpecializationUtil.hasSpecialization(Motorized, specializations);
end;
function fueldisplay:load(xmlFile)
self.updateFuelIndicators = SpecializationUtil.callSpecializationsFunction("updateFuelIndicators");
self.ledreserve = Utils.indexToObject(self.rootNode, getXMLString(xmlFile, "vehicle.ledreserve#index"));
self.ledreserveActive = false;
self.reserve = 15;
self.fuelIndicatorsGroup = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.fuelIndicators#index"));
self.numFuelIndicators = Utils.getNoNil(getXMLInt(xmlFile, "vehicle.fuelIndicators#count"), 0);
self.fuelIndicators = {};
for i=1, self.numFuelIndicators do
local objname = string.format("vehicle.fuelIndicators.fuelIndicator" .. "%d", i);
self.fuelIndicators[i] = {};
self.fuelIndicators[i].rotNode = Utils.indexToObject(self.components, getXMLString(xmlFile, objname .. "#rotNode"));
setVisibility(self.fuelIndicators[i].rotNode,true);
end;
fuelwarningSoundFile = Utils.getFilename("Sounds/fuelwarning.wav", self.baseDirectory);
self.fuelwarningSoundId = createSample("fuelwarningSound");
loadSample(self.fuelwarningSoundId, fuelwarningSoundFile, false);
self.fuelwarningPlaying = false;
self.playedSound = false;
end;
function fueldisplay:delete()
end;
function fueldisplay:mouseEvent(posX, posY, isDown, isUp, button)
end;
function fueldisplay:keyEvent(unicode, sym, modifier, isDown)
end;
function fueldisplay:update(dt)
if self.isEntered then
if self.fuelFillLevel < 15 then --wenn weniger als 15l im Tank Beep Beep und Reserve Led leuchtet
self.reserve = self.reserve - dt;
if self.playedSound == false then
playSample(self.fuelwarningSoundId,1,1,0);
self.playedSound = true;
end;
self.ledreserveActive = true;
else
self.playedSound = false;
self.ledreserveActive = false;
end;
setVisibility(self.ledreserve,self.ledreserveActive);
self:updateFuelIndicators();
end;
end;
function fueldisplay:updateTick(dt)
if self:getIsActive() then
if self.isMotorStarted then
setVisibility(self.fuelIndicatorsGroup, true);
else
setVisibility(self.fuelIndicatorsGroup, false);
end;
end;
end;
function fueldisplay:updateFuelIndicators()
local amountOfFuelPerIndicator = self.fuelCapacity/8; --Anzahl der Indicatoren in der Vehicle.xml
local timesToIterate = self.fuelFillLevel/amountOfFuelPerIndicator;
timesToIterate = math.floor(timesToIterate);
if self.oldTimesToIterate ~= timesToIterate then
for i=1, self.numFuelIndicators do
setVisibility(self.fuelIndicators[i].rotNode, false);
end;
for i=1, timesToIterate do
setVisibility(self.fuelIndicators[i].rotNode, true);
end;
end;
self.oldTimesToIterate = timesToIterate;
end;
function fueldisplay:draw()
end;