--Specjalizacja dla : Ursus1614 By Marcello1942
--#Autor: marcello1942
--#data: 15/05/2013 r.

Ursus1614 = {};

function Ursus1614.prerequisitesPresent(specializations)
    return SpecializationUtil.hasSpecialization(Motorized, specializations);
end;

function Ursus1614:load(xmlFile)

	local klapalewa = Utils.indexToObject(self.rootNode, getXMLString(xmlFile, "vehicle.lok#lewe"));
	if klapalewa ~= nil then
		self.klapalewa = klapalewa;
	end;
		local klapaprawa = Utils.indexToObject(self.rootNode, getXMLString(xmlFile, "vehicle.lok#prawe"));
	if klapaprawa ~= nil then
		self.klapaprawa = klapaprawa;
	end;
		local zaczep = Utils.indexToObject(self.rootNode, getXMLString(xmlFile, "vehicle.lok#zaczep"));
	if zaczep ~= nil then
		self.zaczep = zaczep;
	end;
		local pompka = Utils.indexToObject(self.rootNode, getXMLString(xmlFile, "vehicle.lok#pompka"));
	if pompka ~= nil then
		self.pompka = pompka;
	end;
	local one = Utils.indexToObject(self.rootNode, getXMLString(xmlFile, "vehicle.lok#one"));
	if one ~= nil then
		self.one = one;
	end;
	local two = Utils.indexToObject(self.rootNode, getXMLString(xmlFile, "vehicle.lok#two"));
	if two ~= nil then
		self.two = two;
	end;
	local three = Utils.indexToObject(self.rootNode, getXMLString(xmlFile, "vehicle.lok#three"));
	if three ~= nil then
		self.three = three;
	end;
	local four = Utils.indexToObject(self.rootNode, getXMLString(xmlFile, "vehicle.lok#four"));
	if four ~= nil then
		self.four = four;
	end;
	local szyba = Utils.indexToObject(self.rootNode, getXMLString(xmlFile, "vehicle.lok#szyba"));
	if szyba ~= nil then
		self.szyba = szyba;
	end;
	local right = Utils.indexToObject(self.rootNode, getXMLString(xmlFile, "vehicle.lok#right"));
	if right ~= nil then
		self.right = right;
	end;
	local left = Utils.indexToObject(self.rootNode, getXMLString(xmlFile, "vehicle.lok#left"));
	if left ~= nil then
		self.left = left;
	end;
	local compressor = Utils.indexToObject(self.rootNode, getXMLString(xmlFile, "vehicle.lok#compressor"));
	if compressor ~= nil then
		self.compressor = compressor;
	end;
	local maska = Utils.indexToObject(self.rootNode, getXMLString(xmlFile, "vehicle.lok#maska"));
	if maska ~= nil then
		self.maska = maska;
	end;
	local korek = Utils.indexToObject(self.rootNode, getXMLString(xmlFile, "vehicle.lok#korek"));
	if korek ~= nil then
		self.korek = korek;
	end;
	
	
	self.klapkaoff = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.klapka#off"));
	self.klapkaon = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.klapka#on"));
	self.bolec1 = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.bolec#front"));
	self.bolec2 = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.bolec#rear"));
	self.indicatoroff = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.indicator#off"));
	self.indicatoron = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.indicator#on"));
	self.blysk = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.kogut#index"));
	setVisibility((self.klapkaoff), true);
	setVisibility((self.klapkaon), false);
	setVisibility((self.indicatoron), true);
	setVisibility((self.indicatoroff), false);
	setVisibility((self.blysk), false);
	setVisibility((self.bolec1), true);
	setVisibility((self.bolec2), true);
	
	self.exhaustingSystem = {}
    self.exhaustingSystem.flap = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.exhaustParticleSystems#flap"))
    self.exhaustingSystem.maxRot = Utils.degToRad(Utils.getNoNil(getXMLFloat(xmlFile, "vehicle.exhaustParticleSystems#maxRot"), 0))
    self.exhaustingSystem.maxRpm = self.motor:getMaxRpm()
	
	self.steamParticleSystems = {};
	local steamParticleSystemsCount = Utils.getNoNil(getXMLInt(xmlFile, "vehicle.steamParticleSystems#count"), 0);
	for i=1, steamParticleSystemsCount do
		local namei = string.format("vehicle.steamParticleSystems.steamParticleSystem%d", i);
		Utils.loadParticleSystem(xmlFile, self.steamParticleSystems, namei, self.components, false, nil, self.baseDirectory)
	end;
	
	self.rpm = {}
    self.rpm.mod = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.rpm#index"))
    self.rpm.maxRot = Utils.degToRad(Utils.getNoNil(getXMLFloat(xmlFile, "vehicle.rpm#maxRot"), 0))
    self.rpm.maxRpm = self.motor:getMaxRpm()
	
	self.fuelLevel = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.fuelLevel#index"));
	self.fuelLevelMaxRot = Utils.getNoNil(getXMLFloat(xmlFile, "vehicle.fuelLevel#maxRot"), 0);
	
	self.belts = {};
       	local i = 0;
       	while true do
        local key = string.format("vehicle.belts.belt(%d)", i);

        if not hasXMLProperty(xmlFile, key) then
           break;
        end;

        local node = Utils.indexToObject(self.components, getXMLString(xmlFile, key.."#index"));
        local speed = Utils.getVectorNFromString(getXMLString(xmlFile, key.."#speed"), 2);
        if node ~= nil and speed then
            table.insert(self.belts, {node=node, speed=speed});
        end;
	    i = i +1;
        end;

	

  	local hydraulicsCount = Utils.getNoNil(getXMLInt(xmlFile, "vehicle.hydraulics#count"), 0);
	self.hydraulics = {};
	for i=1, hydraulicsCount do
		local hydraulicName = string.format("vehicle.hydraulics.hydraulic%d", i);
		self.hydraulics[i] = {};
		self.hydraulics[i].node = Utils.indexToObject(self.components, getXMLString(xmlFile, hydraulicName .. "#index"));
		self.hydraulics[i].punch = Utils.indexToObject(self.components, getXMLString(xmlFile, hydraulicName .. "#punch"));
		self.hydraulics[i].translationPunch = Utils.indexToObject(self.components, getXMLString(xmlFile, hydraulicName .. "#punchFixpoint"));
		self.hydraulics[i].fixPoint = Utils.indexToObject(self.components, getXMLString(xmlFile, hydraulicName .. "#fixpoint"));
		local xUp, yUp, zUp = Utils.getVectorFromString(Utils.getNoNil(getXMLString(xmlFile, hydraulicName .. "#upVectors"),"0 1 0"));
		self.hydraulics[i].upVectors = {xUp, yUp, zUp};

		local ax, ay, az;
		if self.hydraulics[i].punch ~= nil then
			ax, ay, az = getWorldTranslation(self.hydraulics[i].punch);
		else
			ax, ay, az = getWorldTranslation(self.hydraulics[i].node);
		end;
		if self.hydraulics[i].translationPunch ~= nil then
			local bx, by, bz = getWorldTranslation(self.hydraulics[i].translationPunch);
			self.hydraulics[i].punchDistance = Utils.vector3Length(ax-bx, ay-by, az-bz);
		end;
	end;
	self.setHydraulicTime = 30;
    self.setHydraulicDirection = SpecializationUtil.callSpecializationsFunction("setHydraulicDirection");
    self.otworz = false
	self.zamknij = false
	
	
	local rotationLifter = Utils.indexToObject(self.rootNode, getXMLString(xmlFile, "vehicle.Lifter#index"));
	self.Lifter = {};
	self.Lifter.node = rotationLifter;

	local rotationLifterArm = Utils.indexToObject(self.rootNode, getXMLString(xmlFile, "vehicle.LifterArm#index"));
	self.LifterArm = {};
	self.LifterArm.node = rotationLifterArm;

	local rotationLifterBottom = Utils.indexToObject(self.rootNode, getXMLString(xmlFile, "vehicle.LifterBottom#index"));
	self.bottomArm2 = {};
	self.bottomArm2.node = rotationLifterBottom;
	
	
	local shaftCount = Utils.getNoNil(getXMLInt(xmlFile, "vehicle.drivingPowerShafts#count"), 0);
    self.drivingPowerShafts = {};
    for i=1, shaftCount do
		local shaft = {};
        local shaftName = string.format("vehicle.drivingPowerShafts.powerShaft%d", i);
		shaft.node = Utils.indexToObject(self.components, getXMLString(xmlFile, shaftName .. "#index"));		
		shaft.trans = Utils.getNoNil(getXMLFloat(xmlFile, shaftName .. "#translation"), 0);
		local x,y,z = getTranslation(getParent(shaft.node));
		shaft.orgTrans = {x,y,z};
		shaft.rot = Utils.degToRad(Utils.getNoNil(getXMLFloat(xmlFile, shaftName .. "#rotation"), 0));	
		shaft.speedFactor = Utils.getNoNil(getXMLFloat(xmlFile, shaftName .. "#speedFactor"), 2);
		table.insert(self.drivingPowerShafts, shaft);        
    end;
	
	
	hor12nSoundFile = Utils.getFilename("sounds/otworzdrzwi.wav", self.baseDirectory);
    self.hor12nSoundId = createSample("LizardHor12nSound");
    loadSample(self.hor12nSoundId, hor12nSoundFile, false);
    self.hor12nPlaying = false;
	
	openSoundFile = Utils.getFilename("sounds/otworzdrzwi.wav", self.baseDirectory);
    self.openSoundId = createSample("LizardHor12nSound");
    loadSample(self.openSoundId, openSoundFile, false);
    self.openPlaying = false;
	
	clouseSoundFile = Utils.getFilename("sounds/zamknijdrzwi.wav", self.baseDirectory);
    self.clouseSoundId = createSample("LizardHor12nSound");
    loadSample(self.clouseSoundId, clouseSoundFile, false);
    self.clousePlaying = false;
    
    hor123nSoundFile = Utils.getFilename("sounds/zamknijdrzwi.wav", self.baseDirectory);
    self.hor123nSoundId = createSample("LizardHor123nSound");
    loadSample(self.hor123nSoundId, hor123nSoundFile, false);
    self.hor123nPlaying = false;
	
	hor1234nSoundFile = Utils.getFilename("sounds/bieg1.wav", self.baseDirectory);
    self.hor1234nSoundId = createSample("LizardHor123nSound");
    loadSample(self.hor1234nSoundId, hor1234nSoundFile, false);
    self.hor1234nPlaying = false;
	
	hor12345nSoundFile = Utils.getFilename("sounds/bieg2.wav", self.baseDirectory);
    self.hor12345nSoundId = createSample("LizardHor123nSound");
    loadSample(self.hor12345nSoundId, hor12345nSoundFile, false);
    self.hor12345nPlaying = false;
	
	hor123456nSoundFile = Utils.getFilename("sounds/bieg1.wav", self.baseDirectory);
    self.hor123456nSoundId = createSample("LizardHor123nSound");
    loadSample(self.hor123456nSoundId, hor123456nSoundFile, false);
    self.hor123456nPlaying = false;
	
	hor1234567nSoundFile = Utils.getFilename("sounds/bieg1.wav", self.baseDirectory);
    self.hor1234567nSoundId = createSample("LizardHor123nSound");
    loadSample(self.hor1234567nSoundId, hor1234567nSoundFile, false);
    self.hor1234567nPlaying = false;
	
	hor12345678nSoundFile = Utils.getFilename("sounds/bieg2.wav", self.baseDirectory);
    self.hor12345678nSoundId = createSample("LizardHor123nSound");
    loadSample(self.hor12345687nSoundId, hor12345678nSoundFile, false);
    self.hor12345678nPlaying = false;
	
	horn2SoundFile = Utils.getFilename("sounds/bieg1.wav", self.baseDirectory);
    self.horn2SoundId = createSample("LizardHor123nSound");
    loadSample(self.horn2SoundId, horn2SoundFile, false);
    self.horn2Playing = false;
	
	dach_downSoundFile = Utils.getFilename("sounds/dach_down.wav", self.baseDirectory);
    self.dach_downSoundId = createSample("LizardHor12nSound");
    loadSample(self.dach_downSoundId, dach_downSoundFile, false);
    self.dach_downPlaying = false;
	
	dach_upSoundFile = Utils.getFilename("sounds/dach_up.wav", self.baseDirectory);
    self.dach_upSoundId = createSample("LizardHor12nSound");
    loadSample(self.dach_upSoundId, dach_upSoundFile, false);
    self.dach_upPlaying = false;
	
	wajchaSoundFile = Utils.getFilename("sounds/wajcha.wav", self.baseDirectory);
    self.wajchaSoundId = createSample("LizardHor12nSound");
    loadSample(self.wajchaSoundId, wajchaSoundFile, false);
    self.wajchaPlaying = false;
	
	wajcha1SoundFile = Utils.getFilename("sounds/wajcha.wav", self.baseDirectory);
    self.wajcha1SoundId = createSample("LizardHor12nSound");
    loadSample(self.wajcha1SoundId, wajcha1SoundFile, false);
    self.wajcha1Playing = false;
	
	podnosnikSoundFile = Utils.getFilename("sounds/podnosnik.wav", self.baseDirectory);
    self.podnosnikSoundId = createSample("LizardHor12nSound");
    loadSample(self.podnosnikSoundId, podnosnikSoundFile, false);
    self.podnosnikPlaying = false;
	
	wycieraczkaSoundFile = Utils.getFilename("sounds/wycieraczka.wav", self.baseDirectory);
    self.wycieraczkaSoundId = createSample("LizardHor12nSound");
    loadSample(self.wycieraczkaSoundId, wycieraczkaSoundFile, false);
    self.wycieraczkaPlaying = false;
	
	pstrykSoundFile = Utils.getFilename("sounds/pstryk.wav", self.baseDirectory);
    self.pstrykSoundId = createSample("LizardHor12nSound");
    loadSample(self.pstrykSoundId, pstrykSoundFile, false);
    self.pstrykPlaying = false;
	
	pstryk1SoundFile = Utils.getFilename("sounds/pstryk.wav", self.baseDirectory);
    self.pstryk1SoundId = createSample("LizardHor12nSound");
    loadSample(self.pstryk1SoundId, pstryk1SoundFile, false);
    self.pstryk1Playing = false;
	
	bolecSoundFile = Utils.getFilename("sounds/bolec.wav", self.baseDirectory);
    self.bolecSoundId = createSample("LizardHor12nSound");
    loadSample(self.bolecSoundId, bolecSoundFile, false);
    self.bolecPlaying = false;
	
	bolec2SoundFile = Utils.getFilename("sounds/bolec.wav", self.baseDirectory);
    self.bolec2SoundId = createSample("LizardHor12nSound");
    loadSample(self.bolec2SoundId, bolec2SoundFile, false);
    self.bolec2Playing = false;
	
	compressorSoundFile = Utils.getFilename("sounds/compressor.wav", self.baseDirectory);
    self.compressorSoundId = createSample("LizardHor12nSound");
    loadSample(self.compressorSoundId, compressorSoundFile, false);
    self.compressorPlaying = false;
	
	brakeSoundFile = Utils.getFilename("sounds/brake.wav", self.baseDirectory);
    self.brakeSoundId = createSample("LizardHor12nSound");
    loadSample(self.brakeSoundId, brakeSoundFile, false);
    self.brakePlaying = false;
	
	starterSoundFile = Utils.getFilename("sounds/starter.wav", self.baseDirectory);
    self.starterSoundId = createSample("LizardHor12nSound");
    loadSample(self.starterSoundId, starterSoundFile, false);
    self.starterPlaying = false;
	
	
