-- -- F936VARIO -- Specialization for F936VARIO mod -- -- @author Stefan Geiger -- @date 10/01/09 -- -- Copyright (C) GIANTS Software GmbH, Confidential, All Rights Reserved. F936VARIO = {}; function F936VARIO.prerequisitesPresent(specializations) return SpecializationUtil.hasSpecialization(Motorized, specializations); end; function F936VARIO:load(xmlFile) hornSoundFile = Utils.getFilename("sounds/horn.wav", self.baseDirectory); self.hornSoundId = createSample("famerCarSound"); loadSample(self.hornSoundId, hornSoundFile, false); self.hornPlaying = false; --[[Zusatzgewichte start]]-- self.extraWeights = Utils.getNoNil(getXMLInt(xmlFile, "vehicle.extraWeights#count"), 0); self.weights = {}; for i=1, self.extraWeights do local weightnamei = string.format("vehicle.extraWeights.weight%d", i); self.weights[i] = Utils.indexToObject(self.components, getXMLString(xmlFile, weightnamei .. "#index")); setVisibility(self.weights[i], false); end; self.currentWeight = 0; self.controlWeight = 0; self.singleWeight = 0; self.maxWeight = Utils.getNoNil(getXMLInt(xmlFile, "vehicle.maxWeight#weight"), 100); --[[Zusatzgewichte ende]]-- --[[Motorstart start]]-- self.ignitionKey = false; self.allowedIgnition = false; self.motorStopSoundVolume2 = Utils.getNoNil(getXMLFloat(xmlFile, "vehicle.motorStopSound#volume"), 1.0); --[[Motorstart ende]]-- --[[RMP Limiter start]]-- local motorMaxRpmStr = getXMLString(xmlFile, "vehicle.motor#maxRpm"); local motorMaxRpm1, motorMaxRpm2, motorMaxRpm3 = Utils.getVectorFromString(motorMaxRpmStr); motorMaxRpm1 = Utils.getNoNil(motorMaxRpm1, 800); motorMaxRpm2 = Utils.getNoNil(motorMaxRpm2, 1000); motorMaxRpm3 = Utils.getNoNil(motorMaxRpm3, 1800); local motorMaxRpm = {motorMaxRpm1, motorMaxRpm2, motorMaxRpm3}; self.motorMaxRpmLimit = motorMaxRpm; --[[RMP Limiter ende]]-- --[[Wheelhydraulik start]]-- self.drivingHydraulicCount = Utils.getNoNil(getXMLInt(xmlFile, "vehicle.drivingHydraulic#count"), 0); if self.drivingHydraulicCount == 0 then print("Error: No drivingHydraulics specified - Count: 0", configFile); end; self.drivingHydraulic = {}; for i=1, self.drivingHydraulicCount do local hydraulicName = string.format("vehicle.drivingHydraulic.drivingHydraulic%d", i); self.drivingHydraulic[i] = {}; self.drivingHydraulic[i].node = Utils.indexToObject(self.components, getXMLString(xmlFile, hydraulicName .. "#hydraulic")); self.drivingHydraulic[i].punch = Utils.indexToObject(self.components, getXMLString(xmlFile, hydraulicName .. "#hydraulicPunch")); self.drivingHydraulic[i].translationPunch = Utils.indexToObject(self.components, getXMLString(xmlFile, hydraulicName .. "#hydraulicPunchFixPoint")); self.drivingHydraulic[i].fenderFixPoint = Utils.indexToObject(self.components, getXMLString(xmlFile, hydraulicName .. "#fenderFixPoint")); local ax, ay, az = getWorldTranslation(self.drivingHydraulic[i].punch); local bx, by, bz = getWorldTranslation(self.drivingHydraulic[i].translationPunch); self.drivingHydraulic[i].punchDistance = Utils.vector3Length(ax-bx, ay-by, az-bz); end; --[[Wheelhydraulik start]]-- --[[Zwillingreifen start]]-- self.numTwinWheels = Utils.getNoNil(getXMLInt(xmlFile, "vehicle.twinWheels#count"), 0); self.twinWheels = {}; for i=1, self.numTwinWheels do local twinWheelnamei = string.format("vehicle.twinWheels.twinWheel" .. "%d", i); self.twinWheels[i] = Utils.indexToObject(self.rootNode, getXMLInt(xmlFile, twinWheelnamei .. "#index")); setVisibility(self.twinWheels[i], false); end; self.twinWheelsActive= false; --[[Zwillingreifen ende]]-- --[[Fieldmarker start]]-- local nummarkAreas = Utils.getNoNil(getXMLInt(xmlFile, "vehicle.markAreas#count"), 0); self.markAreas = {} for i=1, nummarkAreas do self.markAreas[i] = {}; local areanamei = string.format("vehicle.markAreas.markAreas%d", i); self.markAreas[i].point = Utils.indexToObject(self.components, getXMLString(xmlFile, areanamei .. "#pointIndex")); self.markAreas[i].width = Utils.getNoNil(getXMLFloat(xmlFile, areanamei .. "#width"), 0.55) self.markAreas[i].height = Utils.getNoNil(getXMLFloat(xmlFile, areanamei .. "#height"), 0.25) end; --[[Fieldmarker ende]]-- --[[Bewegliche Kupplung start]]-- local translationNode1 = Utils.indexToObject(self.rootNode, getXMLString(xmlFile, "vehicle.translation1#index")); if translationNode1 ~= nil then self.translation1 = {}; self.translation1.node = translationNode1; local x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.translation1#minTrans")); self.translation1.minTrans = {}; self.translation1.minTrans[1] = Utils.getNoNil(x, 0); self.translation1.minTrans[2] = Utils.getNoNil(y, 0); self.translation1.minTrans[3] = Utils.getNoNil(z, 0); x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.translation1#maxTrans")); self.translation1.maxTrans = {}; self.translation1.maxTrans[1] = Utils.getNoNil(x, 0); self.translation1.maxTrans[2] = Utils.getNoNil(y, 0); self.translation1.maxTrans[3] = Utils.getNoNil(z, 0); self.translation1.transTime = Utils.getNoNil(getXMLString(xmlFile, "vehicle.translation1#transTime"), 2)*1000; self.translation1.touchTransLimit = Utils.getNoNil(getXMLString(xmlFile, "vehicle.translation1#touchTransLimit"), 10); end; --[[Bewegliche Kupplung ende]]-- --[[Scheibenwischer start]]-- local rotationPartNodeWischer = Utils.indexToObject(self.rootNode, getXMLString(xmlFile, "vehicle.rotationPartWischer#index")); if rotationPartNodeWischer ~= nil then self.rotationPartWischer = {}; self.rotationPartWischer.node = rotationPartNodeWischer; local x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotationPartWischer#minRot")); self.rotationPartWischer.minRot = {}; self.rotationPartWischer.minRot[1] = Utils.degToRad(Utils.getNoNil(x, 0)); self.rotationPartWischer.minRot[2] = Utils.degToRad(Utils.getNoNil(y, 0)); self.rotationPartWischer.minRot[3] = Utils.degToRad(Utils.getNoNil(z, 0)); x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotationPartWischer#maxRot")); self.rotationPartWischer.maxRot = {}; self.rotationPartWischer.maxRot[1] = Utils.degToRad(Utils.getNoNil(x, 0)); self.rotationPartWischer.maxRot[2] = Utils.degToRad(Utils.getNoNil(y, 0)); self.rotationPartWischer.maxRot[3] = Utils.degToRad(Utils.getNoNil(z, 0)); self.rotationPartWischer.rotTime = Utils.getNoNil(getXMLString(xmlFile, "vehicle.rotationPartWischer#rotTime"), 2)*1000; self.rotationPartWischer.touchRotLimit = Utils.degToRad(Utils.getNoNil(getXMLString(xmlFile, "vehicle.rotationPartWischer#touchRotLimit"), 10)); end; local rotationPartNodeWischerblatt = Utils.indexToObject(self.rootNode, getXMLString(xmlFile, "vehicle.rotationPartWischerblatt#index")); if rotationPartNodeWischerblatt ~= nil then self.rotationPartWischerblatt = {}; self.rotationPartWischerblatt.node = rotationPartNodeWischerblatt; local x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotationPartWischerblatt#minRot")); self.rotationPartWischerblatt.minRot = {}; self.rotationPartWischerblatt.minRot[1] = Utils.degToRad(Utils.getNoNil(x, 0)); self.rotationPartWischerblatt.minRot[2] = Utils.degToRad(Utils.getNoNil(y, 0)); self.rotationPartWischerblatt.minRot[3] = Utils.degToRad(Utils.getNoNil(z, 0)); x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotationPartWischerblatt#maxRot")); self.rotationPartWischerblatt.maxRot = {}; self.rotationPartWischerblatt.maxRot[1] = Utils.degToRad(Utils.getNoNil(x, 0)); self.rotationPartWischerblatt.maxRot[2] = Utils.degToRad(Utils.getNoNil(y, 0)); self.rotationPartWischerblatt.maxRot[3] = Utils.degToRad(Utils.getNoNil(z, 0)); self.rotationPartWischerblatt.rotTime = Utils.getNoNil(getXMLString(xmlFile, "vehicle.rotationPartWischerblatt#rotTime"), 2)*1000; self.rotationPartWischerblatt.touchRotLimit = Utils.degToRad(Utils.getNoNil(getXMLString(xmlFile, "vehicle.rotationPartWischerblatt#touchRotLimit"), 10)); end; self.delayWischer1 = 0; self.delayWischer2 = 0; --[[Scheibenwischer ende]]-- --[[Spiegel start]]-- local rotationPartNodeSpiegelR = Utils.indexToObject(self.rootNode, getXMLString(xmlFile, "vehicle.rotationPartSpiegelR#index")); if rotationPartNodeSpiegelR ~= nil then self.rotationPartSpiegelR = {}; self.rotationPartSpiegelR.node = rotationPartNodeSpiegelR; local x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotationPartSpiegelR#minRot")); self.rotationPartSpiegelR.minRot = {}; self.rotationPartSpiegelR.minRot[1] = Utils.degToRad(Utils.getNoNil(x, 0)); self.rotationPartSpiegelR.minRot[2] = Utils.degToRad(Utils.getNoNil(y, 0)); self.rotationPartSpiegelR.minRot[3] = Utils.degToRad(Utils.getNoNil(z, 0)); x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotationPartSpiegelR#maxRot")); self.rotationPartSpiegelR.maxRot = {}; self.rotationPartSpiegelR.maxRot[1] = Utils.degToRad(Utils.getNoNil(x, 0)); self.rotationPartSpiegelR.maxRot[2] = Utils.degToRad(Utils.getNoNil(y, 0)); self.rotationPartSpiegelR.maxRot[3] = Utils.degToRad(Utils.getNoNil(z, 0)); self.rotationPartSpiegelR.rotTime = Utils.getNoNil(getXMLString(xmlFile, "vehicle.rotationPartSpiegelR#rotTime"), 2)*1000; self.rotationPartSpiegelR.touchRotLimit = Utils.degToRad(Utils.getNoNil(getXMLString(xmlFile, "vehicle.rotationPartSpiegelR#touchRotLimit"), 10)); end; local rotationPartNodeSpiegelL = Utils.indexToObject(self.rootNode, getXMLString(xmlFile, "vehicle.rotationPartSpiegelL#index")); if rotationPartNodeSpiegelL ~= nil then self.rotationPartSpiegelL = {}; self.rotationPartSpiegelL.node = rotationPartNodeSpiegelL; local x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotationPartSpiegelL#minRot")); self.rotationPartSpiegelL.minRot = {}; self.rotationPartSpiegelL.minRot[1] = Utils.degToRad(Utils.getNoNil(x, 0)); self.rotationPartSpiegelL.minRot[2] = Utils.degToRad(Utils.getNoNil(y, 0)); self.rotationPartSpiegelL.minRot[3] = Utils.degToRad(Utils.getNoNil(z, 0)); x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotationPartSpiegelL#maxRot")); self.rotationPartSpiegelL.maxRot = {}; self.rotationPartSpiegelL.maxRot[1] = Utils.degToRad(Utils.getNoNil(x, 0)); self.rotationPartSpiegelL.maxRot[2] = Utils.degToRad(Utils.getNoNil(y, 0)); self.rotationPartSpiegelL.maxRot[3] = Utils.degToRad(Utils.getNoNil(z, 0)); self.rotationPartSpiegelL.rotTime = Utils.getNoNil(getXMLString(xmlFile, "vehicle.rotationPartSpiegelL#rotTime"), 2)*1000; self.rotationPartSpiegelL.touchRotLimit = Utils.degToRad(Utils.getNoNil(getXMLString(xmlFile, "vehicle.rotationPartSpiegelL#touchRotLimit"), 10)); end; --[[Spiegel ende]]-- --[[Rundumleuchte start]]-- self.rundumleuchtenAnz = Utils.getNoNil(getXMLInt(xmlFile, "vehicle.rundumleuchten#count"),0); self.rundumleuchtenAn = false; self.rundumleuchten = {}; for i=1, self.rundumleuchtenAnz do local objname = string.format("vehicle.rundumleuchten.light" .. "%d",i); self.rundumleuchten[i] = {}; self.rundumleuchten[i].rotNode = Utils.indexToObject(self.rootNode, getXMLString(xmlFile, objname .. "#rotNode")); self.rundumleuchten[i].light = Utils.indexToObject(self.rootNode, getXMLString(xmlFile, objname .. "#light")); self.rundumleuchten[i].source = Utils.indexToObject(self.rootNode, getXMLString(xmlFile, objname .. "#lightsource")); self.rundumleuchten[i].speed = Utils.getNoNil(getXMLInt(xmlFile, objname .. "#rotSpeed"), 1)/1000; self.rundumleuchten[i].emit = Utils.getNoNil(getXMLBool(xmlFile, objname .. "#emitLight"), true); if not self.rundumleuchten[i].emit and self.rundumleuchten[i].source ~= nil then setVisibility(self.rundumleuchten[i].source, false); end; end; --[[Rundumleuchte ende]]-- --[[Arbeitslicht Vorne start]]-- self.numFrontlights = Utils.getNoNil(getXMLInt(xmlFile, "vehicle.frontlights#count"), 0); self.frontlights = {}; for i=1, self.numFrontlights do local frontlightnamei = string.format("vehicle.frontlights.frontlight" .. "%d", i); self.frontlights[i] = Utils.indexToObject(self.rootNode, getXMLInt(xmlFile, frontlightnamei .. "#index")); setVisibility(self.frontlights[i], false); end; self.frontlightsActive = false; --[[Arbeitslicht Vorne ende]]-- --[[Fernlicht start]]-- self.numFarlights = Utils.getNoNil(getXMLInt(xmlFile, "vehicle.farlights#count"), 0); self.farlights = {}; for i=1, self.numFarlights do local farlightnamei = string.format("vehicle.farlights.farlight" .. "%d", i); self.farlights[i] = Utils.indexToObject(self.rootNode, getXMLInt(xmlFile, farlightnamei .. "#index")); setVisibility(self.farlights[i], false); end; self.farlightsActive = false; --[[Fernlicht ende]]-- --[[Arbeitslicht Hinten start]]-- self.numBacklights = Utils.getNoNil(getXMLInt(xmlFile, "vehicle.backlights#count"), 0); self.backlights = {}; for i=1, self.numBacklights do local backlightnamei = string.format("vehicle.backlights.backlight" .. "%d", i); self.backlights[i] = Utils.indexToObject(self.rootNode, getXMLInt(xmlFile, backlightnamei .. "#index")); setVisibility(self.backlights[i], false); end; self.backlightsActive = false; --[[Arbeitslicht Hinten ende]]-- --[[Rückfahrlicht start]]---------------------------------------------------------- self.numReverselights = Utils.getNoNil(getXMLInt(xmlFile, "vehicle.reverselights#count"), 0); self.reverselights = {}; for i=1, self.numReverselights do local reverselightnamei = string.format("vehicle.reverselights.reverselight" .. "%d", i); self.reverselights[i] = Utils.indexToObject(self.rootNode, getXMLInt(xmlFile, reverselightnamei .. "#index")); setVisibility(self.reverselights[i], false); end; self.reverselightsActive = false; --[[Rückfahrlicht ende]]-- --[[Bremse/Bremslicht start]]-- self.brakeForce = Utils.getNoNil(getXMLFloat(xmlFile, "vehicle.brakeForce"), 10); self.motorBrakeForce = self.motor.brakeForce; local brakeSound = getXMLString(xmlFile, "vehicle.brakeSound#file"); if brakeSound ~= nil and brakeSound ~= "" then brakeSound = Utils.getFilename(brakeSound, self.baseDirectory); self.brakeSound = createSample("brakeSound"); loadSample(self.brakeSound, brakeSound, false); self.brakeSoundPitchOffset = Utils.getNoNil(getXMLFloat(xmlFile, "vehicle.brakeSound#pitchOffset"), 0); end; self.extra_lights = {}; self.lightsbrake = Utils.indexToObject(self.rootNode, getXMLString(xmlFile, "vehicle.extra_lights.brake#index")); self.exhaustParticleLow = {}; Utils.loadParticleSystem(xmlFile, self.exhaustParticleLow, "vehicle.exhaustParticleLow", self.rootNode, false, nil, self.baseDirectory); self.exhaustParticleHigh = {}; Utils.loadParticleSystem(xmlFile, self.exhaustParticleHigh, "vehicle.exhaustParticleHigh", self.rootNode, false, nil, self.baseDirectory); self.brakeOn = false; self.revLimit = 100; self.maxRpm3 = self.motor.maxRpm[3]; --[[Bremse/Bremslicht ende]]-- --[[Blinker start]]-- turn1SoundFile = Utils.getFilename("sounds/turn1.wav", self.baseDirectory); self.turn1 = createSample("turn1"); loadSample(self.turn1, turn1SoundFile, false); turn2SoundFile = Utils.getFilename("sounds/turn2.wav", self.baseDirectory); self.turn2 = createSample("turn2"); loadSample(self.turn2, turn2SoundFile, false); self.numTurnlights = Utils.getNoNil(getXMLInt(xmlFile, "vehicle.turnlights#count"), 0); self.turnlights = {}; for i=1, self.numTurnlights do local turnlightnamei = string.format("vehicle.turnlights.turnlight" .. "%d", i); self.turnlights[i] = Utils.indexToObject(self.rootNode, getXMLInt(xmlFile, turnlightnamei .. "#index")); setVisibility(self.turnlights[i], false); end; self.turnlightsActive = false; self.numTurnlights2 = Utils.getNoNil(getXMLInt(xmlFile, "vehicle.turnlights2#count"), 0); self.turnlights2 = {}; for i=1, self.numTurnlights2 do local turnlightnamei2 = string.format("vehicle.turnlights2.turnlight" .. "%d", i); self.turnlights2[i] = Utils.indexToObject(self.rootNode, getXMLInt(xmlFile, turnlightnamei2 .. "#index")); setVisibility(self.turnlights2[i], false); end; self.turnlightsActive2 = false; --[[Blinker ende]]-- --[[für Tasten, die in der Modxml festgelegt werden]]-- self.keys = {}; local i=0; while true do local baseName = string.format("vehicle.keys.input(%d)", i); local inputName = getXMLString(xmlFile, baseName.. "#name"); if inputName == nil then break; end; local inputKey = getXMLString(xmlFile, baseName.. "#key"); if Input[inputKey] == nil then print("Error: invalid key '" .. inputKey .. "' for input event '" .. inputName .. "'"); break; end; self.keys[inputName] = Input[inputKey]; i = i+1; end; --[[Tastenbelegung und Textausgabe wird in modDesc festgelegt]]-- self.keyType = InputBinding.getButtonKeyName; self.keyName = " "; end; function F936VARIO:delete() delete(self.hornSoundId); end; function F936VARIO:mouseEvent(posX, posY, isDown, isUp, button) end; function F936VARIO:keyEvent(unicode, sym, modifier, isDown) --[[Zwillingsreifen start]]-- if InputBinding.isPressed(InputBinding.F936VARIO_TWINS) then self.twinWheelsActive = not self.twinWheelsActive; end; --[[Zwillingsreifen ende]]-- --[[Arbeitslicht/Rückfahrlicht start]]-- if InputBinding.isPressed(InputBinding.F936VARIO_FRONTLIGHT) then self.frontlightsActive = not self.frontlightsActive; self.farlightsActive = false; self.backlightsActive = false; end; if InputBinding.isPressed(InputBinding.F936VARIO_FARLIGHT) then self.farlightsActive = not self.farlightsActive; self.frontlightsActive = false; self.backlightsActive = false; end; if InputBinding.isPressed(InputBinding.F936VARIO_REARLIGHT) then self.backlightsActive = not self.backlightsActive; self.farlightsActive = false; self.frontlightsActive = false; end; --[[Arbeitslicht/Rückfahrlicht ende]]-- --[[Blinker start]]-- --[[Blinker Rechts]]-- if InputBinding.isPressed(InputBinding.F936VARIO_TURNRIGHTLIGHT) then self.flashLeft = not self.flashLeft; self.delayOnLeft = 10; self.flashRight = false; self.flash = false; self.flashlightsRightActive = false; self.flashlightsWarnerActive = false; self.flashlightsRight2Active = false; self.turnlightsActive2 = false; self.flashWarner = false; end; --[[Warnblinker]]-- if InputBinding.isPressed(InputBinding.F936VARIO_WARNLIGHT) then self.flash = not self.flash; self.flashRight = false; self.flashLeft = false; self.delayOn = 20; self.flashlightsRightActive = false; self.flashlightsLeftActive = false; self.flashWarner = not self.flashWarner; end; --[[Blinker Links]]-- if InputBinding.isPressed(InputBinding.F936VARIO_TURNLEFTLIGHT) then self.flashRight = not self.flashRight; self.delayOnRight = 10; self.flashLeft = false; self.flash = false; self.flashlightsLeftActive = false; self.flashlightsWarnerActive = false; self.flashlightsLeft2Active = false; self.turnlightsActive = false; self.flashWarner = false; end; --[[Blinker ende]]-- --[[Rundumleuchte start]]-- if InputBinding.isPressed(InputBinding.F936VARIO_RUNDUM) then self.rundumleuchtenAn = not self.rundumleuchtenAn; for i=1, self.rundumleuchtenAnz do setVisibility(self.rundumleuchten[i].light, self.rundumleuchtenAn); end; end; --[[Rundumleuchte ende]]-- --[[Bewegliche Kupplung start]]-- if sym == Input.KEY_pageup then self.translation1Max = isDown; end; if sym == Input.KEY_pagedown then self.translation1Min = isDown; end; --[[Bewegliche Kupplung ende]]-- if InputBinding.isPressed(InputBinding.F936VARIO_HELP) then self.helpPanel = not self.helpPanel; end; --[[Hilfeanzeige start]]-- if InputBinding.isPressed(InputBinding.F936VARIO_LIGHTHELP) then self.lighthelpPanel = not self.lighthelpPanel; end; end; function F936VARIO:update(dt) if self:getIsActiveForInput() and self:getIsActiveForSound() and InputBinding.isPressed(InputBinding.F936VARIO_HUPE) then if not self.hornPlaying then playSample(self.hornSoundId, 0, 1, 0); self.hornPlaying = true; end; else if self.hornPlaying then stopSample(self.hornSoundId); self.hornPlaying = false; end; end; --[[Motorstart start]]-- if not self.isAITractorActivated then if self:getIsActiveForInput() then if InputBinding.hasEvent(InputBinding.F936VARIO_IGNITION) then self.ignitionKey = not self.ignitionKey; self.allowedIgnition = true; end; end; if not self.allowedIgnition and not self.ignitionKey then self.isMotorStarted = false; Motorized.stopSounds(self); self.steeringEnabled = false; Utils.setEmittingState(self.exhaustParticleSystems, false) end; if not self.ignitionKey then self.motorStopSoundVolume = 0; else self.motorStopSoundVolume = self.motorStopSoundVolume2; end; if self.allowedIgnition then if not self.ignitionKey then self.motorStopSoundVolume = self.motorStopSoundVolume2; self:stopMotor(); self.steeringEnabled = false; self.allowedIgnition = false; for k,wheel in pairs(self.wheels) do setWheelShapeProps(wheel.node, wheel.wheelShape, 0, self.motor.brakeForce, 0); end; self:onDeactivateAttachements(); elseif self.ignitionKey then self:startMotor(); self.steeringEnabled = true; self.allowedIgnition = false; end; end; elseif not self.ignitionKey and not self.deactivateOnLeave then self:stopAITractor(); end; --[[Motorstart ende]]-- --[[RMP Limiter start]]-- if self.isMotorStarted and self:getIsActiveForInput() and self.isEntered then if self.motor.speedLevel ~= 0 then if InputBinding.isPressed(InputBinding.ACCELERATE) then if self.motor.maxRpm[self.motor.speedLevel] <= (self.motorMaxRpmLimit[3] - 10) then self.motor.maxRpm[self.motor.speedLevel] = self.motor.maxRpm[self.motor.speedLevel] + 10; end; elseif InputBinding.isPressed(InputBinding.DECELERATE) then if self.motor.maxRpm[self.motor.speedLevel] >= 10 then self.motor.maxRpm[self.motor.speedLevel] = self.motor.maxRpm[self.motor.speedLevel] - 10; end; end; else if InputBinding.isPressed(InputBinding.ACCELERATE) then if self.motor.maxRpm[3] <= (self.motorMaxRpmLimit[3] - 10) then self.motor.maxRpm[3] = self.motor.maxRpm[3] + 10; end; elseif InputBinding.isPressed(InputBinding.DECELERATE) then if self.motor.maxRpm[3] >= 10 then self.motor.maxRpm[3] = self.motor.maxRpm[3] - 10; end; end; end; --[[RMP Limiter ende]]-- --[[Gaslimiter start]]-- if self:getIsActiveForInput() then if InputBinding.isPressed(InputBinding.F936VARIO_MORERPM) then self.motor.minRpm = self.motor.minRpm - 100; elseif InputBinding.isPressed(InputBinding.F936VARIO_LESSRPM) then self.motor.minRpm = self.motor.minRpm + 100; end; end; if self.isEntered then if self.motor.minRpm < -1600 then self.motor.minRpm = -1600; elseif self.motor.minRpm > 200 then self.motor.minRpm = 200; end; end; --[[Gaslimiter ende]]-- --[[Wheelhydraulik start]]-- for i=1, table.getn(self.drivingHydraulic) do local ax, ay, az = getWorldTranslation(self.drivingHydraulic[i].node); local bx, by, bz = getWorldTranslation(self.drivingHydraulic[i].fenderFixPoint); local x, y, z = worldDirectionToLocal(getParent(self.drivingHydraulic[i].node), bx-ax, by-ay, bz-az); setDirection(self.drivingHydraulic[i].node, x, y, z, 0, 1, 0); if self.drivingHydraulic[i].punch ~= nil then local distance = Utils.vector3Length(ax-bx, ay-by, az-bz); setTranslation(self.drivingHydraulic[i].punch, 0, 0, distance-self.drivingHydraulic[i].punchDistance); end; end; --[[Wheelhydraulik ende]]-- --[[Bremse/Bremslicht start]]-- if self.isEntered then self.motor.maxRpm[3] = string.format("%d",(self.revLimit * self.maxRpm3 / 100)); local brake = false; if self.motor.brakeForce == self.brakeForce and getInputAxis(Input.AXIS_Y) ~= 0 then brake = true; self.motor.maxRpm[3] = 0; end; if (self.movingDirection*self.lastSpeed*(-getInputAxis(Input.AXIS_Y))) < -0.001 then brake = true; self.brakeOn = true; self.motor.brakeForce = self.brakeForce; elseif not brake then self.motor.brakeForce = self.motorBrakeForce; end; setVisibility(self.lightsbrake, brake); if self.brakeOn and not brake then if self.brakeSound ~= nil then setSamplePitch(self.brakeSound, self.brakeSoundPitchOffset); playSample(self.brakeSound, 1, 1, 0); end; self.brakeOn = false; end; if getInputAxis(Input.AXIS_Y) ~= 0 and not brake then Utils.setEmittingState(self.exhaustParticleLow, false); Utils.setEmittingState(self.exhaustParticleHigh, true); else Utils.setEmittingState(self.exhaustParticleLow, false); Utils.setEmittingState(self.exhaustParticleHigh, false); end; end; --[[Bremse/Bremslicht ende]]-- --[[Zwillingsreifen start]]-- if self.twinWheelsActive then for i=1, self.numTwinWheels do local twinWheel = self.twinWheels[i]; setVisibility(twinWheel, self.twinWheelsActive); end; else for i=1, self.numTwinWheels do local twinWheel = self.twinWheels[i]; setVisibility(twinWheel, self.twinWheelsActive, false); end; end; --[[Zwillingreifen ende]]-- --[[Bwegliche Kupplung start]]-- local doTranslate = self.translation1Max or self.translation1Min if self.translation1 ~= nil and doTranslate then local x, y, z = getTranslation(self.translation1.node); local trans = {x,y,z}; local newTrans = Utils.getMovedLimitedValues(trans, self.translation1.maxTrans, self.translation1.minTrans, 3, self.translation1.transTime, dt, not self.translation1Max); setTranslation(self.translation1.node, unpack(newTrans)); end; --[[Bewegliche Kupplung ende]]-- --[[Scheibenwischer start]]-- if self.isEntered then if g_currentMission.environment.lastRainScale <= 0.1 and g_currentMission.environment.timeSinceLastRain > 30 then self.rainWarning = false; else self.rainWarning = true; end; if self.rainWarning and self.isMotorStarted then if self.delayWischer1 >= 0 then self.delayWischer1 = self.delayWischer1 -dt; end; if self.delayWischer2 >= 0 then self.delayWischer2 = self.delayWischer2 -dt; end; if not self.rotationMaxWischer then if self.delayWischer1 < 0 then self.delayWischer2 = 1000; self.rotationMaxWischer = true; self.rotationMaxWischerblatt = true; end; end; if self.rotationMaxWischer then if self.delayWischer2 < 0 then self.delayWischer1 = 1000; self.rotationMaxWischer = false; self.rotationMaxWischerblatt = false; end; end; else self.rotationMaxWischer = false; self.rotationMaxWischerblatt = false; end; end; if self.rotationPartWischer ~= nil then local x, y, z = getRotation(self.rotationPartWischer.node); local rot = {x,y,z}; local newRot = Utils.getMovedLimitedValues(rot, self.rotationPartWischer.maxRot, self.rotationPartWischer.minRot, 3, self.rotationPartWischer.rotTime, dt, not self.rotationMaxWischer); setRotation(self.rotationPartWischer.node, unpack(newRot)); end; if self.rotationPartWischerblatt ~= nil then local x, y, z = getRotation(self.rotationPartWischerblatt.node); local rot = {x,y,z}; local newRot = Utils.getMovedLimitedValues(rot, self.rotationPartWischerblatt.maxRot, self.rotationPartWischerblatt.minRot, 3, self.rotationPartWischerblatt.rotTime, dt, not self.rotationMaxWischerblatt); setRotation(self.rotationPartWischerblatt.node, unpack(newRot)); end; --[[Scheibenwischer ende]]-- --[[Spiegel start]]-- if self.isMotorStarted then self.rotationMaxSpiegelR = true elseif not self.isMotorStarted then self.rotationMaxSpiegelR = false end; if self.rotationPartSpiegelR ~= nil then local x, y, z = getRotation(self.rotationPartSpiegelR.node); local rot = {x,y,z}; local newRot = Utils.getMovedLimitedValues(rot, self.rotationPartSpiegelR.maxRot, self.rotationPartSpiegelR.minRot, 3, self.rotationPartSpiegelR.rotTime, dt, not self.rotationMaxSpiegelR); setRotation(self.rotationPartSpiegelR.node, unpack(newRot)); end; if self.isMotorStarted then self.rotationMaxSpiegelL = true elseif not self.isMotorStarted then self.rotationMaxSpiegelL = false end; if self.rotationPartSpiegelL ~= nil then local x, y, z = getRotation(self.rotationPartSpiegelL.node); local rot = {x,y,z}; local newRot = Utils.getMovedLimitedValues(rot, self.rotationPartSpiegelL.maxRot, self.rotationPartSpiegelL.minRot, 3, self.rotationPartSpiegelL.rotTime, dt, not self.rotationMaxSpiegelL); setRotation(self.rotationPartSpiegelL.node, unpack(newRot)); end; --[[Spiegel ende]]-- --[[Arbeitslicht Vorne start]]---------------------------------------- if self.frontlightsActive then for i=1, self.numFrontlights do local frontlight = self.frontlights[i]; setVisibility(frontlight, self.frontlightsActive); end; else for i=1, self.numFrontlights do local frontlight = self.frontlights[i]; setVisibility(frontlight, self.frontlightsActive, false); end; end; --[[Arbeitslicht Vorne ende]]------------------------------------------ --[[Fernlicht start]]---------------------------------------- if self.farlightsActive then for i=1, self.numFarlights do local farlight = self.farlights[i]; setVisibility(farlight, self.farlightsActive); end; else for i=1, self.numFarlights do local farlight = self.farlights[i]; setVisibility(farlight, self.farlightsActive, false); end; end; --[[Fernlicht ende]]------------------------------------------ --[[Arbeitslicht/Rückfahrlicht start]]---------------------------------------- if not self.reverselightsActive then if self.movingDirection < 0 then self.reverselightsActive = true; else self.reverselightsActive = false; end; end; if self.backlightsActive then for i=1, self.numBacklights do local backlight = self.backlights[i]; setVisibility(backlight, self.backlightsActive); end; else for i=1, self.numBacklights do local backlight = self.backlights[i]; setVisibility(backlight, self.backlightsActive, false); end; end; --[[Arbeitslicht/Rückfahrlicht ende]]-- --[[AI Nightlight start]]-- if g_currentMission.environment ~= nil and g_currentMission.environment.dayNightCycle and (g_currentMission.environment.dayTime > (20.5*1000*60*60) or g_currentMission.environment.dayTime < (5.5*1000*60*60)) and not self.lightsActive and self.isHired and not self.steeringEnabled then self.lightsActive = true; end; if not self.isHired and self.lightsActive and not self.isEntered or not g_currentMission.environment.dayNightCycle then self.lightsActive = false; end; for k, light in pairs(self.lights) do setVisibility(light, self.lightsActive); end; --[[AI Nightlight ende]]-- --[[Blinker start]]-- if self.flash then if self.delayOn >= 0 then self.delayOn = self.delayOn -dt; end; if not self.flashlightsRightActive then if self.delayOn < 0 then self.delayOff = 500; self.flashlightsRightActive = true; self.flashlightsLeftActive = true; self.flashlightsWarnerActive = true; self.turnlightsActive2 = true; self.turnlightsActive = true; playSample(self.turn1, 1, 0.7, 0); end; end; if self.delayOff >= 0 then self.delayOff = self.delayOff -dt; end; if self.flashlightsRightActive then if self.delayOff < 0 then self.delayOn = 500; self.flashlightsLeftActive = false; self.flashlightsRightActive = false; self.flashlightsWarnerActive = false; self.turnlightsActive2 = false; self.turnlightsActive = false; playSample(self.turn2, 1, 0.7, 0); end; end; end; if self.flashRight then if self.delayOnRight >= 0 then self.delayOnRight = self.delayOnRight -dt; end; if not self.flashlightsRightActive then if self.delayOnRight < 0 then self.delayOffRight = 500; self.flashlightsRightActive = true; self.turnlightsActive2 = true; playSample(self.turn1,1,0.7,0); end; end; if self.delayOffRight >= 0 then self.delayOffRight = self.delayOffRight -dt; end; if self.flashlightsRightActive then if self.delayOffRight < 0 then self.delayOnRight = 500; self.flashlightsRightActive = false; self.turnlightsActive2 = false; playSample(self.turn2,1,0.7,0); end; end; else if not self.flashWarner then self.turnlightsActive2 = false; end; end; if self.flashLeft then if self.delayOnLeft >= -1 then self.delayOnLeft = self.delayOnLeft -dt; end; if not self.flashlightsLeftActive then if self.delayOnLeft < 0 then self.delayOffLeft = 500; self.flashlightsLeftActive = true; self.turnlightsActive = true; playSample(self.turn1,1,0.7,0); end; end; if self.delayOffLeft >= 0 then self.delayOffLeft = self.delayOffLeft -dt; end; if self.flashlightsLeftActive then if self.delayOffLeft < 0 then self.delayOnLeft = 500; self.flashlightsLeftActive = false; self.turnlightsActive = false; playSample(self.turn2,1,0.7,0); end; end; else if not self.flashWarner then self.turnlightsActive = false; end; end; if self.turnlightsActive then for i=1, self.numTurnlights do local turnlight = self.turnlights[i]; setVisibility(turnlight, self.turnlightsActive); end; else for i=1, self.numTurnlights do local turnlight = self.turnlights[i]; setVisibility(turnlight, self.turnlightsActive, false); end; end; if self.turnlightsActive2 then for i=1, self.numTurnlights2 do local turnlight2 = self.turnlights2[i]; setVisibility(turnlight2, self.turnlightsActive2); end; else for i=1, self.numTurnlights2 do local turnlight2 = self.turnlights2[i]; setVisibility(turnlight2, self.turnlightsActive2, false); end; end; --[[Blinker ende]]-- --[[Fieldmarker start]]-- if self:getIsActiveForInput() and InputBinding.hasEvent(InputBinding.F936VARIO_FIELDMARKER) then self.markOn = not self.markOn; end; if self.markOn then for k, markAreas in pairs(self.markAreas) do local x,y,z = getWorldTranslation(markAreas.point); local w = markAreas.width; local h = markAreas.height; local x1 = x + h/2 local x2 = x - h/2 local z1 = z + w/2 local z2 = z - w/2 Utils.cutFruitArea( 1, x1, z2, x1, z1, x2, z2); Utils.cutFruitArea( 2, x1, z2, x1, z1, x2, z2); Utils.cutFruitArea( 3, x1, z2, x1, z1, x2, z2); Utils.cutFruitArea( 4, x1, z2, x1, z1, x2, z2); Utils.cutFruitArea( 5, x1, z2, x1, z1, x2, z2); Utils.updateMeadowArea(x1, z2, x1, z1, x2, z2); Utils.updateCuttedMeadowArea(x1, z2, x1, z1, x2, z2); end; end; --[[Fieldmarker ende]]-- --[[Zusatzgewichte start]]-- if self.isEntered then self.singleWeight = (self.maxWeight / self.extraWeights); if InputBinding.hasEvent(InputBinding.F936VARIO_WEIGHT_ACTIVE) then if self.currentWeight >= self.maxWeight then self.currentWeight = 0; else self.currentWeight = self.currentWeight + self.singleWeight; end; end; if self.weights ~= nil then if self.currentWeight ~= self.controlWeight then self.controlWeight = self.currentWeight; if self.currentWeight > 0 then for i = 1, self.extraWeights do if i * self.singleWeight <= self.currentWeight then setVisibility(self.weights[i], true); end; end; else for i = 1, self.extraWeights do setVisibility(self.weights[i], false); end; end; end; if self.emptyMass == nil then self.emptyMass = getMass(self.components[1].node); self.currentMass = self.emptyMass; end; local newMass = self.emptyMass + self.currentWeight; if newMass ~= self.currentMass then setMass(self.components[1].node, newMass); self.currentMass = newMass; for k,v in pairs(self.components) do if v.node == self.components[1].node then if v.centerOfMass ~= nil then setCenterOfMass(v.node, v.centerOfMass[1], v.centerOfMass[2], v.centerOfMass[3]); end; break; end; end; end; end; end; --[[Zusatzgewichte ende]]-- --[[Rundumleuchte start]]-- if self.rundumleuchtenAn then for i=1, self.rundumleuchtenAnz do rotate(self.rundumleuchten[i].rotNode, 0, dt*self.rundumleuchten[i].speed, 0); end; end; --[[Rundumleuchte ende]]-- end; function F936VARIO:draw() if self.isMotorStarted then if self.motor.speedLevel ~= 0 then g_currentMission:addExtraPrintText("Taste NUM +/-: "..string.format("%d RPM",self.motor.maxRpm[self.motor.speedLevel])..""); else g_currentMission:addExtraPrintText("Taste NUM +/-: "..string.format("%d RPM",self.motor.maxRpm[3])..""); end; end; if self.isMotorStarted then g_currentMission:addExtraPrintText(string.format("Taste %s/%s: %s", InputBinding.getButtonKeyName(InputBinding.F936VARIO_MORERPM), InputBinding.getButtonKeyName(InputBinding.F936VARIO_LESSRPM), g_i18n:getText("F936VARIO_Gas"))); end; if self.isEntered then setTextBold(true); if not self.isMotorStarted and not self.automaticStart then renderText(0.8, 0.17, 0.02, self.keyName.. " " ..self.keyType(InputBinding.F936VARIO_IGNITION).. ": " ..g_i18n:getText("F936VARIO_Start")); end; if self.isMotorStarted then if not self.helpPanel then renderText(0.8335, 0.15, 0.02, self.keyName.. " " ..self.keyType(InputBinding.F936VARIO_HELP).. ": " ..g_i18n:getText("F936VARIO_Info1")); else renderText(0.8335, 0.15, 0.02, self.keyName.. " " ..self.keyType(InputBinding.F936VARIO_HELP).. ": " ..g_i18n:getText("F936VARIO_Info2")); end; if self.helpPanel then renderText(0.72, 0.89, 0.025, "- Fendt 936 Info -"); renderText(0.72, 0.875, 0.02, self.keyName.. " " ..self.keyType(InputBinding.F936VARIO_HUPE).. ": " ..g_i18n:getText("F936VARIO_HORN")); renderText(0.72, 0.86, 0.02, " Bildauf: Kupplung Heben");--[[Feste Tastenbelegung]]-- renderText(0.72, 0.845, 0.02, " Bildab: Kupplung Senken");--[[Feste Tastenbelegung]]-- renderText(0.72, 0.83, 0.02, self.keyName.. " " ..self.keyType(InputBinding.F936VARIO_WEIGHT_ACTIVE).. ": " ..string.format("%d kg", self.currentWeight*5)); if self.markOn then renderText(0.72, 0.815, 0.02, self.keyName.. " " ..self.keyType(InputBinding.F936VARIO_FIELDMARKER).. ": " ..g_i18n:getText("F936VARIO_Feld1")); else renderText(0.72, 0.815, 0.02, self.keyName.. " " ..self.keyType(InputBinding.F936VARIO_FIELDMARKER).. ": " ..g_i18n:getText("F936VARIO_Feld2")); end; if self.twinWheelsActive then renderText(0.72, 0.8, 0.02, self.keyName.. " " ..self.keyType(InputBinding.F936VARIO_TWINS).. ": " ..g_i18n:getText("F936VARIO_Twins1")); else renderText(0.72, 0.8, 0.02, self.keyName.. " " ..self.keyType(InputBinding.F936VARIO_TWINS).. ": " ..g_i18n:getText("F936VARIO_Twins2")); end; end; end; if self.isMotorStarted then if not self.lighthelpPanel then renderText(0.8, 0.17, 0.02, self.keyName.. " " ..self.keyType(InputBinding.F936VARIO_LIGHTHELP).. ": " ..g_i18n:getText("F936VARIO_LichtInfo1")); else renderText(0.8, 0.17, 0.02, self.keyName.. " " ..self.keyType(InputBinding.F936VARIO_LIGHTHELP).. ": " ..g_i18n:getText("F936VARIO_LichtInfo2")); end; if self.lighthelpPanel then renderText(0.72, 0.77, 0.025, "- LichtInfo -"); if self.frontlightsActive then renderText(0.72, 0.755, 0.02, self.keyName.. " " ..self.keyType(InputBinding.F936VARIO_FRONTLIGHT).. ": " ..g_i18n:getText("F936VARIO_Arbeitslicht1")); else renderText(0.72, 0.755, 0.02, self.keyName.. " " ..self.keyType(InputBinding.F936VARIO_FRONTLIGHT).. ": " ..g_i18n:getText("F936VARIO_Arbeitslicht2")); end; if self.farlightsActive then renderText(0.72, 0.74, 0.02, self.keyName.. " " ..self.keyType(InputBinding.F936VARIO_FARLIGHT).. ": " ..g_i18n:getText("F936VARIO_Fernlicht1")); else renderText(0.72, 0.74, 0.02, self.keyName.. " " ..self.keyType(InputBinding.F936VARIO_FARLIGHT).. ": " ..g_i18n:getText("F936VARIO_Fernlicht2")); end; if self.backlightsActive then renderText(0.72, 0.725, 0.02, self.keyName.. " " ..self.keyType(InputBinding.F936VARIO_REARLIGHT).. ": " ..g_i18n:getText("F936VARIO_Arbeitslicht3")); else renderText(0.72, 0.725, 0.02, self.keyName.. " " ..self.keyType(InputBinding.F936VARIO_REARLIGHT).. ": " ..g_i18n:getText("F936VARIO_Arbeitslicht4")); end; if self.rundumleuchtenAn then renderText(0.72, 0.71, 0.02, self.keyName.. " " ..self.keyType(InputBinding.F936VARIO_RUNDUM).. ": " ..g_i18n:getText("F936VARIO_Rundum1")); else renderText(0.72, 0.71, 0.02, self.keyName.. " " ..self.keyType(InputBinding.F936VARIO_RUNDUM).. ": " ..g_i18n:getText("F936VARIO_Rundum2")); end; if not self.flashLeft then renderText(0.72, 0.695, 0.02, self.keyName.. " " ..self.keyType(InputBinding.F936VARIO_TURNRIGHTLIGHT).. ": " ..g_i18n:getText("F936VARIO_Blinkerrechts1")); elseif self.flashLeft then renderText(0.72, 0.695, 0.02, self.keyName.. " " ..self.keyType(InputBinding.F936VARIO_TURNRIGHTLIGHT).. ": " ..g_i18n:getText("F936VARIO_Blinkerrechts2")); end; if not self.flash then renderText(0.72, 0.68, 0.02, self.keyName.. " " ..self.keyType(InputBinding.F936VARIO_WARNLIGHT).. ": " ..g_i18n:getText("F936VARIO_Warnblinker1")); elseif self.flash then renderText(0.72, 0.68, 0.02, self.keyName.. " " ..self.keyType(InputBinding.F936VARIO_WARNLIGHT).. ": " ..g_i18n:getText("F936VARIO_Warnblinker2")); end; if not self.flashRight then renderText(0.72, 0.665, 0.02, self.keyName.. " " ..self.keyType(InputBinding.F936VARIO_TURNLEFTLIGHT).. ": " ..g_i18n:getText("F936VARIO_Blinkerlinks1")); elseif self.flashRight then renderText(0.72, 0.665, 0.02, self.keyName.. " " ..self.keyType(InputBinding.F936VARIO_TURNLEFTLIGHT).. ": " ..g_i18n:getText("F936VARIO_Blinkerlinks2")); end; end; end; setTextBold(false); end; end; --[[Gaslimiter start]]-- function F936VARIO:stopMotor() self.motor.minRpm = 200; end; --[[Gaslimiter ende]]-- function F936VARIO:onEnter() Utils.setEmittingState(self.exhaustParticleLow, false); end; function F936VARIO:onLeave() if not self.deactivateOnLeave then self.allowedIgnition = false; self.ignitionKey = true; else self.allowedIgnition = false; self.ignitionKey = false; end; self.frontlightsActive = false; self.farlightsActive = false; self.backlightsActive = false; for i=1, self.rundumleuchtenAnz do setVisibility(self.rundumleuchten[i].light, self.rundumleuchtenAn); end; Utils.setEmittingState(self.exhaustParticleLow, false); self.weightActive = false; end; function F936VARIO:validateAttacherJoint(implement, jointDesc, dt) return true; end; --[[Tasten werden hier im Script festgelegt / Unter der "draw"-funktion Textausgabe eintragen]]-- function key_convert(key) if key ~= nil then local keyname = ""; if key > 32 and key < 123 then keyname = string.upper(string.char(key)); elseif key > 255 and key < 266 then keyname = "NUM "..string.char(key-208); else keyname = ""; end; return(keyname); end; end; end;