Category | Scripting |
Created | 21.01.2012 16:29 |
Lukas Tichy (Unknown) | 21.01.2012 16:32 |
---|---|
Hello I use this script for depicted a dashboard fuel light but dashboard fuel light don“t lighting Liaz180 = {}; function Liaz180.prerequisitesPresent(specializations) return SpecializationUtil.hasSpecialization(Motorized, specializations); end; function Liaz180:load(xmlFile) self.updateFuelIndicators = SpecializationUtil.callSpecializationsFunction("updateFuelIndicators"); -- Dashboard indicators self.dashboardFuel = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.dashboardFuel#index")); self.dashboardParkingBrake = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.dashboardParkingBrake#index")); self.dashboardBattery = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.dashboardBattery#index")); self.dashboardEngineThing1 = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.dashboardEngineThing1#index")); self.dashboardEngineThing2 = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.dashboardEngineThing2#index")); end; function Liaz180:updateTick(dt) if self.isMotorStarted then if self.fuelFillLevel < 50 then setVisibility(self.dashboardFuel, true); else setVisibility(self.dashboardFuel, false); end; if self.dashboardParkingBrake ~= nil then if self.handbrake then setVisibility(self.dashboardParkingBrake, true); else setVisibility(self.dashboardParkingBrake, false); end; end; end; if self:getIsActive() then if self.ignitionMode == 0 then if self.dashboardParkingBrake ~= nil then setVisibility(self.dashboardParkingBrake, false); end; if self.dashboardFuel ~= nil then setVisibility(self.dashboardFuel, false); end; elseif self.ignitionMode == 1 then if self.dashboardBattery ~= nil then setVisibility(self.dashboardBattery, true); end; if self.dashboardEngineThing1 ~= nil then setVisibility(self.dashboardEngineThing1, true); end; if self.dashboardEngineThing2 ~= nil then setVisibility(self.dashboardEngineThing2, true); end; if self.dashboardParkingBrake ~= nil then setVisibility(self.dashboardParkingBrake, true); end; if self.oilLight ~= nil then setVisibility(self.oilLight, true); end; if self.dashboardFuel ~= nil then setVisibility(self.dashboardFuel, true); end; elseif self.ignitionMode == 2 then if self.dashboardBattery ~= nil then setVisibility(self.dashboardBattery, false); end; if self.dashboardEngineThing1 ~= nil then setVisibility(self.dashboardEngineThing1, false); end; if self.dashboardEngineThing2 ~= nil then setVisibility(self.dashboardEngineThing2, false); end; if self.oilLight ~= nil then setVisibility(self.oilLight, false); end; if self.dashboardFuel ~= nil then setVisibility(self.dashboardFuel, false); end; end; end; end; Please help me, where is the problem. Thank you. |
Ludovic Fritz (mrludo40) | 15.03.2012 16:55 |
---|---|
hello, here is a code snippet Exemple = {}; function Exemple.prerequisitesPresent(specializations) return SpecializationUtil.hasSpecialization(Motorized, specializations); end; function Exemple:load(xmlFile) self.updateFuelIndicators = SpecializationUtil.callSpecializationsFunction("updateFuelIndicators"); self.ledriserva = Utils.indexToObject(self.rootNode, getXMLString(xmlFile, "vehicle.ledriserva#index")); self.ledriservaActive = false; self.riserva = 100; self.prevousFuelPercentage = 0; self.cos = 20000; end; function Exemple:update(dt) if self.isEntered then if self.fuelFillLevel < 120 then self.riserva = self.riserva - dt; if self.riserva <= 120 then playSample(self.fuelwarningSoundId,1,1,0); self.riserva = 30000; end; self.ledriservaActive = true; else self.riserva = 30000; self.ledriservaActive = false; end; setVisibility(self.ledriserva,self.ledriservaActive); self:updateFuelIndicators(); end; end; function Exemple:updateFuelIndicators() local amountOfFuelPerIndicator = self.fuelCapacity/11; 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 Fendt936serie:updateTick(dt) if self:getIsActive() then if self.isMotorStarted then setVisibility(self.fuelIndicatorsGroup, true); else setVisibility(self.fuelIndicatorsGroup, false); end; end; end; and for xml <fuelIndicators count="11" index="0>27|6|7"> <fuelIndicator1 rotNode="0>27|6|7|0"/> <fuelIndicator2 rotNode="0>27|6|7|1"/> <fuelIndicator3 rotNode="0>27|6|7|2"/> <fuelIndicator4 rotNode="0>27|6|7|3"/> <fuelIndicator5 rotNode="0>27|6|7|4"/> <fuelIndicator6 rotNode="0>27|6|7|5"/> <fuelIndicator7 rotNode="0>27|6|7|6"/> <fuelIndicator8 rotNode="0>27|6|7|7"/> <fuelIndicator9 rotNode="0>27|6|7|8"/> <fuelIndicator10 rotNode="0>27|6|7|9"/> <fuelIndicator11 rotNode="0>27|6|7|10"/> </fuelIndicators> for example |
Note: Log in to post. Create a new account here.