end;
 function Ursus1614:delete()
 
    Utils.deleteParticleSystem(self.steamParticleSystems);
	
end;
function Ursus1614:keyEvent(unicode, sym, modifier, isDown)
	  
	  
	if isDown and sym == Input.KEY_b then
		self.Przekaznik = not self.Przekaznik;
	end;
	
	
	if isDown and sym == Input.KEY_b then
		self.wajcha = not self.wajcha;
	end;
	
	
	if isDown and sym == Input.KEY_w then
		self.front = not self.front;
	end;
	
	
	if isDown and sym == Input.KEY_s then
		self.backward = not self.backward;
	end;
	
	
	if isDown and sym == Input.KEY_v then
		self.podnosnik = not self.podnosnik;
	end;
	
	if isDown and sym == Input.KEY_l then
		self.wycieraczka = not self.wycieraczka;
	end;
	
	if isDown and sym == Input.KEY_l then
		self.wlacznik = not self.wlacznik;
	end;
	
	if isDown and sym == Input.KEY_home then
		self.kogut = not self.kogut;
	end;
		
  
end;


function Ursus1614:update(dt)

        local nearestDistance = 1.5;
		local vx, vy, vz = getWorldTranslation(g_currentMission.player.rootNode);
	
		
		local px, py, pz = getWorldTranslation(self.klapalewa); 
		local distance = Utils.vector3Length(px-vx, py-vy, pz-vz);	
		if distance < nearestDistance then
			self.przyklapiel = true; 
		else
			self.przyklapiel = false; 
		end;
		
		local rx, ry, rz = getWorldTranslation(self.klapaprawa); 
		local distance = Utils.vector3Length(rx-vx, ry-vy, rz-vz);	
		if distance < nearestDistance then
			self.przyklapiep = true; 
		else
			self.przyklapiep = false; 
		end;
		
		
		local sx, sy, sz = getWorldTranslation(self.zaczep); 
		local distance = Utils.vector3Length(sx-vx, sy-vy, sz-vz);	
		if distance < nearestDistance then
			self.przyzaczepie = true; 
		else
			self.przyzaczepie = false; 
		end; 
		
		local ux, uy, uz = getWorldTranslation(self.pompka); 
		local distance = Utils.vector3Length(ux-vx, uy-vy, uz-vz);	
		if distance < nearestDistance then
			self.przypompka = true; 
		else
			self.przypompka = false; 
		end; 
		
		local ox, oy, oz = getWorldTranslation(self.bolec1); 
		local distance = Utils.vector3Length(ox-vx, oy-vy, oz-vz);	
		if distance < nearestDistance then
			self.przyBolec1 = true; 
		else
			self.przyBolec1 = false; 
		end; 
		
		local nx, ny, nz = getWorldTranslation(self.bolec2); 
		local distance = Utils.vector3Length(nx-vx, ny-vy, nz-vz);	
		if distance < nearestDistance then
			self.przyBolec2 = true; 
		else
			self.przyBolec2 = false; 
		end; 
		
		local mx, my, mz = getWorldTranslation(self.compressor); 
		local distance = Utils.vector3Length(mx-vx, my-vy, mz-vz);	
		if distance < nearestDistance then
			self.przycompressor = true; 
		else
			self.przycompressor = false; 
		end; 
		
		local lx, ly, lz = getWorldTranslation(self.maska); 
		local distance = Utils.vector3Length(lx-vx, ly-vy, lz-vz);	
		if distance < nearestDistance then
			self.przymaska = true; 
		else
			self.przymaska = false; 
		end; 
		
		local kx, ky, kz = getWorldTranslation(self.korek); 
		local distance = Utils.vector3Length(kx-vx, ky-vy, kz-vz);	
		if distance < nearestDistance then
			self.przykorku = true; 
		else
			self.przykorku = false; 
		end; 
	
		
		
--------drzwi----------------
--otwieranie--
	if self.przyklapiep or self.isEntered then
	if InputBinding.hasEvent(InputBinding.PRAWE) then
			if self.animationParts[1].clipEndTime then
				self:setAnimationTime(1, self.animationParts[1].offSet);
				self.otworz = true;
				self.zamknij = false;
			elseif self.animationParts[1].clipStartTime then
				self:setAnimationTime(1, self.animationParts[1].animDuration);
				self.otworz = false;
				self.zamknij = true;
			end;
		end;
	end;
	
	if self.przyklapiel or self.isEntered then
	if InputBinding.hasEvent(InputBinding.LEWE) then
			if self.animationParts[2].clipEndTime then
				self:setAnimationTime(2, self.animationParts[2].offSet);
				self.sound7 = true;
				self.sound8 = false;
			elseif self.animationParts[2].clipStartTime then
				self:setAnimationTime(2, self.animationParts[2].animDuration);
				self.sound7 = false;
				self.sound8 = true;
			end;
		end;
	end;  
	
	--dach-	
	if self.isEntered then				
		if InputBinding.hasEvent(InputBinding.DACH) then
			if self.animationParts[3].clipEndTime then
				self:setAnimationTime(3, self.animationParts[3].offSet);
				self.sound11 = true;
				self.sound12 = false;
			elseif self.animationParts[3].clipStartTime then
				self:setAnimationTime(3, self.animationParts[3].animDuration);
				self.sound11 = false;
				self.sound12 = true;
			end;
		end;
		end;
		
		--szyba_tyl-	
	if self.isEntered then				
		if InputBinding.hasEvent(InputBinding.SZYBA) then
			if self.animationParts[21].clipEndTime then
				self:setAnimationTime(21, self.animationParts[21].offSet);
			elseif self.animationParts[21].clipStartTime then
				self:setAnimationTime(21, self.animationParts[21].animDuration);
			end;
		end;
	end;
	
	--zaczep--
	if self.przyzaczepie then
	 	if InputBinding.isPressed(InputBinding.zaczepUp) then
               self:setAnimationTime(4, self.animationParts[4].currentPosition+(self.animationParts[4].offSet+dt), false);
           elseif InputBinding.isPressed(InputBinding.zaczepDown) then
               self:setAnimationTime(4, self.animationParts[4].currentPosition-(self.animationParts[4].offSet+dt), false);
        end;
        end;
		
		--pompka--
	if self.przypompka then
	 	if InputBinding.isPressed(InputBinding.pompkaup) then
               self:setAnimationTime(24, self.animationParts[24].currentPosition+(self.animationParts[24].offSet+dt), false);
           elseif InputBinding.isPressed(InputBinding.pompkadown) then
               self:setAnimationTime(24, self.animationParts[24].currentPosition-(self.animationParts[24].offSet+dt), false);
        end;
        end;
		
		---podnosnik---
	
	if self.Lifter.node ~= nil and self.bottomArm2.node ~= nil then
			rBBArmX, rBBArmY, rBBArmZ = getRotation(self.bottomArm2.node);
			setRotation(self.Lifter.node, rBBArmX*1.5, 0, 0);
	end;
	if self.LifterArm.node ~= nil and self.bottomArm2.node ~= nil then
			setRotation(self.LifterArm.node, 0.05-rBBArmX*1.5, 0, 0);
	end;
	
	---wajcha podnosnika---
	
		if self.isEntered then
		if self.podnosnik then
		   self:setAnimationTime(5,self.animationParts[5].animDuration);
		   self.sound19 = true;
		else 
		   self:setAnimationTime(5,self.animationParts[5].offSet);	
           self.sound19 = false;   
		end;
		end;
		
		---wycieraczka---
		
		if self.wycieraczka then
           self:setAnimationTime(13, 1);
		   self.sound20 = true;
        else
           self:setAnimationTime(13, 0);
		   self.sound20 = false;
        end;
		
		if self.isEntered then
		if self.wlacznik then
			self:setAnimationTime(12,self.animationParts[12].animDuration);
			self.sound21 = true;
			self.sound22 = false;
		else
			self:setAnimationTime(12,self.animationParts[12].offSet);
			self.sound21 = false;
			self.sound22 = true;
		end;
		end;
	                 --- szyby boczne ---
					 
		if self.isEntered then				
		if InputBinding.hasEvent(InputBinding.szybaL) then
			if self.animationParts[11].clipEndTime then
				self:setAnimationTime(11, self.animationParts[11].offSet);
			elseif self.animationParts[11].clipStartTime then
				self:setAnimationTime(11, self.animationParts[11].animDuration);
			end;
		end;
	end;		

        if self.isEntered then				
		if InputBinding.hasEvent(InputBinding.szybaP) then
			if self.animationParts[8].clipEndTime then
				self:setAnimationTime(8, self.animationParts[8].offSet);
			elseif self.animationParts[8].clipStartTime then
				self:setAnimationTime(8, self.animationParts[8].animDuration);
			end;
		end;
	end;			 	
					 ---Reczny---
					 
	    if self.handbrake then
		    self:setAnimationTime(7,self.animationParts[7].animDuration);
		else
			self:setAnimationTime(7,self.animationParts[7].offSet);
		end;
		
		            ---siedzisko---
					
		if self.isEntered then				
		if InputBinding.hasEvent(InputBinding.siedzenie) then
			if self.animationParts[25].clipEndTime then
				self:setAnimationTime(25, self.animationParts[25].offSet);
			elseif self.animationParts[25].clipStartTime then
				self:setAnimationTime(25, self.animationParts[25].animDuration);
			end;
		end;
	end;	

                    ---Compressor---
			
        if self.przycompressor then			
		if InputBinding.hasEvent(InputBinding.compressor) then
			if self.animationParts[26].clipEndTime then
				self:setAnimationTime(26, self.animationParts[26].offSet);
			elseif self.animationParts[26].clipStartTime then
				self:setAnimationTime(26, self.animationParts[26].animDuration);
			end;
		end;
	end;	
	
	if self.isMotorStarted and self.animationParts[26].clipEndTime then
	   self.sound25 = true;
	elseif self.animationParts[26].clipStartTime or not self.isMotorStarted then
	   self.sound25 = false;
	end;
	
	
	
					---maska---
					
        if self.przymaska then			
		if InputBinding.hasEvent(InputBinding.maska) then
			if self.animationParts[37].clipEndTime then
				self:setAnimationTime(37, self.animationParts[37].offSet);
			elseif self.animationParts[37].clipStartTime then
				self:setAnimationTime(37, self.animationParts[37].animDuration);
			end;
		end;
	end;
	
	                  
					  ---korek chlodnicy---
					
        if self.przykorku then			
		if InputBinding.hasEvent(InputBinding.korek) then
			if self.animationParts[38].clipEndTime and self.animationParts[37].clipEndTime then
				self:setAnimationTime(38, self.animationParts[38].offSet);
			elseif self.animationParts[38].clipStartTime and self.animationParts[37].clipEndTime then
				self:setAnimationTime(38, self.animationParts[38].animDuration);
			end;
		end;
	end;
	
	
	if self.animationParts[38].clipEndTime and self.dym then
	   Utils.setEmittingState(self.steamParticleSystems, true);
	elseif self.animationParts[38].clipStartTime or self.animationParts[19].clipStartTime then
	   Utils.setEmittingState(self.steamParticleSystems, false);
	end;
	
	
	
	
	
	               ---pasy---
				   
	if self.isMotorStarted then
		for _, part in pairs(self.belts) do
          	setShaderParameter(part.node, "uvScrollSpeed", part.speed[1], 0, 0, 0, false);
    end;      	
	elseif not self.isMotorStarted then
		for _, part in pairs(self.belts) do
          	setShaderParameter(part.node, "uvScrollSpeed", 0, 0, 0, 0, false);
	end;
	end;

                    ---pasy--end---
	
					---Bolce---
		if  InputBinding.hasEvent(InputBinding.bolec1) and self.przyBolec1 then
			self.boolec1 = not self.boolec1;
	    end;

		if self.boolec1 then
			setVisibility(self.bolec1,false);
			self.sound23 = true;
		else
			setVisibility(self.bolec1,true);
			self.sound23 = false;
		end;
		
        if  InputBinding.hasEvent(InputBinding.bolec1) and self.przyBolec2 then
			self.boolec2 = not self.boolec2;
	    end;

		if self.boolec2 then
			setVisibility(self.bolec2,false);
			self.sound24 = true;
		else
			setVisibility(self.bolec2,true);
			self.sound24 = false;
		end;
					---Panel pomocy---
					
		if  InputBinding.hasEvent(InputBinding.help) then
			self.help = not self.help;
	    end;			
		
					   --klapka--
					   
	  if self.isMotorStarted then
      local angle = math.rad(math.random(-30, 10)) + self.exhaustingSystem.maxRot * self.motor.lastMotorRpm / self.exhaustingSystem.maxRpm
         angle = math.max(math.min(angle, 0), self.exhaustingSystem.maxRot)
         setRotation(self.exhaustingSystem.flap, 0, 0, angle)
      end;
	  
	  if self.isMotorStarted then
		 setVisibility((self.klapkaoff), false);
		 setVisibility((self.klapkaon), true);
		 else
		 setVisibility((self.klapkaoff), true);
		 setVisibility((self.klapkaon), false);
	  end;	
	          ---------
	
	if self.setAnimationTime ~= nil then
		if self.isMotorStarted then
			self:setAnimationTime(6, 1);
		else
			self:setAnimationTime(6, 0);
		end;
		if self.Przekaznik then
           self:setAnimationTime(9, 1);
        else
           self:setAnimationTime(9, 0);
        end;
		
		
	if self.isMotorStarted then
			self:setAnimationTime(22,self.animationParts[22].animDuration);
		else
			self:setAnimationTime(22,self.animationParts[22].offSet);
		end;
		
		if self.isEntered then
		if self.hamuj then
			self:setAnimationTime(23,self.animationParts[23].animDuration);
			self.sound10 = true;
		else
			self:setAnimationTime(23,self.animationParts[23].offSet);
			self.sound10 = false;
		end;
		end;
		
		
		if self.isEntered then
		if self.wajcha then
			self:setAnimationTime(10,self.animationParts[10].animDuration);
			self.sound17 = true;
			self.sound18 = false;
		else
			self:setAnimationTime(10,self.animationParts[10].offSet);
			self.sound17 = false;
			self.sound18 = true;
		end;
		end;

                         --- gearBox marcello1942---		
		
		if self.motor.speedLevel == 4 then
			self:setAnimationTime(34,self.animationParts[34].animDuration);
			self.two = false;
			self.three = false;
			self.one = false;
			self.sound = true;
		else
			self:setAnimationTime(34,self.animationParts[34].offSet);
			self.sound = false;
		end;
		if self.isEntered then
		if self.motor.speedLevel == 3 or Input.isKeyPressed(Input.KEY_w) then
			self:setAnimationTime(33,self.animationParts[33].animDuration);
			self.two = false;
			self.one = false;
			self.four = false;
			self.sound3 = true;
		else
			self:setAnimationTime(33,self.animationParts[33].offSet);
			self.sound3 = false;
		end;
		end;
		if self.motor.speedLevel == 2 then
			self:setAnimationTime(32,self.animationParts[32].animDuration);
			self.one = false;
			self.three = false;
			self.four = false;
			self.sound4 = true;
		else
			self:setAnimationTime(32,self.animationParts[32].offSet);
			self.sound4 = false;
		end;
		if self.isEntered then
		if self.motor.speedLevel == 1 or Input.isKeyPressed(Input.KEY_s) then
			self:setAnimationTime(31,self.animationParts[31].animDuration);
			self.two = false;
			self.three = false;
			self.four = false;
			self.sound6 = true;
		else
			self:setAnimationTime(31,self.animationParts[31].offSet);
			self.sound6 = false;
		end;
		end;
		
		if Input.isKeyPressed(Input.KEY_1) or Input.isKeyPressed(Input.KEY_2) or Input.isKeyPressed(Input.KEY_3) or Input.isKeyPressed(Input.KEY_4) then
		   self:setAnimationTime(30,self.animationParts[30].animDuration);
		   self.wheels[1].driveMode =0
		   self.wheels[2].driveMode =0
		   self.wheels[3].driveMode =0
		   self.wheels[4].driveMode =0	
		else 
		   self:setAnimationTime(30,self.animationParts[30].offSet);
           self.wheels[1].driveMode =2
		   self.wheels[2].driveMode =2
		   self.wheels[3].driveMode =2
		   self.wheels[4].driveMode =2		   
		end;
		
		if self.isEntered then
		if Input.isKeyPressed(Input.KEY_w) or Input.isKeyPressed(Input.KEY_s) then
		   self:setAnimationTime(29,self.animationParts[29].animDuration);
		   self:setAnimationTime(17,self.animationParts[17].animDuration);
		else 
		   self:setAnimationTime(29,self.animationParts[29].offSet);
		   self:setAnimationTime(17,self.animationParts[17].offSet);
		end;
		end;
		
				
        if self.front then
			self.two = false;
			self.one = false;
			self.four = false;
		end;
		
		if self.backward then
			self.two = false;
			self.four = false;
			self.three = false;
		end;
		
		                       ---FB---
							   
		if self.isEntered then					   
		if Input.isKeyPressed(Input.KEY_s) then
		   self:setAnimationTime(28, self.animationParts[28].currentPosition+(self.animationParts[28].offSet+dt), false);
		   self.sound2 = true;
		   self.sound5 = false;
        elseif 
		   Input.isKeyPressed(Input.KEY_w) or self.motor.speedLevel == 1 or self.motor.speedLevel == 2 or self.motor.speedLevel == 3 or self.motor.speedLevel == 4 then
           self:setAnimationTime(28, self.animationParts[28].currentPosition-(self.animationParts[28].offSet+dt), false);
		   self.sound2 = false;
		   self.sound5 = true;
        end;
        end;
		end;
		
		                 ---wskazowki---
						 
		if self.isMotorStarted then
			self:setAnimationTime(20,self.animationParts[20].animDuration);
		else
			self:setAnimationTime(20,self.animationParts[20].offSet);
		end;
		
		---3---
        if self.isMotorStarted then
			self:setAnimationTime(19,self.animationParts[19].animDuration);
		else
			self:setAnimationTime(19,self.animationParts[19].offSet);
			self.dym1 = true;
		end;
		
		if self.animationParts[19].clipEndTime then
	       self:setAnimationTime(39,self.animationParts[39].animDuration);
		   self.dym = true;
	    elseif self.animationParts[19].clipStartTime then
	       self:setAnimationTime(39,self.animationParts[39].offSet);
	    end;
		
		---end 3 ---
		
		
		if self.isMotorStarted then
			self:setAnimationTime(18,self.animationParts[18].offSet);
		else
			self:setAnimationTime(18,self.animationParts[18].animDuration);
		end;
		
		                 ---wskazowki end---
						 
		
		                      ---indicator rpm stoper---
							  
		if self.isMotorStarted then
			self:setAnimationTime(35,self.animationParts[35].animDuration);
		else
			self:setAnimationTime(35,self.animationParts[35].offSet);
		end;	

         if self.isMotorStarted then
		 setVisibility((self.indicatoron), false);
		 setVisibility((self.indicatoroff), true);
		 else
		 setVisibility((self.indicatoron), true);
		 setVisibility((self.indicatoroff), false);
	  end;		
                                  ---end---


                                       ---kogut---
         if self.kogut then
			self:setAnimationTime(36, 1);
			setVisibility((self.blysk), true);
		else
			self:setAnimationTime(36, 0);
			setVisibility((self.blysk), false);
		end;
									   ---end--- 
							  
					                   ---rpm---
	
       if self.isMotorStarted then
      local angle = math.rad(math.random(-2, 0)) + self.rpm.maxRot * self.motor.lastMotorRpm / self.rpm.maxRpm
         angle = math.max(math.min(angle, 0), self.rpm.maxRot)
         setRotation(self.rpm.mod, 0, 0, angle)
      end;
                                       ---end---
									   
		                        ---fuel---
								
		local actualTankInhalt = 0;
		if self.fuelCapacity > 0 and self.isMotorStarted then
			actualTankInhalt = (self.fuelFillLevel / self.fuelCapacity + 0.0001) * 100;
		end;
		local rotValue = (self.fuelLevelMaxRot / self.fuelCapacity) * actualTankInhalt;
		setRotation(self.fuelLevel, 0, Utils.degToRad(rotValue), 0);						
		
		                        ---end---
		
		                        ---r---
		if self.isMotorStarted and self.fuelFillLevel < 32 then
		self:setAnimationTime(14,self.animationParts[14].animDuration);
		else
			self:setAnimationTime(14,self.animationParts[14].offSet);
		end;	
                                ---end---

                               ---stop the engine wen tank is empty---
 
        if self.fuelFillLevel < 1 then
		self:stopMotor();
		self.deactivateOnLeave = true;
		self.ignitionKey = false;
		end;
		                              ---end---
		
		                ---starter wen tank is empty---
						
		if self.isEntered then				
		if self.fuelFillLevel < 1 then
		if Input.isKeyPressed(Input.KEY_z) then
		self.sound26 = true;
		else
		self.sound26 = false;
		end;
		end;
		end;
       		                    ---end---
						
						
		                ---przelacznik kierunki---
						
		if  self.isEntered then				
		if  self.lewy then
			self:setAnimationTime(16,self.animationParts[16].animDuration);
			self.right = false;
		else
			self:setAnimationTime(16,self.animationParts[16].offSet);
		end;
        end;
        if  self.isEntered then		
 		if  self.prawy then
			self:setAnimationTime(15,self.animationParts[15].animDuration);
			self.left = false;
		else
			self:setAnimationTime(15,self.animationParts[15].offSet);
		end;
        end;
	                         ---end---
		
	  --napisy
		if self.przyzaczepie then
			g_currentMission:addHelpButtonText(g_i18n:getText("RearHitchUp"), InputBinding.zaczepUp);
			g_currentMission:addHelpButtonText(g_i18n:getText("RearHitchDown"), InputBinding.zaczepDown);
		end;
		if self.przyklapiel then
	    if self.animationParts[2].clipStartTime then
			g_currentMission:addHelpButtonText(g_i18n:getText("DoorOpen"), InputBinding.LEWE);
		else
			g_currentMission:addHelpButtonText(g_i18n:getText("DoorClose"), InputBinding.LEWE);
		end;
		end;
		if self.przyklapiep then
	    if self.animationParts[1].clipStartTime then
			g_currentMission:addHelpButtonText(g_i18n:getText("DoorOpen"), InputBinding.PRAWE);
		else
			g_currentMission:addHelpButtonText(g_i18n:getText("DoorClose"), InputBinding.PRAWE);
		end;
		end;
		if self.przypompka then
			g_currentMission:addHelpButtonText(g_i18n:getText("ManualPumpUp"), InputBinding.pompkaup);
			g_currentMission:addHelpButtonText(g_i18n:getText("ManualPumpDown"), InputBinding.pompkadown);
		end;
		if self.przyBolec1 then
		if self.boolec1 then
			g_currentMission:addHelpButtonText(g_i18n:getText("HidePivot"), InputBinding.bolec1);
		else
			g_currentMission:addHelpButtonText(g_i18n:getText("ShowPivot"), InputBinding.bolec1);
		end;
		end;
		if self.przyBolec2 then
		if self.boolec2 then
			g_currentMission:addHelpButtonText(g_i18n:getText("HidePivot"), InputBinding.bolec1);
		else
			g_currentMission:addHelpButtonText(g_i18n:getText("ShowPivot"), InputBinding.bolec1);
		end;
		end;
		if self.isEntered then
		if self.help then
		    g_currentMission:addHelpButtonText(g_i18n:getText("HideHelp"), InputBinding.help);
		else
			g_currentMission:addHelpButtonText(g_i18n:getText("ShowHelp"), InputBinding.help);
		end;
		end;
		if self.przycompressor then	
		if self.animationParts[26].clipStartTime then	
		    g_currentMission:addHelpButtonText(g_i18n:getText("CompressorOn"), InputBinding.compressor);
		else
			g_currentMission:addHelpButtonText(g_i18n:getText("CompressorOff"), InputBinding.compressor);
		end;
		end;
		if self.przymaska then	
		if self.animationParts[37].clipStartTime then	
		    g_currentMission:addHelpButtonText(g_i18n:getText("OpenHood"), InputBinding.maska);
		else
			g_currentMission:addHelpButtonText(g_i18n:getText("CloseHood"), InputBinding.maska);
		end;
		end;
		
		if self.przykorku then	
		if self.animationParts[38].clipStartTime and self.animationParts[37].clipEndTime then	
		    g_currentMission:addHelpButtonText(g_i18n:getText("OpenRadiatorCap"), InputBinding.korek);
		elseif self.animationParts[37].clipEndTime then
			g_currentMission:addHelpButtonText(g_i18n:getText("CloseRadiatorCap"), InputBinding.korek);
		end;
		end;

			if self:getIsActive() then
		self.setHydraulicTime = 30;
	end;


	if self.setHydraulicTime > 0 then
		for k,v in pairs(self.hydraulics) do
			self:setHydraulicDirection(k);
		end;
		self.setHydraulicTime = self.setHydraulicTime - 1;
	end;
	
	
	  if self.otworz then
       if not self.hor12nPlaying then
            playSample(self.hor12nSoundId, 1, 3, 3);
            self.hor12nPlaying = true;
        end;
       
    else
        if self.hor12nPlaying then
            stopSample(self.hor12nSoundId);
            self.hor12nPlaying = false;
        end;
         
    end;
      if self.zamknij then
       if not self.hor123nPlaying then
            playSample(self.hor123nSoundId, 1, 3, 3);
            self.hor123nPlaying = true;
        end;
       
    else
        if self.hor123nPlaying then
            stopSample(self.hor123nSoundId);
            self.hor123nPlaying = false;
        end;
         
    end;
	
	if self.sound then
       if not self.hor1234nPlaying then
            playSample(self.hor1234nSoundId, 1, 3, 3);
            self.hor1234nPlaying = true;
        end;
       
    else
        if self.hor1234nPlaying then
            stopSample(self.hor1234nSoundId);
            self.hor1234nPlaying = false;
        end;
         
    end;
	
	if self.sound2 then
       if not self.hor12345nPlaying then
            playSample(self.hor12345nSoundId, 1, 3, 3);
            self.hor12345nPlaying = true;
        end;
       
    else
        if self.hor12345nPlaying then
            stopSample(self.hor12345nSoundId);
            self.hor12345nPlaying = false;
        end;
         
    end;
	
	if self.sound3 then
       if not self.hor123456nPlaying then
            playSample(self.hor123456nSoundId, 1, 3, 3);
            self.hor123456nPlaying = true;
        end;
       
    else
        if self.hor123456nPlaying then
            stopSample(self.hor123456nSoundId);
            self.hor123456nPlaying = false;
        end;
         
    end;
	
	if self.sound4 then
       if not self.hor1234567nPlaying then
            playSample(self.hor1234567nSoundId, 1, 3, 3);
            self.hor1234567nPlaying = true;
        end;
       
    else
        if self.hor1234567nPlaying then
            stopSample(self.hor1234567nSoundId);
            self.hor1234567nPlaying = false;
        end;
         
    end;
	
	if self.sound5 then
       if not self.hor12345678nPlaying then
            playSample(self.hor12345678nSoundId, 1, 3, 3);
            self.hor12345678nPlaying = true;
        end;
       
    else
        if self.hor12345678nPlaying then
            stopSample(self.hor12345678nSoundId);
            self.hor12345678nPlaying = false;
        end;
         
    end;
	
	if self.sound6 then
       if not self.horn2Playing then
            playSample(self.horn2SoundId, 1, 3, 3);
            self.horn2Playing = true;
        end;
       
    else
        if self.horn2Playing then
            stopSample(self.horn2SoundId);
            self.horn2Playing = false;
        end;
         
    end;
	
	if self.sound7 then
       if not self.openPlaying then
            playSample(self.openSoundId, 1, 3, 3);
            self.openPlaying = true;
        end;
       
    else
        if self.openPlaying then
            stopSample(self.openSoundId);
            self.openPlaying = false;
        end;
         
    end;
	
		if self.sound8 then
       if not self.clousePlaying then
            playSample(self.clouseSoundId, 1, 3, 3);
            self.clousePlaying = true;
        end;
       
    else
        if self.clousePlaying then
            stopSample(self.clouseSoundId);
            self.clousePlaying = false;
        end;
         
    end;
	
	if self.sound10 then
       if not self.brakePlaying then
            playSample(self.brakeSoundId, 1, 3, 3);
            self.brakePlaying = true;
        end;
       
    else
        if self.brakePlaying then
            stopSample(self.brakeSoundId);
            self.brakePlaying = false;
        end;
         
    end;
	
	if self.sound11 then
       if not self.dach_downPlaying then
            playSample(self.dach_downSoundId, 1, 3, 3);
            self.dach_downPlaying = true;
        end;
       
    else
        if self.dach_downPlaying then
            stopSample(self.dach_downSoundId);
            self.dach_downPlaying = false;
        end;
         
    end;
	
	if self.sound12 then
       if not self.dach_upPlaying then
            playSample(self.dach_upSoundId, 1, 3, 3);
            self.dach_upPlaying = true;
        end;
       
    else
        if self.dach_upPlaying then
            stopSample(self.dach_upSoundId);
            self.dach_upPlaying = false;
        end;
         
    end;
	
	if self.sound17 then
       if not self.wajchaPlaying then
            playSample(self.wajchaSoundId, 1, 3, 3);
            self.wajchaPlaying = true;
        end;
       
    else
        if self.wajchaPlaying then
            stopSample(self.wajchaSoundId);
            self.wajchaPlaying = false;
        end;
         
    end;
	
	if self.sound18 then
       if not self.wajcha1Playing then
            playSample(self.wajcha1SoundId, 1, 3, 3);
            self.wajcha1Playing = true;
        end;
       
    else
        if self.wajcha1Playing then
            stopSample(self.wajcha1SoundId);
            self.wajcha1Playing = false;
        end;
         
    end;
	
	if self.sound19 then
       if not self.podnosnikPlaying then
            playSample(self.podnosnikSoundId, 1, 3, 3);
            self.podnosnikPlaying = true;
        end;
       
    else
        if self.podnosnikPlaying then
            stopSample(self.podnosnikSoundId);
            self.podnosnikPlaying = false;
        end;
         
    end;
	
	
	   if self.isEntered then
	   if self.sound20 then
       if not self.wycieraczkaPlaying then
            playSample(self.wycieraczkaSoundId, 0, 1, 0);
            self.wycieraczkaPlaying = true;
        end;
       
    else
        if self.wycieraczkaPlaying then
            stopSample(self.wycieraczkaSoundId);
            self.wycieraczkaPlaying = false;
        end;
         
    end;
	end;
	
	if self.sound21 then
       if not self.pstrykPlaying then
            playSample(self.pstrykSoundId, 1, 3, 3);
            self.pstrykPlaying = true;
        end;
       
    else
        if self.pstrykPlaying then
            stopSample(self.pstrykSoundId);
            self.pstrykPlaying = false;
        end;
         
    end;
	
	if self.sound22 then
       if not self.pstryk1Playing then
            playSample(self.pstryk1SoundId, 1, 3, 3);
            self.pstryk1Playing = true;
        end;
       
    else
        if self.pstryk1Playing then
            stopSample(self.pstryk1SoundId);
            self.pstryk1Playing = false;
        end;
         
    end;
	
	if self.sound23 then
       if not self.bolecPlaying then
            playSample(self.bolecSoundId, 1, 3, 3);
            self.bolecPlaying = true;
        end;
       
    else
        if self.bolecPlaying then
            stopSample(self.bolecSoundId);
            self.bolecPlaying = false;
        end;
         
    end;
	
	if self.sound24 then
       if not self.bolec2Playing then
            playSample(self.bolec2SoundId, 1, 3, 3);
            self.bolec2Playing = true;
        end;
       
    else
        if self.bolec2Playing then
            stopSample(self.bolec2SoundId);
            self.bolec2Playing = false;
        end;
         
    end;
	
	if self.sound25 then
       if not self.compressorPlaying then
            playSample(self.compressorSoundId, 0, 1, 0);
            self.compressorPlaying = true;
        end;
       
    else
        if self.compressorPlaying then
            stopSample(self.compressorSoundId);
            self.compressorPlaying = false;
        end;
         
    end;
	
	if self.sound26 then
       if not self.starterPlaying then
            playSample(self.starterSoundId, 0, 1, 0);
            self.starterPlaying = true;
        end;
       
    else
        if self.starterPlaying then
            stopSample(self.starterSoundId);
            self.starterPlaying = false;
        end;
         
    end;
	
	
	
end;


function Ursus1614:mouseEvent(posX, posY, isDown, isUp, button)
end;

function Ursus1614:validateAttacherJoint(implement, jointDesc, dt)
    return true;
end;
function Ursus1614:setHydraulicDirection(index)
	local hydraulic = self.hydraulics[index];

	if hydraulic.fixPoint ~= nil then
		local ax, ay, az = getWorldTranslation(hydraulic.node);
		local bx, by, bz = getWorldTranslation(hydraulic.fixPoint);
		local x, y, z = worldDirectionToLocal(getParent(hydraulic.node), bx-ax, by-ay, bz-az);
		local xUp, yUp, zUp = unpack(hydraulic.upVectors);
		setDirection(hydraulic.node, x, y, z, xUp, yUp, zUp);
		if hydraulic.punch ~= nil then
			local distance = Utils.vector3Length(ax-bx, ay-by, az-bz);
			setTranslation(hydraulic.punch, 0, 0, distance-hydraulic.punchDistance);
		end;
	end;
end;
function Ursus1614:draw()

        if self.isEntered then
		if self.help then
			renderText(0.67, 0.825, 0.03, "-->Zetor 10145<--");
			if not self.isMotorStarted then
			renderText(0.72, 0.800, 0.02, "Z: turn on the engine");
			else
			renderText(0.72, 0.800, 0.02, "Z: turn off the engine");
			end;
	
	
		    renderText(0.72, 0.775, 0.02, "Doors right: M, left: N ");
	
		
			renderText(0.72, 0.75, 0.02, "Roof hatch: T ");
         
           
			renderText(0.72, 0.725, 0.02, "Direction indicators: Num 1/2/3 ");
	
		
			renderText(0.72, 0.7, 0.02, "Add, reduce rpm: Num_plus, Num_minus ");
			
		
			renderText(0.72, 0.675, 0.02, "Side windows, left: Y, right: U");
			
			
			renderText(0.72, 0.650, 0.02, "Halogens: 7, 8 ");
			
			
			renderText(0.72, 0.625, 0.02, "Handbrake: Space ");
			
			
			renderText(0.72, 0.600, 0.02, "Wiper: L ");
			
			
			renderText(0.72, 0.575, 0.02, "Passenger seat: J ");
			
			
			renderText(0.72, 0.550, 0.02, "Rear window: K");
			
			
			renderText(0.72, 0.525, 0.02, "***Turn on the fourth gear");
			
			
			renderText(0.72, 0.500, 0.02, "to get the maximum speed***");
			
			
			renderText(0.67, 0.450, 0.03, "-->Edit Gracjan26<--");
		end;
	end;	
end;

function Ursus1614:updateTick(dt)
		if self.backHydraulic ~= nil then		
		local x, y, z = getRotation(self.attacherJoints[1].bottomArm.rotationNode);
		setRotation(self.backHydraulic.rootArm, x, y, z);	
	end;
	
	

		for _, shaft in pairs(self.drivingPowerShafts) do
			local x,y,z = getRotation(self.wheels[1].driveNode);
			setRotation(shaft.node, 0 ,0, x*shaft.speedFactor);
			
			if shaft.trans ~= 0 then
				local newTrans = shaft.trans * self.articulatedSteering.curRot/self.articulatedSteering.maxRot;
				local x,y,z = unpack(shaft.orgTrans);
				setTranslation(getParent(shaft.node), x + newTrans,y,z);
			end;
			if shaft.rot ~= 0 then
				newRot = shaft.rot * self.articulatedSteering.curRot/self.articulatedSteering.maxRot;
				setRotation(getParent(shaft.node), 0, newRot, 0);
			end;
    end;		
end;