--
-- Teleskopladerser
--local maxKmh
-- M@D Author  StarT  gswlad
-- M@D date  4.7.2012

Teleskopladerser = {}

function Teleskopladerser.prerequisitesPresent(specializations)
	Vehicle.registerJointType("frontloader");
    return true ;
end;

function Teleskopladerser:load(xmlFile)

    self.fanNode = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.fan#index"));



--[[stop]]------------------------------------------------------------
local rotationPartNodebrakerihag = Utils.indexToObject(self.rootNode, getXMLString(xmlFile, "vehicle.rotationPartbrakerihag#index"));
    if rotationPartNodebrakerihag ~= nil then
        self.rotationPartbrakerihag = {};
        self.rotationPartbrakerihag.node = rotationPartNodebrakerihag;

        local x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotationPartbrakerihag#minRot"));
        self.rotationPartbrakerihag.minRot = {};
        self.rotationPartbrakerihag.minRot[1] = Utils.degToRad(Utils.getNoNil(x, 0));
        self.rotationPartbrakerihag.minRot[2] = Utils.degToRad(Utils.getNoNil(y, 0));
        self.rotationPartbrakerihag.minRot[3] = Utils.degToRad(Utils.getNoNil(z, 0));

        x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotationPartbrakerihag#maxRot"));
        self.rotationPartbrakerihag.maxRot = {};
        self.rotationPartbrakerihag.maxRot[1] = Utils.degToRad(Utils.getNoNil(x, 0));
        self.rotationPartbrakerihag.maxRot[2] = Utils.degToRad(Utils.getNoNil(y, 0));
        self.rotationPartbrakerihag.maxRot[3] = Utils.degToRad(Utils.getNoNil(z, 0));

        self.rotationPartbrakerihag.rotTime = Utils.getNoNil(getXMLString(xmlFile, "vehicle.rotationPartbrakerihag#rotTime"), 2)*1000;
        self.rotationPartbrakerihag.touchRotLimit = Utils.degToRad(Utils.getNoNil(getXMLString(xmlFile, "vehicle.rotationPartbrakerihag#touchRotLimit"), 10));
    end;

	handbrakeSoundFile = Utils.getFilename("sounds/handbrake.wav", self.baseDirectory);
	self.handbrakeSoundId = createSample("handbrakeSound");
	loadSample(self.handbrakeSoundId, handbrakeSoundFile, false);






--[[panel]]------------------------------------------------------------
	self.numkablights = Utils.getNoNil(getXMLInt(xmlFile, "vehicle.kablights#count"), 0);
    self.kablights = {};
    for i=1, self.numkablights do
        local kablightsnamei = string.format("vehicle.kablights.kablights" .. "%d", i);
        self.kablights[i] = Utils.indexToObject(self.rootNode, getXMLInt(xmlFile, kablightsnamei .. "#index"));
        setVisibility(self.kablights[i], false);
    end;	
     self.kablightsActive = false;


--[[rul]]------------------------------------------------------------
	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;


--[[val]]------------------------------------------------------------
self.crankshaftNode = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.crankshaft#index"));
self.crankshaft1Node = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.crankshaft1#index"));
self.crankshaft2Node = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.crankshaft2#index"));
self.crankshaft3Node = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.crankshaft3#index"));
self.crankshaft4Node = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.crankshaft4#index"));
self.crankshaft5Node = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.crankshaft5#index"));
self.crankshaft6Node = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.crankshaft6#index"));
self.crankshaft7Node = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.crankshaft7#index"));
self.crankshaft8Node = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.crankshaft8#index"));
self.crankshaft9Node = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.crankshaft9#index"));
self.crankshaft10Node = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.crankshaft10#index"));
self.crankshaft11Node = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.crankshaft11#index"));
self.crankshaft12Node = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.crankshaft12#index"));







local rotationPartNodekorobka0 = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.korobka0#index"));
    if rotationPartNodekorobka0 ~= nil then
        self.rotationPartkorobka0 = {};
        self.rotationPartkorobka0.node = rotationPartNodekorobka0;

        local x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotationPartkorobka0#minRot"));
        self.rotationPartkorobka0.minRot = {};
        self.rotationPartkorobka0.minRot[1] = Utils.degToRad(Utils.getNoNil(x, 0));
        self.rotationPartkorobka0.minRot[2] = Utils.degToRad(Utils.getNoNil(y, 0));
        self.rotationPartkorobka0.minRot[3] = Utils.degToRad(Utils.getNoNil(z, 0));

        x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.korobka0#maxRot"));
        self.rotationPartkorobka0.maxRot = {};
        self.rotationPartkorobka0.maxRot[1] = Utils.degToRad(Utils.getNoNil(x, 0));
        self.rotationPartkorobka0.maxRot[2] = Utils.degToRad(Utils.getNoNil(y, 0));
        self.rotationPartkorobka0.maxRot[3] = Utils.degToRad(Utils.getNoNil(z, 0));

        self.rotationPartkorobka0.rotTime = Utils.getNoNil(getXMLString(xmlFile, "vehicle.korobka0#rotTime"), 2)*1000;
        self.rotationPartkorobka0.touchRotLimit = Utils.degToRad(Utils.getNoNil(getXMLString(xmlFile, "vehicle.korobka0#touchRotLimit"), 10));
    end;
 local rotationPartNodekorobka = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.korobka#index"));
    if rotationPartNodekorobka ~= nil then
        self.rotationPartkorobka = {};
        self.rotationPartkorobka.node = rotationPartNodekorobka;

        local x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotationPartkorobka#minRot"));
        self.rotationPartkorobka.minRot = {};
        self.rotationPartkorobka.minRot[1] = Utils.degToRad(Utils.getNoNil(x, 0));
        self.rotationPartkorobka.minRot[2] = Utils.degToRad(Utils.getNoNil(y, 0));
        self.rotationPartkorobka.minRot[3] = Utils.degToRad(Utils.getNoNil(z, 0));

        x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.korobka#maxRot"));
        self.rotationPartkorobka.maxRot = {};
        self.rotationPartkorobka.maxRot[1] = Utils.degToRad(Utils.getNoNil(x, 0));
        self.rotationPartkorobka.maxRot[2] = Utils.degToRad(Utils.getNoNil(y, 0));
        self.rotationPartkorobka.maxRot[3] = Utils.degToRad(Utils.getNoNil(z, 0));

        self.rotationPartkorobka.rotTime = Utils.getNoNil(getXMLString(xmlFile, "vehicle.korobka#rotTime"), 2)*1000;
        self.rotationPartkorobka.touchRotLimit = Utils.degToRad(Utils.getNoNil(getXMLString(xmlFile, "vehicle.korobka#touchRotLimit"), 10));
    end;
	local rotationPartNodekorobka1 = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.korobka1#index"));
    if rotationPartNodekorobka1 ~= nil then
        self.rotationPartkorobka1 = {};
        self.rotationPartkorobka1.node = rotationPartNodekorobka1;

        local x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotationPartkorobka1#minRot"));
        self.rotationPartkorobka1.minRot = {};
        self.rotationPartkorobka1.minRot[1] = Utils.degToRad(Utils.getNoNil(x, 0));
        self.rotationPartkorobka1.minRot[2] = Utils.degToRad(Utils.getNoNil(y, 0));
        self.rotationPartkorobka1.minRot[3] = Utils.degToRad(Utils.getNoNil(z, 0));

        x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.korobka1#maxRot"));
        self.rotationPartkorobka1.maxRot = {};
        self.rotationPartkorobka1.maxRot[1] = Utils.degToRad(Utils.getNoNil(x, 0));
        self.rotationPartkorobka1.maxRot[2] = Utils.degToRad(Utils.getNoNil(y, 0));
        self.rotationPartkorobka1.maxRot[3] = Utils.degToRad(Utils.getNoNil(z, 0));

        self.rotationPartkorobka1.rotTime = Utils.getNoNil(getXMLString(xmlFile, "vehicle.korobka1#rotTime"), 2)*1000;
        self.rotationPartkorobka1.touchRotLimit = Utils.degToRad(Utils.getNoNil(getXMLString(xmlFile, "vehicle.korobka1#touchRotLimit"), 10));
    end;
	local rotationPartNodekorobka2 = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.korobka2#index"));
    if rotationPartNodekorobka2 ~= nil then
        self.rotationPartkorobka2 = {};
        self.rotationPartkorobka2.node = rotationPartNodekorobka2;

        local x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotationPartkorobka2#minRot"));
        self.rotationPartkorobka2.minRot = {};
        self.rotationPartkorobka2.minRot[1] = Utils.degToRad(Utils.getNoNil(x, 0));
        self.rotationPartkorobka2.minRot[2] = Utils.degToRad(Utils.getNoNil(y, 0));
        self.rotationPartkorobka2.minRot[3] = Utils.degToRad(Utils.getNoNil(z, 0));

        x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.korobka2#maxRot"));
        self.rotationPartkorobka2.maxRot = {};
        self.rotationPartkorobka2.maxRot[1] = Utils.degToRad(Utils.getNoNil(x, 0));
        self.rotationPartkorobka2.maxRot[2] = Utils.degToRad(Utils.getNoNil(y, 0));
        self.rotationPartkorobka2.maxRot[3] = Utils.degToRad(Utils.getNoNil(z, 0));

        self.rotationPartkorobka2.rotTime = Utils.getNoNil(getXMLString(xmlFile, "vehicle.korobka2#rotTime"), 2)*1000;
        self.rotationPartkorobka2.touchRotLimit = Utils.degToRad(Utils.getNoNil(getXMLString(xmlFile, "vehicle.korobka2#touchRotLimit"), 10));
    end;	
local rotationPartNodekorobka3 = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.korobka3#index"));
    if rotationPartNodekorobka3 ~= nil then
        self.rotationPartkorobka3 = {};
        self.rotationPartkorobka3.node = rotationPartNodekorobka3;

        local x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotationPartkorobka3#minRot"));
        self.rotationPartkorobka3.minRot = {};
        self.rotationPartkorobka3.minRot[1] = Utils.degToRad(Utils.getNoNil(x, 0));
        self.rotationPartkorobka3.minRot[2] = Utils.degToRad(Utils.getNoNil(y, 0));
        self.rotationPartkorobka3.minRot[3] = Utils.degToRad(Utils.getNoNil(z, 0));

        x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.korobka3#maxRot"));
        self.rotationPartkorobka3.maxRot = {};
        self.rotationPartkorobka3.maxRot[1] = Utils.degToRad(Utils.getNoNil(x, 0));
        self.rotationPartkorobka3.maxRot[2] = Utils.degToRad(Utils.getNoNil(y, 0));
        self.rotationPartkorobka3.maxRot[3] = Utils.degToRad(Utils.getNoNil(z, 0));

        self.rotationPartkorobka3.rotTime = Utils.getNoNil(getXMLString(xmlFile, "vehicle.korobka3#rotTime"), 2)*1000;
        self.rotationPartkorobka3.touchRotLimit = Utils.degToRad(Utils.getNoNil(getXMLString(xmlFile, "vehicle.korobka3#touchRotLimit"), 10));
    end;		
	local rotationPartNodekorobka4 = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.korobka4#index"));
    if rotationPartNodekorobka4 ~= nil then
        self.rotationPartkorobka4 = {};
        self.rotationPartkorobka4.node = rotationPartNodekorobka4;

        local x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotationPartkorobka4#minRot"));
        self.rotationPartkorobka4.minRot = {};
        self.rotationPartkorobka4.minRot[1] = Utils.degToRad(Utils.getNoNil(x, 0));
        self.rotationPartkorobka4.minRot[2] = Utils.degToRad(Utils.getNoNil(y, 0));
        self.rotationPartkorobka4.minRot[3] = Utils.degToRad(Utils.getNoNil(z, 0));

        x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.korobka4#maxRot"));
        self.rotationPartkorobka4.maxRot = {};
        self.rotationPartkorobka4.maxRot[1] = Utils.degToRad(Utils.getNoNil(x, 0));
        self.rotationPartkorobka4.maxRot[2] = Utils.degToRad(Utils.getNoNil(y, 0));
        self.rotationPartkorobka4.maxRot[3] = Utils.degToRad(Utils.getNoNil(z, 0));

        self.rotationPartkorobka4.rotTime = Utils.getNoNil(getXMLString(xmlFile, "vehicle.korobka4#rotTime"), 2)*1000;
        self.rotationPartkorobka4.touchRotLimit = Utils.degToRad(Utils.getNoNil(getXMLString(xmlFile, "vehicle.korobka4#touchRotLimit"), 10));
    end;
	local rotationPartNodekorobkazad = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.korobkazad#index"));
    if rotationPartNodekorobkazad ~= nil then
        self.rotationPartkorobkazad = {};
        self.rotationPartkorobkazad.node = rotationPartNodekorobkazad;

        local x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotationPartkorobkazad#minRot"));
        self.rotationPartkorobkazad.minRot = {};
        self.rotationPartkorobkazad.minRot[1] = Utils.degToRad(Utils.getNoNil(x, 0));
        self.rotationPartkorobkazad.minRot[2] = Utils.degToRad(Utils.getNoNil(y, 0));
        self.rotationPartkorobkazad.minRot[3] = Utils.degToRad(Utils.getNoNil(z, 0));

        x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.korobkazad#maxRot"));
        self.rotationPartkorobkazad.maxRot = {};
        self.rotationPartkorobkazad.maxRot[1] = Utils.degToRad(Utils.getNoNil(x, 0));
        self.rotationPartkorobkazad.maxRot[2] = Utils.degToRad(Utils.getNoNil(y, 0));
        self.rotationPartkorobkazad.maxRot[3] = Utils.degToRad(Utils.getNoNil(z, 0));

        self.rotationPartkorobkazad.rotTime = Utils.getNoNil(getXMLString(xmlFile, "vehicle.korobkazad#rotTime"), 2)*1000;
        self.rotationPartkorobkazad.touchRotLimit = Utils.degToRad(Utils.getNoNil(getXMLString(xmlFile, "vehicle.korobkazad#touchRotLimit"), 10));
    end;












local rotationPartNoderu4ka1 = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.rotationPartru4ka1#index"));
      if rotationPartNoderu4ka1 ~= nil then
        self.rotationPartru4ka1 = {};
        self.rotationPartru4ka1.node = rotationPartNoderu4ka1;

        local x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotationPartru4ka1#minRot"));
        self.rotationPartru4ka1.minRot = {};
        self.rotationPartru4ka1.minRot[1] = Utils.degToRad(Utils.getNoNil(x, 0));
        self.rotationPartru4ka1.minRot[2] = Utils.degToRad(Utils.getNoNil(y, 0));
        self.rotationPartru4ka1.minRot[3] = Utils.degToRad(Utils.getNoNil(z, 0));

        x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotationPartru4ka1#maxRot"));
        self.rotationPartru4ka1.maxRot = {};
        self.rotationPartru4ka1.maxRot[1] = Utils.degToRad(Utils.getNoNil(x, 0));
        self.rotationPartru4ka1.maxRot[2] = Utils.degToRad(Utils.getNoNil(y, 0));
        self.rotationPartru4ka1.maxRot[3] = Utils.degToRad(Utils.getNoNil(z, 0));

        self.rotationPartru4ka1.rotTime = Utils.getNoNil(getXMLString(xmlFile, "vehicle.rotationPartru4ka1#rotTime"), 2)*1000;
        self.rotationPartru4ka1.touchRotLimit = Utils.degToRad(Utils.getNoNil(getXMLString(xmlFile, "vehicle.rotationPartru4ka1#touchRotLimit"), 10));
    end;

local rotationPartNoderu4ka2 = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.rotationPartru4ka2#index"));
      if rotationPartNoderu4ka2 ~= nil then
        self.rotationPartru4ka2 = {};
        self.rotationPartru4ka2.node = rotationPartNoderu4ka2;

        local x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotationPartru4ka2#minRot"));
        self.rotationPartru4ka2.minRot = {};
        self.rotationPartru4ka2.minRot[1] = Utils.degToRad(Utils.getNoNil(x, 0));
        self.rotationPartru4ka2.minRot[2] = Utils.degToRad(Utils.getNoNil(y, 0));
        self.rotationPartru4ka2.minRot[3] = Utils.degToRad(Utils.getNoNil(z, 0));

        x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotationPartru4ka2#maxRot"));
        self.rotationPartru4ka2.maxRot = {};
        self.rotationPartru4ka2.maxRot[1] = Utils.degToRad(Utils.getNoNil(x, 0));
        self.rotationPartru4ka2.maxRot[2] = Utils.degToRad(Utils.getNoNil(y, 0));
        self.rotationPartru4ka2.maxRot[3] = Utils.degToRad(Utils.getNoNil(z, 0));

        self.rotationPartru4ka2.rotTime = Utils.getNoNil(getXMLString(xmlFile, "vehicle.rotationPartru4ka2#rotTime"), 2)*1000;
        self.rotationPartru4ka2.touchRotLimit = Utils.degToRad(Utils.getNoNil(getXMLString(xmlFile, "vehicle.rotationPartru4ka2#touchRotLimit"), 10));
    end;



    self.wiper1Active = false;	
    self.wiper2Active = false;
    self.wiper3Active = false;	
    self.wiper4Active = false;
    self.wiper5Active = false;	
    self.wiper6Active = false;	
    self.delayOnLeft = 0;
    self.delayOffLeft = 0;
    self.delayOnRight = 0;
    self.delayOffRight = 0;
    self.delayWischer1 = 0;
    self.delayWischer2 = 0;
    self.delayOn = 0;
    self.delayOff = 0;
    self.deltafo = 0;

  local wiper1Node = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.wiper1#index"));
    if wiper1Node ~= nil then
        self.wiper1 = {};
        self.wiper1.node = wiper1Node;
        local x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.wiper1#minRot"));
        self.wiper1.minRot = {};
        self.wiper1.minRot[1] = Utils.degToRad(Utils.getNoNil(x, 0));
        self.wiper1.minRot[2] = Utils.degToRad(Utils.getNoNil(y, 0));
        self.wiper1.minRot[3] = Utils.degToRad(Utils.getNoNil(z, 0));
        x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.wiper1#maxRot"));
        self.wiper1.maxRot = {};
        self.wiper1.maxRot[1] = Utils.degToRad(Utils.getNoNil(x, 0));
        self.wiper1.maxRot[2] = Utils.degToRad(Utils.getNoNil(y, 0));
        self.wiper1.maxRot[3] = Utils.degToRad(Utils.getNoNil(z, 0));
        self.wiper1.rotTime = Utils.getNoNil(getXMLString(xmlFile, "vehicle.wiper1#rotTime"), 2)*1000;
        self.wiper1.touchRotLimit = Utils.degToRad(Utils.getNoNil(getXMLString(xmlFile, "vehicle.wiper1#touchRotLimit"), 10));
    end;
	
	local wiper2Node = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.wiper2#index"));
    if wiper2Node ~= nil then
        self.wiper2 = {};
        self.wiper2.node = wiper2Node;
        local x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.wiper2#minRot"));
        self.wiper2.minRot = {};
        self.wiper2.minRot[1] = Utils.degToRad(Utils.getNoNil(x, 0));
        self.wiper2.minRot[2] = Utils.degToRad(Utils.getNoNil(y, 0));
        self.wiper2.minRot[3] = Utils.degToRad(Utils.getNoNil(z, 0));
        x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.wiper2#maxRot"));
        self.wiper2.maxRot = {};
        self.wiper2.maxRot[1] = Utils.degToRad(Utils.getNoNil(x, 0));
        self.wiper2.maxRot[2] = Utils.degToRad(Utils.getNoNil(y, 0));
        self.wiper2.maxRot[3] = Utils.degToRad(Utils.getNoNil(z, 0));
        self.wiper2.rotTime = Utils.getNoNil(getXMLString(xmlFile, "vehicle.wiper2#rotTime"), 2)*1000;
        self.wiper2.touchRotLimit = Utils.degToRad(Utils.getNoNil(getXMLString(xmlFile, "vehicle.wiper2#touchRotLimit"), 10));
    end;


  local wiper3Node = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.wiper3#index"));
    if wiper3Node ~= nil then
        self.wiper3 = {};
        self.wiper3.node = wiper3Node;
        local x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.wiper3#minRot"));
        self.wiper3.minRot = {};
        self.wiper3.minRot[1] = Utils.degToRad(Utils.getNoNil(x, 0));
        self.wiper3.minRot[2] = Utils.degToRad(Utils.getNoNil(y, 0));
        self.wiper3.minRot[3] = Utils.degToRad(Utils.getNoNil(z, 0));
        x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.wiper3#maxRot"));
        self.wiper3.maxRot = {};
        self.wiper3.maxRot[1] = Utils.degToRad(Utils.getNoNil(x, 0));
        self.wiper3.maxRot[2] = Utils.degToRad(Utils.getNoNil(y, 0));
        self.wiper3.maxRot[3] = Utils.degToRad(Utils.getNoNil(z, 0));
        self.wiper3.rotTime = Utils.getNoNil(getXMLString(xmlFile, "vehicle.wiper3#rotTime"), 2)*1000;
        self.wiper3.touchRotLimit = Utils.degToRad(Utils.getNoNil(getXMLString(xmlFile, "vehicle.wiper3#touchRotLimit"), 10));
    end;
	
	local wiper4Node = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.wiper4#index"));
    if wiper4Node ~= nil then
        self.wiper4 = {};
        self.wiper4.node = wiper4Node;
        local x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.wiper4#minRot"));
        self.wiper4.minRot = {};
        self.wiper4.minRot[1] = Utils.degToRad(Utils.getNoNil(x, 0));
        self.wiper4.minRot[2] = Utils.degToRad(Utils.getNoNil(y, 0));
        self.wiper4.minRot[3] = Utils.degToRad(Utils.getNoNil(z, 0));
        x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.wiper4#maxRot"));
        self.wiper4.maxRot = {};
        self.wiper4.maxRot[1] = Utils.degToRad(Utils.getNoNil(x, 0));
        self.wiper4.maxRot[2] = Utils.degToRad(Utils.getNoNil(y, 0));
        self.wiper4.maxRot[3] = Utils.degToRad(Utils.getNoNil(z, 0));
        self.wiper4.rotTime = Utils.getNoNil(getXMLString(xmlFile, "vehicle.wiper4#rotTime"), 2)*1000;
        self.wiper4.touchRotLimit = Utils.degToRad(Utils.getNoNil(getXMLString(xmlFile, "vehicle.wiper4#touchRotLimit"), 10));
    end;

  local wiper5Node = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.wiper5#index"));
    if wiper5Node ~= nil then
        self.wiper5 = {};
        self.wiper5.node = wiper5Node;
        local x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.wiper5#minRot"));
        self.wiper5.minRot = {};
        self.wiper5.minRot[1] = Utils.degToRad(Utils.getNoNil(x, 0));
        self.wiper5.minRot[2] = Utils.degToRad(Utils.getNoNil(y, 0));
        self.wiper5.minRot[3] = Utils.degToRad(Utils.getNoNil(z, 0));
        x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.wiper5#maxRot"));
        self.wiper5.maxRot = {};
        self.wiper5.maxRot[1] = Utils.degToRad(Utils.getNoNil(x, 0));
        self.wiper5.maxRot[2] = Utils.degToRad(Utils.getNoNil(y, 0));
        self.wiper5.maxRot[3] = Utils.degToRad(Utils.getNoNil(z, 0));
        self.wiper5.rotTime = Utils.getNoNil(getXMLString(xmlFile, "vehicle.wiper5#rotTime"), 2)*1000;
        self.wiper5.touchRotLimit = Utils.degToRad(Utils.getNoNil(getXMLString(xmlFile, "vehicle.wiper5#touchRotLimit"), 10));
    end;
	
	local wiper6Node = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.wiper6#index"));
    if wiper6Node ~= nil then
        self.wiper6 = {};
        self.wiper6.node = wiper6Node;
        local x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.wiper6#minRot"));
        self.wiper6.minRot = {};
        self.wiper6.minRot[1] = Utils.degToRad(Utils.getNoNil(x, 0));
        self.wiper6.minRot[2] = Utils.degToRad(Utils.getNoNil(y, 0));
        self.wiper6.minRot[3] = Utils.degToRad(Utils.getNoNil(z, 0));
        x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.wiper6#maxRot"));
        self.wiper6.maxRot = {};
        self.wiper6.maxRot[1] = Utils.degToRad(Utils.getNoNil(x, 0));
        self.wiper6.maxRot[2] = Utils.degToRad(Utils.getNoNil(y, 0));
        self.wiper6.maxRot[3] = Utils.degToRad(Utils.getNoNil(z, 0));
        self.wiper6.rotTime = Utils.getNoNil(getXMLString(xmlFile, "vehicle.wiper6#rotTime"), 2)*1000;
        self.wiper6.touchRotLimit = Utils.degToRad(Utils.getNoNil(getXMLString(xmlFile, "vehicle.wiper6#touchRotLimit"), 10));
    end;





self.wentelatorNode1 = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.wentelator#index"));
	self.wentelatorRotationScale = Utils.getNoNil(getXMLFloat(xmlFile, "vehicle.wentelator#rotationScale"), 1);
	self.isTurnedOn = false;

self.wentelator1Node1 = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.wentelator1#index"));
	self.wentelator1RotationScale = Utils.getNoNil(getXMLFloat(xmlFile, "vehicle.wentelator1#rotationScale"), 1);
	self.isTurnedOn1 = false;

self.wentelator2Node1 = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.wentelator2#index"));
	self.wentelator2RotationScale = Utils.getNoNil(getXMLFloat(xmlFile, "vehicle.wentelator2#rotationScale"), 1);
	self.isTurnedOn2 = false;

self.wentelator3Node1 = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.wentelator3#index"));
	self.wentelator3RotationScale = Utils.getNoNil(getXMLFloat(xmlFile, "vehicle.wentelator3#rotationScale"), 1);
	self.isTurnedOn3 = false;





    self.motor1Active = false;
    self.motor2Active = false;		
    self.delayOnLeft = 0;
    self.delayOffLeft = 0;
    self.delayOnRight = 0;
    self.delayOffRight = 0;
    self.delayKurs1 = 0;
    self.delayKurs2 = 0;
    self.delayOn = 0;
    self.delayOff = 0;
    self.deltafo = 0;

  local motor1Node = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.motor1#index"));
    if motor1Node ~= nil then
        self.motor1 = {};
        self.motor1.node = motor1Node;
        local x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.motor1#minRot"));
        self.motor1.minRot = {};
        self.motor1.minRot[1] = Utils.degToRad(Utils.getNoNil(x, 0));
        self.motor1.minRot[2] = Utils.degToRad(Utils.getNoNil(y, 0));
        self.motor1.minRot[3] = Utils.degToRad(Utils.getNoNil(z, 0));
        x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.motor1#maxRot"));
        self.motor1.maxRot = {};
        self.motor1.maxRot[1] = Utils.degToRad(Utils.getNoNil(x, 0));
        self.motor1.maxRot[2] = Utils.degToRad(Utils.getNoNil(y, 0));
        self.motor1.maxRot[3] = Utils.degToRad(Utils.getNoNil(z, 0));
        self.motor1.rotTime = Utils.getNoNil(getXMLString(xmlFile, "vehicle.motor1#rotTime"), 2)*70;
        self.motor1.touchRotLimit = Utils.degToRad(Utils.getNoNil(getXMLString(xmlFile, "vehicle.motor1#touchRotLimit"), 10));
    end;

  local motor2Node = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.motor2#index"));
    if motor2Node ~= nil then
        self.motor2 = {};
        self.motor2.node = motor2Node;
        local x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.motor2#minRot"));
        self.motor2.minRot = {};
        self.motor2.minRot[1] = Utils.degToRad(Utils.getNoNil(x, 0));
        self.motor2.minRot[2] = Utils.degToRad(Utils.getNoNil(y, 0));
        self.motor2.minRot[3] = Utils.degToRad(Utils.getNoNil(z, 0));
        x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.motor2#maxRot"));
        self.motor2.maxRot = {};
        self.motor2.maxRot[1] = Utils.degToRad(Utils.getNoNil(x, 0));
        self.motor2.maxRot[2] = Utils.degToRad(Utils.getNoNil(y, 0));
        self.motor2.maxRot[3] = Utils.degToRad(Utils.getNoNil(z, 0));
        self.motor2.rotTime = Utils.getNoNil(getXMLString(xmlFile, "vehicle.motor2#rotTime"), 2)*70;
        self.motor2.touchRotLimit = Utils.degToRad(Utils.getNoNil(getXMLString(xmlFile, "vehicle.motor2#touchRotLimit"), 10));
    end;







local rotationPartNodepoworotnika = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.poworotnika#index"));
    if rotationPartNodepoworotnika ~= nil then
        self.rotationPartpoworotnika = {};
        self.rotationPartpoworotnika.node = rotationPartNodepoworotnika;

        local x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotationPartpoworotnika#minRot"));
        self.rotationPartpoworotnika.minRot = {};
        self.rotationPartpoworotnika.minRot[1] = Utils.degToRad(Utils.getNoNil(x, 0));
        self.rotationPartpoworotnika.minRot[2] = Utils.degToRad(Utils.getNoNil(y, 0));
        self.rotationPartpoworotnika.minRot[3] = Utils.degToRad(Utils.getNoNil(z, 0));

        x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.poworotnika#maxRot"));
        self.rotationPartpoworotnika.maxRot = {};
        self.rotationPartpoworotnika.maxRot[1] = Utils.degToRad(Utils.getNoNil(x, 0));
        self.rotationPartpoworotnika.maxRot[2] = Utils.degToRad(Utils.getNoNil(y, 0));
        self.rotationPartpoworotnika.maxRot[3] = Utils.degToRad(Utils.getNoNil(z, 0));

        self.rotationPartpoworotnika.rotTime = Utils.getNoNil(getXMLString(xmlFile, "vehicle.poworotnika#rotTime"), 2)*1000;
        self.rotationPartpoworotnika.touchRotLimit = Utils.degToRad(Utils.getNoNil(getXMLString(xmlFile, "vehicle.poworotnika#touchRotLimit"), 10));
    end;

local rotationPartNodepoworotnikk = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.poworotnikk#index"));
    if rotationPartNodepoworotnikk ~= nil then
        self.rotationPartpoworotnikk = {};
        self.rotationPartpoworotnikk.node = rotationPartNodepoworotnikk;

        local x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotationPartpoworotnikk#minRot"));
        self.rotationPartpoworotnikk.minRot = {};
        self.rotationPartpoworotnikk.minRot[1] = Utils.degToRad(Utils.getNoNil(x, 0));
        self.rotationPartpoworotnikk.minRot[2] = Utils.degToRad(Utils.getNoNil(y, 0));
        self.rotationPartpoworotnikk.minRot[3] = Utils.degToRad(Utils.getNoNil(z, 0));

        x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.poworotnikk#maxRot"));
        self.rotationPartpoworotnikk.maxRot = {};
        self.rotationPartpoworotnikk.maxRot[1] = Utils.degToRad(Utils.getNoNil(x, 0));
        self.rotationPartpoworotnikk.maxRot[2] = Utils.degToRad(Utils.getNoNil(y, 0));
        self.rotationPartpoworotnikk.maxRot[3] = Utils.degToRad(Utils.getNoNil(z, 0));

        self.rotationPartpoworotnikk.rotTime = Utils.getNoNil(getXMLString(xmlFile, "vehicle.poworotnikk#rotTime"), 2)*1000;
        self.rotationPartpoworotnikk.touchRotLimit = Utils.degToRad(Utils.getNoNil(getXMLString(xmlFile, "vehicle.poworotnikk#touchRotLimit"), 10));
    end;

local rotationPartNodepoworotnik = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.poworotnik#index"));
    if rotationPartNodepoworotnik ~= nil then
        self.rotationPartpoworotnik = {};
        self.rotationPartpoworotnik.node = rotationPartNodepoworotnik;

        local x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotationPartpoworotnik#minRot"));
        self.rotationPartpoworotnik.minRot = {};
        self.rotationPartpoworotnik.minRot[1] = Utils.degToRad(Utils.getNoNil(x, 0));
        self.rotationPartpoworotnik.minRot[2] = Utils.degToRad(Utils.getNoNil(y, 0));
        self.rotationPartpoworotnik.minRot[3] = Utils.degToRad(Utils.getNoNil(z, 0));

        x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.poworotnik#maxRot"));
        self.rotationPartpoworotnik.maxRot = {};
        self.rotationPartpoworotnik.maxRot[1] = Utils.degToRad(Utils.getNoNil(x, 0));
        self.rotationPartpoworotnik.maxRot[2] = Utils.degToRad(Utils.getNoNil(y, 0));
        self.rotationPartpoworotnik.maxRot[3] = Utils.degToRad(Utils.getNoNil(z, 0));

        self.rotationPartpoworotnik.rotTime = Utils.getNoNil(getXMLString(xmlFile, "vehicle.poworotnik#rotTime"), 2)*1000;
        self.rotationPartpoworotnik.touchRotLimit = Utils.degToRad(Utils.getNoNil(getXMLString(xmlFile, "vehicle.poworotnik#touchRotLimit"), 10));
    end;
local rotationPartNodepoworotnik0 = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.poworotnik0#index"));
    if rotationPartNodepoworotnik0 ~= nil then
        self.rotationPartpoworotnik0 = {};
        self.rotationPartpoworotnik0.node = rotationPartNodepoworotnik0;

        local x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotationPartpoworotnik0#minRot"));
        self.rotationPartpoworotnik0.minRot = {};
        self.rotationPartpoworotnik0.minRot[1] = Utils.degToRad(Utils.getNoNil(x, 0));
        self.rotationPartpoworotnik0.minRot[2] = Utils.degToRad(Utils.getNoNil(y, 0));
        self.rotationPartpoworotnik0.minRot[3] = Utils.degToRad(Utils.getNoNil(z, 0));

        x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.poworotnik0#maxRot"));
        self.rotationPartpoworotnik0.maxRot = {};
        self.rotationPartpoworotnik0.maxRot[1] = Utils.degToRad(Utils.getNoNil(x, 0));
        self.rotationPartpoworotnik0.maxRot[2] = Utils.degToRad(Utils.getNoNil(y, 0));
        self.rotationPartpoworotnik0.maxRot[3] = Utils.degToRad(Utils.getNoNil(z, 0));

        self.rotationPartpoworotnik0.rotTime = Utils.getNoNil(getXMLString(xmlFile, "vehicle.poworotnik0#rotTime"), 2)*1000;
        self.rotationPartpoworotnik0.touchRotLimit = Utils.degToRad(Utils.getNoNil(getXMLString(xmlFile, "vehicle.poworotnik0#touchRotLimit"), 10));
    end;









	local rotationPartNodePedal3 = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.rotationPartPedal3#index"));
    if rotationPartNodePedal3 ~= nil then
        self.rotationPartPedal3 = {};
        self.rotationPartPedal3.node = rotationPartNodePedal3;

        local x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotationPartPedal3#minRot"));
        self.rotationPartPedal3.minRot = {};
        self.rotationPartPedal3.minRot[1] = Utils.degToRad(Utils.getNoNil(x, 0));
        self.rotationPartPedal3.minRot[2] = Utils.degToRad(Utils.getNoNil(y, 0));
        self.rotationPartPedal3.minRot[3] = Utils.degToRad(Utils.getNoNil(z, 0));

        x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotationPartPedal3#maxRot"));
        self.rotationPartPedal3.maxRot = {};
        self.rotationPartPedal3.maxRot[1] = Utils.degToRad(Utils.getNoNil(x, 0));
        self.rotationPartPedal3.maxRot[2] = Utils.degToRad(Utils.getNoNil(y, 0));
        self.rotationPartPedal3.maxRot[3] = Utils.degToRad(Utils.getNoNil(z, 0));

        self.rotationPartPedal3.rotTime = Utils.getNoNil(getXMLString(xmlFile, "vehicle.rotationPartPedal3#rotTime"), 2)*1000;
        self.rotationPartPedal3.touchRotLimit = Utils.degToRad(Utils.getNoNil(getXMLString(xmlFile, "vehicle.rotationPartPedal3#touchRotLimit"), 10));
    end;

	local rotationPartNodePedal2 = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.rotationPartPedal2#index"));
    if rotationPartNodePedal2 ~= nil then
        self.rotationPartPedal2 = {};
        self.rotationPartPedal2.node = rotationPartNodePedal2;

        local x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotationPartPedal2#minRot"));
        self.rotationPartPedal2.minRot = {};
        self.rotationPartPedal2.minRot[1] = Utils.degToRad(Utils.getNoNil(x, 0));
        self.rotationPartPedal2.minRot[2] = Utils.degToRad(Utils.getNoNil(y, 0));
        self.rotationPartPedal2.minRot[3] = Utils.degToRad(Utils.getNoNil(z, 0));

        x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotationPartPedal2#maxRot"));
        self.rotationPartPedal2.maxRot = {};
        self.rotationPartPedal2.maxRot[1] = Utils.degToRad(Utils.getNoNil(x, 0));
        self.rotationPartPedal2.maxRot[2] = Utils.degToRad(Utils.getNoNil(y, 0));
        self.rotationPartPedal2.maxRot[3] = Utils.degToRad(Utils.getNoNil(z, 0));

        self.rotationPartPedal2.rotTime = Utils.getNoNil(getXMLString(xmlFile, "vehicle.rotationPartPedal2#rotTime"), 2)*1000;
        self.rotationPartPedal2.touchRotLimit = Utils.degToRad(Utils.getNoNil(getXMLString(xmlFile, "vehicle.rotationPartPedal2#touchRotLimit"), 10));
    end;

	local rotationPartNodePedalr = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.rotationPartPedalr#index"));
    if rotationPartNodePedalr ~= nil then
        self.rotationPartPedalr = {};
        self.rotationPartPedalr.node = rotationPartNodePedalr;

        local x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotationPartPedalr#minRot"));
        self.rotationPartPedalr.minRot = {};
        self.rotationPartPedalr.minRot[1] = Utils.degToRad(Utils.getNoNil(x, 0));
        self.rotationPartPedalr.minRot[2] = Utils.degToRad(Utils.getNoNil(y, 0));
        self.rotationPartPedalr.minRot[3] = Utils.degToRad(Utils.getNoNil(z, 0));

        x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotationPartPedalr#maxRot"));
        self.rotationPartPedalr.maxRot = {};
        self.rotationPartPedalr.maxRot[1] = Utils.degToRad(Utils.getNoNil(x, 0));
        self.rotationPartPedalr.maxRot[2] = Utils.degToRad(Utils.getNoNil(y, 0));
        self.rotationPartPedalr.maxRot[3] = Utils.degToRad(Utils.getNoNil(z, 0));

        self.rotationPartPedalr.rotTime = Utils.getNoNil(getXMLString(xmlFile, "vehicle.rotationPartPedalr#rotTime"), 2)*1000;
        self.rotationPartPedalr.touchRotLimit = Utils.degToRad(Utils.getNoNil(getXMLString(xmlFile, "vehicle.rotationPartPedalr#touchRotLimit"), 10));
    end;

local rotationPartNodeDrehzahl1 = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.rotationPartDrehzahl1#index"));
    if rotationPartNodeDrehzahl1 ~= nil then
        self.rotationPartDrehzahl1 = {};
        self.rotationPartDrehzahl1.node = rotationPartNodeDrehzahl1;

        local x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotationPartDrehzahl1#minRot"));
        self.rotationPartDrehzahl1.minRot = {};
        self.rotationPartDrehzahl1.minRot[1] = Utils.degToRad(Utils.getNoNil(x, 0));
        self.rotationPartDrehzahl1.minRot[2] = Utils.degToRad(Utils.getNoNil(y, 0));
        self.rotationPartDrehzahl1.minRot[3] = Utils.degToRad(Utils.getNoNil(z, 0));

        x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotationPartDrehzahl1#maxRot"));
        self.rotationPartDrehzahl1.maxRot = {};
        self.rotationPartDrehzahl1.maxRot[1] = Utils.degToRad(Utils.getNoNil(x, 0));
        self.rotationPartDrehzahl1.maxRot[2] = Utils.degToRad(Utils.getNoNil(y, 0));
        self.rotationPartDrehzahl1.maxRot[3] = Utils.degToRad(Utils.getNoNil(z, 0));

        self.rotationPartDrehzahl1.rotTime = Utils.getNoNil(getXMLString(xmlFile, "vehicle.rotationPartDrehzahl1#rotTime"), 2)*1000;
        self.rotationPartDrehzahl1.touchRotLimit = Utils.degToRad(Utils.getNoNil(getXMLString(xmlFile, "vehicle.rotationPartDrehzahl1#touchRotLimit"), 10));
    end;
	
	local rotationPartNodeDrehzahl2 = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.rotationPartDrehzahl2#index"));
    if rotationPartNodeDrehzahl2 ~= nil then
        self.rotationPartDrehzahl2 = {};
        self.rotationPartDrehzahl2.node = rotationPartNodeDrehzahl2;

        local x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotationPartDrehzahl2#minRot"));
        self.rotationPartDrehzahl2.minRot = {};
        self.rotationPartDrehzahl2.minRot[1] = Utils.degToRad(Utils.getNoNil(x, 0));
        self.rotationPartDrehzahl2.minRot[2] = Utils.degToRad(Utils.getNoNil(y, 0));
        self.rotationPartDrehzahl2.minRot[3] = Utils.degToRad(Utils.getNoNil(z, 0));

        x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotationPartDrehzahl2#maxRot"));
        self.rotationPartDrehzahl2.maxRot = {};
        self.rotationPartDrehzahl2.maxRot[1] = Utils.degToRad(Utils.getNoNil(x, 0));
        self.rotationPartDrehzahl2.maxRot[2] = Utils.degToRad(Utils.getNoNil(y, 0));
        self.rotationPartDrehzahl2.maxRot[3] = Utils.degToRad(Utils.getNoNil(z, 0));

        self.rotationPartDrehzahl2.rotTime = Utils.getNoNil(getXMLString(xmlFile, "vehicle.rotationPartDrehzahl2#rotTime"), 2)*1000;
        self.rotationPartDrehzahl2.touchRotLimit = Utils.degToRad(Utils.getNoNil(getXMLString(xmlFile, "vehicle.rotationPartDrehzahl2#touchRotLimit"), 10));
    end;





      self.tanklight = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.tanklight#index"));
	self.tank2light = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.tanklight#index2"));
      self.tanklightActive = false;

local rotationPartNodeTanknadel = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.rotationPartTanknadel#index"));
    if rotationPartNodeTanknadel ~= nil then
        self.rotationPartTanknadel = {};
        self.rotationPartTanknadel.node = rotationPartNodeTanknadel;

        local x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotationPartTanknadel#minRot"));
        self.rotationPartTanknadel.minRot = {};
        self.rotationPartTanknadel.minRot[1] = Utils.degToRad(Utils.getNoNil(x, 0));
        self.rotationPartTanknadel.minRot[2] = Utils.degToRad(Utils.getNoNil(y, 0));
        self.rotationPartTanknadel.minRot[3] = Utils.degToRad(Utils.getNoNil(z, 0));

        x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotationPartTanknadel#maxRot"));
        self.rotationPartTanknadel.maxRot = {};
        self.rotationPartTanknadel.maxRot[1] = Utils.degToRad(Utils.getNoNil(x, 0));
        self.rotationPartTanknadel.maxRot[2] = Utils.degToRad(Utils.getNoNil(y, 0));
        self.rotationPartTanknadel.maxRot[3] = Utils.degToRad(Utils.getNoNil(z, 0));

        self.rotationPartTanknadel.rotTime = Utils.getNoNil(getXMLString(xmlFile, "vehicle.rotationPartTanknadel#rotTime"), 2)*1000;
        self.rotationPartTanknadel.touchRotLimit = Utils.degToRad(Utils.getNoNil(getXMLString(xmlFile, "vehicle.rotationPartTanknadel#touchRotLimit"), 10));
    end;
	
	local rotationPartNodeTanknadel2 = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.rotationPartTanknadel2#index"));
    if rotationPartNodeTanknadel2 ~= nil then
        self.rotationPartTanknadel2 = {};
        self.rotationPartTanknadel2.node = rotationPartNodeTanknadel2;

        local x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotationPartTanknadel2#minRot"));
        self.rotationPartTanknadel2.minRot = {};
        self.rotationPartTanknadel2.minRot[1] = Utils.degToRad(Utils.getNoNil(x, 0));
        self.rotationPartTanknadel2.minRot[2] = Utils.degToRad(Utils.getNoNil(y, 0));
        self.rotationPartTanknadel2.minRot[3] = Utils.degToRad(Utils.getNoNil(z, 0));

        x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotationPartTanknadel2#maxRot"));
        self.rotationPartTanknadel2.maxRot = {};
        self.rotationPartTanknadel2.maxRot[1] = Utils.degToRad(Utils.getNoNil(x, 0));
        self.rotationPartTanknadel2.maxRot[2] = Utils.degToRad(Utils.getNoNil(y, 0));
        self.rotationPartTanknadel2.maxRot[3] = Utils.degToRad(Utils.getNoNil(z, 0));

        self.rotationPartTanknadel2.rotTime = Utils.getNoNil(getXMLString(xmlFile, "vehicle.rotationPartTanknadel2#rotTime"), 2)*1000;
        self.rotationPartTanknadel2.touchRotLimit = Utils.degToRad(Utils.getNoNil(getXMLString(xmlFile, "vehicle.rotationPartTanknadel2#touchRotLimit"), 10));
    end;

    fuelwarningSoundFile = Utils.getFilename("sounds/fuelwarning.wav", self.baseDirectory);
    self.fuelwarningSoundId = createSample("fuelwarningSound");
    loadSample(self.fuelwarningSoundId, fuelwarningSoundFile, false);
    self.fuelwarningPlaying = false;







	local rotationPartNodePedal = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.rotationPartPedal#index"));
    if rotationPartNodePedal ~= nil then
        self.rotationPartPedal = {};
        self.rotationPartPedal.node = rotationPartNodePedal;

        local x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotationPartPedal#minRot"));
        self.rotationPartPedal.minRot = {};
        self.rotationPartPedal.minRot[1] = Utils.degToRad(Utils.getNoNil(x, 0));
        self.rotationPartPedal.minRot[2] = Utils.degToRad(Utils.getNoNil(y, 0));
        self.rotationPartPedal.minRot[3] = Utils.degToRad(Utils.getNoNil(z, 0));

        x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotationPartPedal#maxRot"));
        self.rotationPartPedal.maxRot = {};
        self.rotationPartPedal.maxRot[1] = Utils.degToRad(Utils.getNoNil(x, 0));
        self.rotationPartPedal.maxRot[2] = Utils.degToRad(Utils.getNoNil(y, 0));
        self.rotationPartPedal.maxRot[3] = Utils.degToRad(Utils.getNoNil(z, 0));

        self.rotationPartPedal.rotTime = Utils.getNoNil(getXMLString(xmlFile, "vehicle.rotationPartPedal#rotTime"), 2)*1000;
        self.rotationPartPedal.touchRotLimit = Utils.degToRad(Utils.getNoNil(getXMLString(xmlFile, "vehicle.rotationPartPedal#touchRotLimit"), 10));
    end;

local rotationPartNodeKmh1 = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.rotationPartKmh1#index"));
    if rotationPartNodeKmh1 ~= nil then
        self.rotationPartKmh1 = {};
        self.rotationPartKmh1.node = rotationPartNodeKmh1;

        local x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotationPartKmh1#minRot"));
        self.rotationPartKmh1.minRot = {};
        self.rotationPartKmh1.minRot[1] = Utils.degToRad(Utils.getNoNil(x, 0));
        self.rotationPartKmh1.minRot[2] = Utils.degToRad(Utils.getNoNil(y, 0));
        self.rotationPartKmh1.minRot[3] = Utils.degToRad(Utils.getNoNil(z, 0));

        x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotationPartKmh1#maxRot"));
        self.rotationPartKmh1.maxRot = {};
        self.rotationPartKmh1.maxRot[1] = Utils.degToRad(Utils.getNoNil(x, 0));
        self.rotationPartKmh1.maxRot[2] = Utils.degToRad(Utils.getNoNil(y, 0));
        self.rotationPartKmh1.maxRot[3] = Utils.degToRad(Utils.getNoNil(z, 0));

        self.rotationPartKmh1.rotTime = Utils.getNoNil(getXMLString(xmlFile, "vehicle.rotationPartKmh1#rotTime"), 2)*1000;
        self.rotationPartKmh1.touchRotLimit = Utils.degToRad(Utils.getNoNil(getXMLString(xmlFile, "vehicle.rotationPartKmh1#touchRotLimit"), 10));
    end;
	
	local rotationPartNodeKmh2 = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.rotationPartKmh2#index"));
    if rotationPartNodeKmh2 ~= nil then
        self.rotationPartKmh2 = {};
        self.rotationPartKmh2.node = rotationPartNodeKmh2;

        local x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotationPartKmh2#minRot"));
        self.rotationPartKmh2.minRot = {};
        self.rotationPartKmh2.minRot[1] = Utils.degToRad(Utils.getNoNil(x, 0));
        self.rotationPartKmh2.minRot[2] = Utils.degToRad(Utils.getNoNil(y, 0));
        self.rotationPartKmh2.minRot[3] = Utils.degToRad(Utils.getNoNil(z, 0));

        x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotationPartKmh2#maxRot"));
        self.rotationPartKmh2.maxRot = {};
        self.rotationPartKmh2.maxRot[1] = Utils.degToRad(Utils.getNoNil(x, 0));
        self.rotationPartKmh2.maxRot[2] = Utils.degToRad(Utils.getNoNil(y, 0));
        self.rotationPartKmh2.maxRot[3] = Utils.degToRad(Utils.getNoNil(z, 0));

        self.rotationPartKmh2.rotTime = Utils.getNoNil(getXMLString(xmlFile, "vehicle.rotationPartKmh2#rotTime"), 2)*1000;
        self.rotationPartKmh2.touchRotLimit = Utils.degToRad(Utils.getNoNil(getXMLString(xmlFile, "vehicle.rotationPartKmh2#touchRotLimit"), 10));
    end;

local rotationPartNodeBrake = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.rotationPartBrake#index"));
    if rotationPartNodeBrake ~= nil then
        self.rotationPartBrake = {};
        self.rotationPartBrake.node = rotationPartNodeBrake;

        local x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotationPartBrake#minRot"));
        self.rotationPartBrake.minRot = {};
        self.rotationPartBrake.minRot[1] = Utils.degToRad(Utils.getNoNil(x, 0));
        self.rotationPartBrake.minRot[2] = Utils.degToRad(Utils.getNoNil(y, 0));
        self.rotationPartBrake.minRot[3] = Utils.degToRad(Utils.getNoNil(z, 0));

        x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotationPartBrake#maxRot"));
        self.rotationPartBrake.maxRot = {};
        self.rotationPartBrake.maxRot[1] = Utils.degToRad(Utils.getNoNil(x, 0));
        self.rotationPartBrake.maxRot[2] = Utils.degToRad(Utils.getNoNil(y, 0));
        self.rotationPartBrake.maxRot[3] = Utils.degToRad(Utils.getNoNil(z, 0));

        self.rotationPartBrake.rotTime = Utils.getNoNil(getXMLString(xmlFile, "vehicle.rotationPartBrake#rotTime"), 2)*1000;
        self.rotationPartBrake.touchRotLimit = Utils.degToRad(Utils.getNoNil(getXMLString(xmlFile, "vehicle.rotationPartBrake#touchRotLimit"), 10));
    end;

	local translationPartNode = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.translationPart#index"));
    if translationPartNode ~= nil then
        self.translationPart = {};
        self.translationPart.node = translationPartNode;
        local x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.translationPart#minTrans"));
        self.translationPart.minTrans = {};
        self.translationPart.minTrans[1] = Utils.getNoNil(x, 0);
        self.translationPart.minTrans[2] = Utils.getNoNil(y, 0);
        self.translationPart.minTrans[3] = Utils.getNoNil(z, 0);

        x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.translationPart#maxTrans"));
        self.translationPart.maxTrans = {};
        self.translationPart.maxTrans[1] = Utils.getNoNil(x, 0);
        self.translationPart.maxTrans[2] = Utils.getNoNil(y, 0);
        self.translationPart.maxTrans[3] = Utils.getNoNil(z, 0);

        self.translationPart.transTime = Utils.getNoNil(getXMLString(xmlFile, "vehicle.translationPart#transTime"), 2)*1000;
        self.translationPart.touchTransLimit = Utils.getNoNil(getXMLString(xmlFile, "vehicle.translationPart#touchTransLimit"), 10);
    end;
    local translationPartNode2 = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.translationPart2#index"));
    if translationPartNode2 ~= nil then
        self.translationPart2 = {};
        self.translationPart2.node = translationPartNode2;
        local x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.translationPart2#minTrans"));
        self.translationPart2.minTrans = {};
        self.translationPart2.minTrans[1] = Utils.getNoNil(x, 0);
        self.translationPart2.minTrans[2] = Utils.getNoNil(y, 0);
        self.translationPart2.minTrans[3] = Utils.getNoNil(z, 0);

        x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.translationPart2#maxTrans"));
        self.translationPart2.maxTrans = {};
        self.translationPart2.maxTrans[1] = Utils.getNoNil(x, 0);
        self.translationPart2.maxTrans[2] = Utils.getNoNil(y, 0);
        self.translationPart2.maxTrans[3] = Utils.getNoNil(z, 0);

        self.translationPart2.transTime = Utils.getNoNil(getXMLString(xmlFile, "vehicle.translationPart2#transTime"), 2)*1000;
        self.translationPart2.touchTransLimit = Utils.getNoNil(getXMLString(xmlFile, "vehicle.translationPart2#touchTransLimit"), 10);
    end; 

	local rotationNode6 = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.rotation6#index"));
    if rotationNode6 ~= nil then
        self.rotation6 = {};
        self.rotation6.node = rotationNode6;
        local x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotation6#minRot"));
        self.rotation6.minRot = {};
        self.rotation6.minRot[1] = Utils.degToRad(Utils.getNoNil(x, 0));
        self.rotation6.minRot[2] = Utils.degToRad(Utils.getNoNil(y, 0));
        self.rotation6.minRot[3] = Utils.degToRad(Utils.getNoNil(z, 0));

        x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotation6#maxRot"));
        self.rotation6.maxRot = {};
        self.rotation6.maxRot[1] = Utils.degToRad(Utils.getNoNil(x, 0));
        self.rotation6.maxRot[2] = Utils.degToRad(Utils.getNoNil(y, 0));
        self.rotation6.maxRot[3] = Utils.degToRad(Utils.getNoNil(z, 0));

        self.rotation6.rotTime = Utils.getNoNil(getXMLString(xmlFile, "vehicle.rotation6#rotTime"), 2)*1000;
        self.rotation6.touchRotLimit = Utils.degToRad(Utils.getNoNil(getXMLString(xmlFile, "vehicle.rotation6#touchRotLimit"), 10));
    end; 

	local rotationNode7 = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.rotation7#index"));
    if rotationNode7 ~= nil then
        self.rotation7 = {};
        self.rotation7.node = rotationNode7;
        local x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotation7#minRot"));
        self.rotation7.minRot = {};
        self.rotation7.minRot[1] = Utils.degToRad(Utils.getNoNil(x, 0));
        self.rotation7.minRot[2] = Utils.degToRad(Utils.getNoNil(y, 0));
        self.rotation7.minRot[3] = Utils.degToRad(Utils.getNoNil(z, 0));

        x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotation7#maxRot"));
        self.rotation7.maxRot = {};
        self.rotation7.maxRot[1] = Utils.degToRad(Utils.getNoNil(x, 0));
        self.rotation7.maxRot[2] = Utils.degToRad(Utils.getNoNil(y, 0));
        self.rotation7.maxRot[3] = Utils.degToRad(Utils.getNoNil(z, 0));

        self.rotation7.rotTime = Utils.getNoNil(getXMLString(xmlFile, "vehicle.rotation7#rotTime"), 2)*1000;
        self.rotation7.touchRotLimit = Utils.degToRad(Utils.getNoNil(getXMLString(xmlFile, "vehicle.rotation7#touchRotLimit"), 10));
    end;       
	
	local rotationNode8 = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.rotation8#index"));
    if rotationNode8 ~= nil then
        self.rotation8 = {};
        self.rotation8.node = rotationNode8;
        local x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotation8#minRot"));
        self.rotation8.minRot = {};
        self.rotation8.minRot[1] = Utils.degToRad(Utils.getNoNil(x, 0));
        self.rotation8.minRot[2] = Utils.degToRad(Utils.getNoNil(y, 0));
        self.rotation8.minRot[3] = Utils.degToRad(Utils.getNoNil(z, 0));

        x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotation8#maxRot"));
        self.rotation8.maxRot = {};
        self.rotation8.maxRot[1] = Utils.degToRad(Utils.getNoNil(x, 0));
        self.rotation8.maxRot[2] = Utils.degToRad(Utils.getNoNil(y, 0));
        self.rotation8.maxRot[3] = Utils.degToRad(Utils.getNoNil(z, 0));

        self.rotation8.rotTime = Utils.getNoNil(getXMLString(xmlFile, "vehicle.rotation8#rotTime"), 2)*1000;
        self.rotation8.touchRotLimit = Utils.degToRad(Utils.getNoNil(getXMLString(xmlFile, "vehicle.rotation8#touchRotLimit"), 10));
    end;
	
	local rotationNode9 = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.rotation9#index"));
    if rotationNode9 ~= nil then
        self.rotation9 = {};
        self.rotation9.node = rotationNode9;
        local x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotation9#minRot"));
        self.rotation9.minRot = {};
        self.rotation9.minRot[1] = Utils.degToRad(Utils.getNoNil(x, 0));
        self.rotation9.minRot[2] = Utils.degToRad(Utils.getNoNil(y, 0));
        self.rotation9.minRot[3] = Utils.degToRad(Utils.getNoNil(z, 0));

        x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotation9#maxRot"));
        self.rotation9.maxRot = {};
        self.rotation9.maxRot[1] = Utils.degToRad(Utils.getNoNil(x, 0));
        self.rotation9.maxRot[2] = Utils.degToRad(Utils.getNoNil(y, 0));
        self.rotation9.maxRot[3] = Utils.degToRad(Utils.getNoNil(z, 0));

        self.rotation9.rotTime = Utils.getNoNil(getXMLString(xmlFile, "vehicle.rotation9#rotTime"), 2)*1000;
        self.rotation9.touchRotLimit = Utils.degToRad(Utils.getNoNil(getXMLString(xmlFile, "vehicle.rotation9#touchRotLimit"), 10));
    end;

    local rotationPartNodeLeft11 = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.rotationPartLeft11#index"));
    if rotationPartNodeLeft11 ~= nil then
        self.rotationPartLeft11 = {};
        self.rotationPartLeft11.node = rotationPartNodeLeft11;
        local x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotationPartLeft11#minRot"));
        self.rotationPartLeft11.minRot = {};
        self.rotationPartLeft11.minRot[1] = Utils.degToRad(Utils.getNoNil(x, 0));
        self.rotationPartLeft11.minRot[2] = Utils.degToRad(Utils.getNoNil(y, 0));
        self.rotationPartLeft11.minRot[3] = Utils.degToRad(Utils.getNoNil(z, 0));
        x, y, z = Utils.getVectorFromString(getXMLString(xmlFile, "vehicle.rotationPartLeft11#maxRot"));
        self.rotationPartLeft11.maxRot = {};
        self.rotationPartLeft11.maxRot[1] = Utils.degToRad(Utils.getNoNil(x, 0));
        self.rotationPartLeft11.maxRot[2] = Utils.degToRad(Utils.getNoNil(y, 0));
        self.rotationPartLeft11.maxRot[3] = Utils.degToRad(Utils.getNoNil(z, 0));
        self.rotationPartLeft11.rotTime = Utils.getNoNil(getXMLString(xmlFile, "vehicle.rotationPartLeft11#rotTime"), 2)*1000;
        self.rotationPartLeft11.touchRotLimit = Utils.degToRad(Utils.getNoNil(getXMLString(xmlFile, "vehicle.rotationPartLeft11#touchRotLimit"), 10));
    end;



end;



















      
function Teleskopladerser:delete()    
end;


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

	  
function Teleskopladerser:keyEvent(unicode, sym, modifier, isDown)

--[[info]]------------------------------------------------------------
 if isDown and sym == Input.KEY_0 then
		self.helpPanel = not self.helpPanel;
	end;



--[[stop]]------------------------------------------------------------	
if isDown and sym == Input.KEY_space then
		self.handbrake = not self.handbrake;
		if self.handbrake then
			playSample(self.handbrakeSoundId,1,1,0);
		end;
	end;






--[[rul]]------------------------------------------------------------
  if isDown and sym == Input.KEY_l then
	    self.frontlightsActive = not self.frontlightsActive;
	  
	end;

--[[panel]]------------------------------------------------------------
  if isDown and sym == Input.KEY_KP_enter then
	    self.kablightsActive = not self.kablightsActive;
	  
	end;











      if self.rotationPartTanknadel ~= nil then
		local x, y, z = getRotation(self.rotationPartTanknadel.node);
		y = ((self.rotationPartTanknadel.maxRot[2] - self.rotationPartTanknadel.minRot[2]) / self.fuelCapacity) * self.fuelFillLevel + self.rotationPartTanknadel.minRot[2];
		setRotation(self.rotationPartTanknadel.node, x, y ,z);
	end;
	
	if self.rotationPartTanknadel2 ~= nil then
		local x, y, z = getRotation(self.rotationPartTanknadel2.node);
		y = ((self.rotationPartTanknadel2.maxRot[2] - self.rotationPartTanknadel2.minRot[2]) / self.fuelCapacity) * self.fuelFillLevel + self.rotationPartTanknadel2.minRot[2];
		setRotation(self.rotationPartTanknadel2.node, x, y ,z);
	end;





      if isDown and sym == Input.KEY_y then 
		self.wiper1Active = not self.wiper1Active;
	  end; 
      if isDown and sym == Input.KEY_y then 
		self.wiper2Active = not self.wiper2Active;
	  end;
      if isDown and sym == Input.KEY_y then 
		self.wiper3Active = not self.wiper3Active;
	  end; 
      if isDown and sym == Input.KEY_y then 
		self.wiper4Active = not self.wiper4Active;
	  end;
      if isDown and sym == Input.KEY_y then 
		self.wiper5Active = not self.wiper5Active;
	  end; 
      if isDown and sym == Input.KEY_y then 
		self.wiper6Active = not self.wiper6Active;
	  end; 


      if isDown and sym == Input.KEY_KP_enter then 
		self.motor1Active = not self.motor1Active;
	  end;

      if isDown and sym == Input.KEY_KP_enter then 
		self.motor2Active = not self.motor2Active;
	  end; 





     if isDown then
		if sym == Input.KEY_t then
			if self.isTurnedOn == false then
				self.isTurnedOn = true;
			else
				self.isTurnedOn = false;
			end;
		end;		
		
	end;

     if isDown then
		if sym == Input.KEY_t then
			if self.isTurnedOn1 == false then
				self.isTurnedOn1 = true;
			else
				self.isTurnedOn1 = false;
			end;
		end;		
		
	end;

     if isDown then
		if sym == Input.KEY_t then
			if self.isTurnedOn2 == false then
				self.isTurnedOn2 = true;
			else
				self.isTurnedOn2 = false;
			end;
		end;		
		
	end;

     if isDown then
		if sym == Input.KEY_KP_multiply then
			if self.isTurnedOn3 == false then
				self.isTurnedOn3 = true;
			else
				self.isTurnedOn3 = false;
			end;
		end;		
		
	end;


	if sym == Input.KEY_KP_2 then
            self.rotationMaxpoworotnika = not self.rotationMaxpoworotnika;
            self.rotationMaxpoworotnik0 = false;
	
	end;

	if sym == Input.KEY_KP_3 then
            self.rotationMaxpoworotnikk = not self.rotationMaxpoworotnikk;
            self.rotationMaxpoworotnik0 = false;
	
	end;
	
     if sym == Input.KEY_KP_1 then
           self.rotationMaxpoworotnik = not self.rotationMaxpoworotnik;
           self.rotationMaxpoworotnik0 = false;	
	end;	



	
	if self.isEntered then
		if Input.isKeyPressed(Input.KEY_KP_enter) then
			self.rotationMaxPedal3 = true;
		else
			self.rotationMaxPedal3 = false;
		end;
		if Input.isKeyPressed(Input.KEY_w) then
			self.rotationMaxPedal2 = true;
		else
			self.rotationMaxPedal2 = false;
		end;
		if Input.isKeyPressed(Input.KEY_w) then
			self.rotationMaxPedalr = true;
		else
			self.rotationMaxPedalr = false;
		end;
		if Input.isKeyPressed(Input.KEY_w) then
			self.rotationMaxPedal = true;
		else
			self.rotationMaxPedal = false;
		end;
		if Input.isKeyPressed(Input.KEY_s) then
			self.rotationMaxBrake = true;
		else
			self.rotationMaxBrake = false;
		end;
		if self.gang0 then
			self.rotationMaxClutch = true;
		else
			self.rotationMaxClutch = false;
		end;
	end

	if self.isEntered then
		if Input.isKeyPressed(Input.KEY_KP_enter) then
			self.rotationMaxPedal3 = true;
		else
			self.rotationMaxPedal3 = false;
		end;
		if Input.isKeyPressed(Input.KEY_w) then
			self.rotationMaxPedal2 = true;
		else
			self.rotationMaxPedal2 = false;
		end;
		if Input.isKeyPressed(Input.KEY_w) then
			self.rotationMaxPedalr = true;
		else
			self.rotationMaxPedalr = false;
		end;
		if Input.isKeyPressed(Input.KEY_w) then
			self.rotationMaxPedal = true;
		else
			self.rotationMaxPedal = false;
		end;
		if Input.isKeyPressed(Input.KEY_s) then
			self.rotationMaxBrake = true;
		else
			self.rotationMaxBrake = false;
		end;
		if self.gang0 then
			self.rotationMaxClutch = true;
		else
			self.rotationMaxClutch = false;
		end;
	end
	


    if sym == Input.KEY_o then
		self.translationMax = isDown;
	end;
	if sym == Input.KEY_p then
		self.translationMin = isDown;
	end;

    if sym == Input.KEY_o then
		self.translationMax2 = isDown;
	end;
	if sym == Input.KEY_p then
		self.translationMin2 = isDown;
	end;

	if sym == Input.KEY_n then
		self.rotation9Max = isDown;
	end;
	if sym == Input.KEY_m then
		self.rotation9Min = isDown;
	end;
	if sym == Input.KEY_k then
		self.rotation8Max = isDown;
	end;
	if sym == Input.KEY_l then
		self.rotation8Min = isDown;
	end;
	if sym == Input.KEY_h then
		self.rotation7Max = isDown;
	end;
	if sym == Input.KEY_j then
		self.rotation7Min = isDown;
	end;
	if sym == Input.KEY_f then
		self.rotation6Max = isDown;
	end;
	if sym == Input.KEY_g then
		self.rotation6Min = isDown;
	end;



if isDown and sym == Input.KEY_r then
		if self.chuj then
			self.rotationMaxru4ka1 = true;
		else
			self.rotationMaxru4ka1 = true
		end;
	else
		self.rotationMaxru4ka1 = false;
		end;

if isDown and sym == Input.KEY_r then
		if self.chuj then
			self.rotationMaxru4ka2 = true;
		else
			self.rotationMaxru4ka2 = true
		end;
	else
		self.rotationMaxru4ka2 = false;
		end;



      if InputBinding.isPressed(InputBinding.SHIT) then
		self.rotationMaxLeft11 = not self.rotationMaxLeft11;
	end;

end;








function Teleskopladerser:update(dt)

		if self.fanNode ~= nil and self.isMotorStarted then 
			 rotate(self.fanNode, 0, 0, self.motor.lastMotorRpm*4);
		end;


--[[stop]]------------------------------------------------------------
if self.rotationPartbrakerihag ~= nil then
		local x, y, z = getRotation(self.rotationPartbrakerihag.node);
		local rot = {x,y,z};
		local newRot = Utils.getMovedLimitedValues(rot, self.rotationPartbrakerihag.maxRot, self.rotationPartbrakerihag.minRot, 3, self.rotationPartbrakerihag.rotTime, dt, not self.rotationMaxbrakerihag);
		setRotation(self.rotationPartbrakerihag.node, unpack(newRot));

end;

	if self.handbrake then
		self.motor.maxRpm[1] = 0;
        self.motor.maxRpm[2] = 0;
        self.motor.maxRpm[3] = 0;
		
	 end;  
	
	
	if not self.handbrake then
	    self.motor.maxRpm[1] = 1000;
        self.motor.maxRpm[2] = 2500;
        self.motor.maxRpm[3] = 5900;
	end;	
 	







--[[panel]]------------------------------------------------------------
if self.isEntered then
		  if self.kablightsActive then
		   for i=1, self.numkablights do
		   local kablights = self.kablights[i];
		   setVisibility(kablights, self.kablightsActive);
		end;
	else
		for i=1, self.numkablights do
			local kablights = self.kablights[i];
			setVisibility(kablights, self.kablightsActive, false);
			setVisibility(self.kablights.outs, true);
		end;
	end;
	end;
--[[rul]]------------------------------------------------------------
if self.isEntered then
		  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);
			setVisibility(self.frontlights.outs, true);
		end;
	end;
	end;

--[[val]]------------------------------------------------------------
if self.crankshaftNode ~= nil and (self.movingDirection > 0 or self.movingDirection < 0) then
         	rotate(self.crankshaftNode, 0, 0, self.motor.lastMotorRpm*0.001);
    	end;
if self.crankshaft1Node ~= nil and (self.movingDirection > 0 or self.movingDirection < 0) then
         	rotate(self.crankshaft1Node, 0, 0, self.motor.lastMotorRpm*0.001);
    	end;
if self.crankshaft2Node ~= nil and (self.movingDirection > 0 or self.movingDirection < 0) then
         	rotate(self.crankshaft2Node, 0, 0, self.motor.lastMotorRpm*0.001);
    	end;	
if self.crankshaft3Node ~= nil and (self.movingDirection > 0 or self.movingDirection < 0) then
         	rotate(self.crankshaft3Node, 0, 0, self.motor.lastMotorRpm*0.001);
    	end;	
if self.crankshaft4Node ~= nil and (self.movingDirection > 0 or self.movingDirection < 0) then
         	rotate(self.crankshaft4Node, 0, 0, self.motor.lastMotorRpm*0.001);
    	end;
if self.crankshaft5Node ~= nil and (self.movingDirection > 0 or self.movingDirection < 0) then
         	rotate(self.crankshaft5Node, 0, 0, self.motor.lastMotorRpm*0.001);
    	end;
if self.crankshaft6Node ~= nil and (self.movingDirection > 0 or self.movingDirection < 0) then
         	rotate(self.crankshaft6Node, 0, 0, self.motor.lastMotorRpm*0.001);
    	end;
if self.crankshaft7Node ~= nil and (self.movingDirection > 0 or self.movingDirection < 0) then
         	rotate(self.crankshaft7Node, 0, 0, self.motor.lastMotorRpm*0.001);
    	end;
if self.crankshaft8Node ~= nil and (self.movingDirection > 0 or self.movingDirection < 0) then
         	rotate(self.crankshaft8Node, 0, 0, self.motor.lastMotorRpm*0.001);
    	end;
if self.crankshaft9Node ~= nil and (self.movingDirection > 0 or self.movingDirection < 0) then
         	rotate(self.crankshaft9Node, 0, 0, self.motor.lastMotorRpm*0.001);
    	end;
if self.crankshaft10Node ~= nil and (self.movingDirection > 0 or self.movingDirection < 0) then
         	rotate(self.crankshaft10Node, 0, 0, self.motor.lastMotorRpm*0.001);
    	end;
if self.crankshaft11Node ~= nil and (self.movingDirection > 0 or self.movingDirection < 0) then
         	rotate(self.crankshaft11Node, 0, 0, self.motor.lastMotorRpm*0.001);
    	end;
if self.crankshaft12Node ~= nil and (self.movingDirection > 0 or self.movingDirection < 0) then
         	rotate(self.crankshaft12Node, 0, 0, self.motor.lastMotorRpm*0.001);
    	end;








if self.motor.lastMotorRpm > 300 and self.motor.lastMotorRpm < 650 then
self.rotationMaxkorobka = true;
self.rotationMaxkorobka0 = false;
self.rotationMaxkorobkazad = false;
	end;
if self.motor.lastMotorRpm > 650 and self.motor.lastMotorRpm < 700 then
self.rotationMaxkorobka = false;
self.rotationMaxkorobka1 = false;
self.rotationMaxkorobka0 = true;
self.rotationMaxkorobkazad = false;
	end;	
	
if self.motor.lastMotorRpm > 700 and self.motor.lastMotorRpm < 1050 then
self.rotationMaxkorobka1 = true;
self.rotationMaxkorobka0 = false;
self.rotationMaxkorobkazad = false;
	end;

if self.motor.lastMotorRpm > 1050 and self.motor.lastMotorRpm < 1100 then
self.rotationMaxkorobka1 = false;
self.rotationMaxkorobka2 = false;
self.rotationMaxkorobka0 = true;
self.rotationMaxkorobkazad = false;
	end;
	
if self.motor.lastMotorRpm > 1100 and self.motor.lastMotorRpm < 1550 then
self.rotationMaxkorobka2 = true;
self.rotationMaxkorobka0 = false;
self.rotationMaxkorobkazad = false;
	end;
if self.motor.lastMotorRpm > 1550 and self.motor.lastMotorRpm < 1600 then
self.rotationMaxkorobka2 = false;
self.rotationMaxkorobka3 = false;
self.rotationMaxkorobka0 = true;
self.rotationMaxkorobkazad = false;
	end;

	
if self.motor.lastMotorRpm > 1600 and self.motor.lastMotorRpm < 1950 then
self.rotationMaxkorobka3 = true;
self.rotationMaxkorobka0 = false;
self.rotationMaxkorobkazad = false;
	end;	
if self.motor.lastMotorRpm > 1950 and self.motor.lastMotorRpm < 2000 then
self.rotationMaxkorobka3 = false;
self.rotationMaxkorobka4 = false;
self.rotationMaxkorobka0 = true;
self.rotationMaxkorobkazad = false;
	end;	
if self.motor.lastMotorRpm > 2000 then
self.rotationMaxkorobka4 = true;
self.rotationMaxkorobka0 = false;
self.rotationMaxkorobkazad = false;
	end;	
if self.brakeSoundAllow then
self.rotationMaxkorobkazad = true;
self.rotationMaxkorobka0 = false;
self.rotationMaxkorobka = false;
self.rotationMaxkorobka1 = false;
self.rotationMaxkorobka2 = false;
self.rotationMaxkorobka3 = false;
self.rotationMaxkorobka4 = false;
	end;		
	
	
 if self.motor.lastMotorRpm < 300 then
self.rotationMaxkorobka0 = true;
self.rotationMaxkorobka = false;
self.rotationMaxkorobka1 = false;
self.rotationMaxkorobka2 = false;
self.rotationMaxkorobka3 = false;
self.rotationMaxkorobka4 = false;
self.rotationMaxkorobkazad = false;
	end;
	
	
if self.rotationMaxkorobka0 == true then
if self.rotationPartkorobka0 ~= nil then
		   local x, y, z = getRotation(self.rotationPartkorobka0.node);
		   local rot = {x,y,z};
		   local newRot = Utils.getMovedLimitedValues(rot, self.rotationPartkorobka0.maxRot, self.rotationPartkorobka0.minRot, 3, self.rotationPartkorobka0.rotTime, dt, not self.rotationMaxkorobka0);
		   setRotation(self.rotationPartkorobka0.node, unpack(newRot));
       end;
	   end;

if self.rotationMaxkorobka == true then
if self.rotationPartkorobka ~= nil then
		   local x, y, z = getRotation(self.rotationPartkorobka.node);
		   local rot = {x,y,z};
		   local newRot = Utils.getMovedLimitedValues(rot, self.rotationPartkorobka.maxRot, self.rotationPartkorobka.minRot, 3, self.rotationPartkorobka.rotTime, dt, not self.rotationMaxkorobka);
		   setRotation(self.rotationPartkorobka.node, unpack(newRot));
       end;
	   end;
if self.rotationMaxkorobka1 == true then	   
if self.rotationPartkorobka1 ~= nil then
		   local x, y, z = getRotation(self.rotationPartkorobka1.node);
		   local rot = {x,y,z};
		   local newRot = Utils.getMovedLimitedValues(rot, self.rotationPartkorobka1.maxRot, self.rotationPartkorobka1.minRot, 3, self.rotationPartkorobka1.rotTime, dt, not self.rotationMaxkorobka1);
		   setRotation(self.rotationPartkorobka1.node, unpack(newRot));
       end;
end;
if self.rotationMaxkorobka2 == true then
if self.rotationPartkorobka2 ~= nil then
		   local x, y, z = getRotation(self.rotationPartkorobka2.node);
		   local rot = {x,y,z};
		   local newRot = Utils.getMovedLimitedValues(rot, self.rotationPartkorobka2.maxRot, self.rotationPartkorobka2.minRot, 3, self.rotationPartkorobka2.rotTime, dt, not self.rotationMaxkorobka2);
		   setRotation(self.rotationPartkorobka2.node, unpack(newRot));
       end;
end;
 
if self.rotationMaxkorobka3 == true then
if self.rotationPartkorobka3 ~= nil then
		   local x, y, z = getRotation(self.rotationPartkorobka3.node);
		   local rot = {x,y,z};
		   local newRot = Utils.getMovedLimitedValues(rot, self.rotationPartkorobka3.maxRot, self.rotationPartkorobka3.minRot, 3, self.rotationPartkorobka3.rotTime, dt, not self.rotationMaxkorobka3);
		   setRotation(self.rotationPartkorobka3.node, unpack(newRot));
       end;
end;

if self.rotationMaxkorobka4 == true then
if self.rotationPartkorobka4 ~= nil then
		   local x, y, z = getRotation(self.rotationPartkorobka4.node);
		   local rot = {x,y,z};
		   local newRot = Utils.getMovedLimitedValues(rot, self.rotationPartkorobka4.maxRot, self.rotationPartkorobka4.minRot, 3, self.rotationPartkorobka4.rotTime, dt, not self.rotationMaxkorobka4);
		   setRotation(self.rotationPartkorobka4.node, unpack(newRot));
       end;
end;
if self.rotationMaxkorobkazad == true then
if self.rotationPartkorobkazad ~= nil then
		   local x, y, z = getRotation(self.rotationPartkorobkazad.node);
		   local rot = {x,y,z};
		   local newRot = Utils.getMovedLimitedValues(rot, self.rotationPartkorobkazad.maxRot, self.rotationPartkorobkazad.minRot, 3, self.rotationPartkorobkazad.rotTime, dt, not self.rotationMaxkorobkazad);
		   setRotation(self.rotationPartkorobkazad.node, unpack(newRot));
       end;
end;















if self.starrr == true then

if self.isEntered then
		if self.fuelFillLevel < 50 then
			self.tankwarn = self.tankwarn - dt;
			if self.tankwarn <= 0 then
				playSample(self.fuelwarningSoundId,1,1,0);
				self.tankwarn = 30000;
			end;
			self.tanklightActive = true;
		else
			self.tankwarn = 30000;
			self.tanklightActive = false;
		end;
		setVisibility(self.tanklight,self.tanklightActive);
		setVisibility(self.tank2light,self.tanklightActive);
	end;

if self.rotationPartTanknadel ~= nil then
		local x, y, z = getRotation(self.rotationPartTanknadel.node);
		y = ((self.rotationPartTanknadel.maxRot[2] - self.rotationPartTanknadel.minRot[2]) / self.fuelCapacity) * self.fuelFillLevel + self.rotationPartTanknadel.minRot[2];
		setRotation(self.rotationPartTanknadel.node, x, y ,z);
	end;
	
	if self.rotationPartTanknadel2 ~= nil then
		local x, y, z = getRotation(self.rotationPartTanknadel2.node);
		y = ((self.rotationPartTanknadel2.maxRot[2] - self.rotationPartTanknadel2.minRot[2]) / self.fuelCapacity) * self.fuelFillLevel + self.rotationPartTanknadel2.minRot[2];
		setRotation(self.rotationPartTanknadel2.node, x, y ,z);
	end;

if self.isEntered then
		if self.fuelFillLevel < 50 then
			self.tankwarn = self.tankwarn - dt;
			if self.tankwarn <= 0 then
				playSample(self.fuelwarningSoundId,1,1,0);
				self.tankwarn = 30000;
			end;
			self.tanklightActive = true;
		else
			self.tankwarn = 30000;
			self.tanklightActive = false;
		end;
		setVisibility(self.tanklight,self.tanklightActive);
		setVisibility(self.tank2light,self.tanklightActive);
	end;
end;






local maxDrehzahl = 2900;
	if self.rotationPartDrehzahl1 ~= nil then
		local x, y, z = getRotation(self.rotationPartDrehzahl1.node);
		y = ((self.rotationPartDrehzahl1.maxRot[2] - self.rotationPartDrehzahl1.minRot[2]) / maxDrehzahl) * self.motor.lastMotorRpm + self.rotationPartDrehzahl1.minRot[2];
		setRotation(self.rotationPartDrehzahl1.node, x, y ,z);
	end;
	if self.rotationPartDrehzahl2 ~= nil then
		local x, y, z = getRotation(self.rotationPartDrehzahl2.node);
		y = ((self.rotationPartDrehzahl2.maxRot[2] - self.rotationPartDrehzahl2.minRot[2]) / maxDrehzahl) * self.motor.lastMotorRpm + self.rotationPartDrehzahl2.minRot[2];
		setRotation(self.rotationPartDrehzahl2.node, x, y ,z);
	end;




local maxKmh = 50;
	if self.rotationPartKmh1 ~= nil then
		local x, y, z = getRotation(self.rotationPartKmh1.node);
		y = ((self.rotationPartKmh1.maxRot[2] - self.rotationPartKmh1.minRot[2]) / maxKmh) * self.lastSpeed*3600 + self.rotationPartKmh1.minRot[2];
		setRotation(self.rotationPartKmh1.node, x, y ,z);
	end;
	if self.rotationPartKmh2 ~= nil then
		local x, y, z = getRotation(self.rotationPartKmh2.node);
		y = ((self.rotationPartKmh2.maxRot[2] - self.rotationPartKmh2.minRot[2]) / maxKmh) * self.lastSpeed*3600 + self.rotationPartKmh2.minRot[2];
		setRotation(self.rotationPartKmh2.node, x, y ,z);
	end;
















	               if self.wiper1Active 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.wiper1Max then
				   if self.delayWischer1 < 0 then
					self.delayWischer2 = 1000;
					self.wiper1Max = true;
					self.wiper2Max = true;
					self.wiper3Max = true;
					self.wiper4Max = true;
					self.wiper5Max = true;
					self.wiper6Max = true;
				end;
			end;
			         if self.wiper1Max then
				   if self.delayWischer2 < 0 then
					self.delayWischer1 = 1000;
					self.wiper1Max = false;
					self.wiper2Max = false;
					self.wiper3Max = false;
					self.wiper4Max = false;
					self.wiper5Max = false;
					self.wiper6Max = false;
				end;
			end;
		else
			self.wiper1Max = false;
			self.wiper2Max = false;
			self.wiper3Max = false;
			self.wiper4Max = false;
			self.wiper5Max = false;
			self.wiper6Max = false;
		end;

      if self.wiper1 ~= nil then
        	local x, y, z = getRotation(self.wiper1.node);
        	local rot = {x,y,z};
        	local newRot = Utils.getMovedLimitedValues(rot, self.wiper1.maxRot, self.wiper1.minRot, 3, self.wiper1.rotTime, dt, not self.wiper1Max);
        	setRotation(self.wiper1.node, unpack(newRot));
    	end;
		
	if self.wiper2 ~= nil then
        	local x, y, z = getRotation(self.wiper2.node);
        	local rot = {x,y,z};
        	local newRot = Utils.getMovedLimitedValues(rot, self.wiper2.maxRot, self.wiper2.minRot, 3, self.wiper2.rotTime, dt, not self.wiper2Max);
        	setRotation(self.wiper2.node, unpack(newRot));
    	end;
      if self.wiper3 ~= nil then
        	local x, y, z = getRotation(self.wiper3.node);
        	local rot = {x,y,z};
        	local newRot = Utils.getMovedLimitedValues(rot, self.wiper3.maxRot, self.wiper3.minRot, 3, self.wiper3.rotTime, dt, not self.wiper3Max);
        	setRotation(self.wiper3.node, unpack(newRot));
    	end;
		
	if self.wiper4 ~= nil then
        	local x, y, z = getRotation(self.wiper4.node);
        	local rot = {x,y,z};
        	local newRot = Utils.getMovedLimitedValues(rot, self.wiper4.maxRot, self.wiper4.minRot, 3, self.wiper4.rotTime, dt, not self.wiper4Max);
        	setRotation(self.wiper4.node, unpack(newRot));
    	end;
      if self.wiper5 ~= nil then
        	local x, y, z = getRotation(self.wiper5.node);
        	local rot = {x,y,z};
        	local newRot = Utils.getMovedLimitedValues(rot, self.wiper5.maxRot, self.wiper5.minRot, 3, self.wiper5.rotTime, dt, not self.wiper5Max);
        	setRotation(self.wiper5.node, unpack(newRot));
    	end;
		
	if self.wiper6 ~= nil then
        	local x, y, z = getRotation(self.wiper6.node);
        	local rot = {x,y,z};
        	local newRot = Utils.getMovedLimitedValues(rot, self.wiper6.maxRot, self.wiper6.minRot, 3, self.wiper6.rotTime, dt, not self.wiper6Max);
        	setRotation(self.wiper6.node, unpack(newRot));
    	end;







        if self.isTurnedOn then
        if self.wentelatorNode1 ~= nil then
				rotate(self.wentelatorNode1, self.wentelatorRotationScale * 5 * 1, 0, 0);
			end;			

        end;

        if self.isTurnedOn1 then
        if self.wentelator1Node1 ~= nil then
				rotate(self.wentelator1Node1, self.wentelator1RotationScale * 5 * 1, 0, 0);
			end;			

        end;

        if self.isTurnedOn2 then
        if self.wentelator2Node1 ~= nil then
				rotate(self.wentelator2Node1, self.wentelator2RotationScale * 5 * 1, 0, 0);
			end;			

        end;

        if self.isTurnedOn3 then
        if self.wentelator3Node1 ~= nil then
				rotate(self.wentelator3Node1, self.wentelator3RotationScale * 5 * 1, 0, 0);
			end;			

        end;



	               if self.motor1Active then
			   if self.delayKurs1 >= 0 then
				self.delayKurs1 = self.delayKurs1 -dt;
			end;
			   if self.delayKurs2 >= 0 then
				self.delayKurs2 = self.delayKurs2 -dt;
			end;
			     if not self.motor1Max then
				   if self.delayKurs1 < 0 then
					self.delayKurs2 = 70;
					self.motor1Max = true;
					self.motor2Max = true;
				end;
			end;
			         if self.motor1Max then
				   if self.delayKurs2 < 0 then
					self.delayKurs1 = 70;
					self.motor1Max = false;
					self.motor2Max = false;
				end;
			end;
		else
			self.motor1Max = false;
			self.motor2Max = false;
		end;


      if self.motor1 ~= nil then
        	local x, y, z = getRotation(self.motor1.node);
        	local rot = {x,y,z};
        	local newRot = Utils.getMovedLimitedValues(rot, self.motor1.maxRot, self.motor1.minRot, 3, self.motor1.rotTime, dt, not self.motor1Max);
        	setRotation(self.motor1.node, unpack(newRot));
    	end;

      if self.motor2 ~= nil then
        	local x, y, z = getRotation(self.motor2.node);
        	local rot = {x,y,z};
        	local newRot = Utils.getMovedLimitedValues(rot, self.motor2.maxRot, self.motor2.minRot, 3, self.motor2.rotTime, dt, not self.motor2Max);
        	setRotation(self.motor2.node, unpack(newRot));
    	end;








      if self.rotationMaxpoworotnikk == false and self.rotationMaxpoworotnik == false and self.rotationMaxpoworotnika == false then
      self.rotationMaxpoworotnik0 = true
      end;	


	if self.rotationMaxpoworotnika == true then
               if self.rotationPartpoworotnika ~= nil then
		   local x, y, z = getRotation(self.rotationPartpoworotnika.node);
		   local rot = {x,y,z};
		   local newRot = Utils.getMovedLimitedValues(rot, self.rotationPartpoworotnika.maxRot, self.rotationPartpoworotnika.minRot, 3, self.rotationPartpoworotnika.rotTime, dt, not self.rotationMaxpoworotnika);
		   setRotation(self.rotationPartpoworotnika.node, unpack(newRot));
       end;
         end;		
	if self.rotationMaxpoworotnikk == true then
               if self.rotationPartpoworotnikk ~= nil then
		   local x, y, z = getRotation(self.rotationPartpoworotnikk.node);
		   local rot = {x,y,z};
		   local newRot = Utils.getMovedLimitedValues(rot, self.rotationPartpoworotnikk.maxRot, self.rotationPartpoworotnikk.minRot, 3, self.rotationPartpoworotnikk.rotTime, dt, not self.rotationMaxpoworotnikk);
		   setRotation(self.rotationPartpoworotnikk.node, unpack(newRot));
       end;
	   end;
               if self.rotationMaxpoworotnik == true then
               if self.rotationPartpoworotnik ~= nil then
		   local x, y, z = getRotation(self.rotationPartpoworotnik.node);
		   local rot = {x,y,z};
		   local newRot = Utils.getMovedLimitedValues(rot, self.rotationPartpoworotnik.maxRot, self.rotationPartpoworotnik.minRot, 3, self.rotationPartpoworotnik.rotTime, dt, not self.rotationMaxpoworotnik);
		   setRotation(self.rotationPartpoworotnik.node, unpack(newRot));
       end;
	   end;

               if self.rotationMaxpoworotnik0 == true then
               if self.rotationPartpoworotnik0 ~= nil then
		   local x, y, z = getRotation(self.rotationPartpoworotnik0.node);
		   local rot = {x,y,z};
		   local newRot = Utils.getMovedLimitedValues(rot, self.rotationPartpoworotnik0.maxRot, self.rotationPartpoworotnik0.minRot, 3, self.rotationPartpoworotnik0.rotTime, dt, not self.rotationMaxpoworotnik0);
		   setRotation(self.rotationPartpoworotnik0.node, unpack(newRot));
       end;
	   end;





	if self.rotationPartPedal3 ~= nil then
		local x, y, z = getRotation(self.rotationPartPedal3.node);
		local rot = {x,y,z};
		local newRot = Utils.getMovedLimitedValues(rot, self.rotationPartPedal3.maxRot, self.rotationPartPedal3.minRot, 3, self.rotationPartPedal3.rotTime, dt, not self.rotationMaxPedal3);
		setRotation(self.rotationPartPedal3.node, unpack(newRot));
	end;

	if self.rotationPartPedal2 ~= nil then
		local x, y, z = getRotation(self.rotationPartPedal2.node);
		local rot = {x,y,z};
		local newRot = Utils.getMovedLimitedValues(rot, self.rotationPartPedal2.maxRot, self.rotationPartPedal2.minRot, 3, self.rotationPartPedal2.rotTime, dt, not self.rotationMaxPedal2);
		setRotation(self.rotationPartPedal2.node, unpack(newRot));
	end;

	if self.rotationPartPedalr ~= nil then
		local x, y, z = getRotation(self.rotationPartPedalr.node);
		local rot = {x,y,z};
		local newRot = Utils.getMovedLimitedValues(rot, self.rotationPartPedalr.maxRot, self.rotationPartPedalr.minRot, 3, self.rotationPartPedalr.rotTime, dt, not self.rotationMaxPedalr);
		setRotation(self.rotationPartPedalr.node, unpack(newRot));
	end;

	if self.rotationPartPedal ~= nil then
		local x, y, z = getRotation(self.rotationPartPedal.node);
		local rot = {x,y,z};
		local newRot = Utils.getMovedLimitedValues(rot, self.rotationPartPedal.maxRot, self.rotationPartPedal.minRot, 3, self.rotationPartPedal.rotTime, dt, not self.rotationMaxPedal);
		setRotation(self.rotationPartPedal.node, unpack(newRot));
	end;

     if self.rotationPartBrake ~= nil then
		local x, y, z = getRotation(self.rotationPartBrake.node);
		local rot = {x,y,z};
		local newRot = Utils.getMovedLimitedValues(rot, self.rotationPartBrake.maxRot, self.rotationPartBrake.minRot, 3, self.rotationPartBrake.rotTime, dt, not self.rotationMaxBrake);
		setRotation(self.rotationPartBrake.node, unpack(newRot));
	end;

	local doTranslate = self.translationMax or self.translationMin 
	if self.translationPart ~= nil and doTranslate then 
		local x, y, z = getTranslation(self.translationPart.node); 
		local trans = {x,y,z}; 
		local newTrans = Utils.getMovedLimitedValues(trans, self.translationPart.maxTrans, self.translationPart.minTrans, 3, self.translationPart.transTime, dt, not self.translationMax); 
		setTranslation(self.translationPart.node, unpack(newTrans)); 
	end; 
	local doTranslate = self.translationMax2 or self.translationMin2 
	if self.translationPart2 ~= nil and doTranslate then 
		local x, y, z = getTranslation(self.translationPart2.node); 
		local trans = {x,y,z}; 
		local newTrans = Utils.getMovedLimitedValues(trans, self.translationPart2.maxTrans, self.translationPart2.minTrans, 3, self.translationPart2.transTime, dt, not self.translationMax2); 
		setTranslation(self.translationPart2.node, unpack(newTrans)); 
	end;

	local doRotate = self.rotation6Max or self.rotation6Min 
	if self.rotation6 ~= nil and doRotate then
        local x, y, z = getRotation(self.rotation6.node);
        local rot = {x,y,z};
        local newRot = Utils.getMovedLimitedValues(rot, self.rotation6.maxRot, self.rotation6.minRot, 3, self.rotation6.rotTime, dt, not self.rotation6Max);
        setRotation(self.rotation6.node, unpack(newRot));
    end;

	local doRotate = self.rotation7Max or self.rotation7Min 
	if self.rotation7 ~= nil and doRotate then
        local x, y, z = getRotation(self.rotation7.node);
        local rot = {x,y,z};
        local newRot = Utils.getMovedLimitedValues(rot, self.rotation7.maxRot, self.rotation7.minRot, 3, self.rotation7.rotTime, dt, not self.rotation7Max);
        setRotation(self.rotation7.node, unpack(newRot));
    end;
	
	local doRotate = self.rotation8Max or self.rotation8Min 
	if self.rotation8 ~= nil and doRotate then
        local x, y, z = getRotation(self.rotation8.node);
        local rot = {x,y,z};
        local newRot = Utils.getMovedLimitedValues(rot, self.rotation8.maxRot, self.rotation8.minRot, 3, self.rotation8.rotTime, dt, not self.rotation8Max);
        setRotation(self.rotation8.node, unpack(newRot));
    end;
	
	local doRotate = self.rotation9Max or self.rotation9Min 
	if self.rotation9 ~= nil and doRotate then
        local x, y, z = getRotation(self.rotation9.node);
        local rot = {x,y,z};
        local newRot = Utils.getMovedLimitedValues(rot, self.rotation9.maxRot, self.rotation9.minRot, 3, self.rotation9.rotTime, dt, not self.rotation9Max);
        setRotation(self.rotation9.node, unpack(newRot));
    end;





if self.rotationPartru4ka1 ~= nil then
		local x, y, z = getRotation(self.rotationPartru4ka1.node);
		local rot = {x,y,z};
		local newRot = Utils.getMovedLimitedValues(rot, self.rotationPartru4ka1.maxRot, self.rotationPartru4ka1.minRot, 3, self.rotationPartru4ka1.rotTime, dt, not self.rotationMaxru4ka1);
		setRotation(self.rotationPartru4ka1.node, unpack(newRot));

end;

if self.rotationPartru4ka2 ~= nil then
		local x, y, z = getRotation(self.rotationPartru4ka2.node);
		local rot = {x,y,z};
		local newRot = Utils.getMovedLimitedValues(rot, self.rotationPartru4ka2.maxRot, self.rotationPartru4ka2.minRot, 3, self.rotationPartru4ka2.rotTime, dt, not self.rotationMaxru4ka2);
		setRotation(self.rotationPartru4ka2.node, unpack(newRot));

end;




	if self.rotationPartLeft11 ~= nil then
		local x, y, z = getRotation(self.rotationPartLeft11.node);
		local rot = {x,y,z};
		local newRot = Utils.getMovedLimitedValues(rot, self.rotationPartLeft11.maxRot, self.rotationPartLeft11.minRot, 3, self.rotationPartLeft11.rotTime, dt, not self.rotationMaxLeft11);
		setRotation(self.rotationPartLeft11.node, unpack(newRot));
	end;

end;











function Teleskopladerser:draw()


--[[info]]------------------------------------------------------------
 if self.isEntered then
		if not self.helpPanel then
			renderText(0.86, 0.18, 0.025, "Taste 0: Info");
		else
			renderText(0.86, 0.18, 0.025, "Taste 0: Info");
		end;
		if self.helpPanel then
			renderText(0.84, 0.84, 0.025, "* Info Belarus 892 *");
			renderText(0.8, 0.82, 0.02, "num 1: kair.posukis ");		
			renderText(0.8, 0.80, 0.02, "num 2: avarinis ");
			renderText(0.8, 0.78, 0.02, "num 3: des.posukis ");
			renderText(0.8, 0.76, 0.02, "num Enter : uzvedimas ");
                  renderText(0.8, 0.74, 0.02, "num 4: kair. durys ");
			renderText(0.8, 0.72, 0.02, "num 6: des. durys ");
			renderText(0.8, 0.70, 0.02, "num 7: kair. langas ");
                  renderText(0.8, 0.68, 0.02, "num 9: des. langas ");
                  renderText(0.8, 0.66, 0.02, "Peles kairys mygtukas: hidraulika ");
                  renderText(0.8, 0.64, 0.02, "num 8: gal. langas ");
                  renderText(0.8, 0.62, 0.02, "Home : poezdas ");
                  renderText(0.8, 0.60, 0.02, "U : 4x4 ");
                  renderText(0.8, 0.58, 0.02, "F : sviesos ");
                  renderText(0.8, 0.56, 0.02, "Space : rankinis ");
                  renderText(0.8, 0.54, 0.02, "7 : salono sviesa ");
                  renderText(0.8, 0.52, 0.02, "6: darbo sviesos ");
                  renderText(0.8, 0.50, 0.02, "num 5: vairo modas ");
                  renderText(0.8, 0.48, 0.02, "5: lempos ant stogo  ");
                  renderText(0.8, 0.46, 0.02, "8: slaunys ");
                  renderText(0.8, 0.44, 0.02, "9: pricepas ");
                  renderText(0.84, 0.41, 0.025, " Justinas ");
		end;
       end;

end;



function Teleskopladerser:connectCollisions(varName)
	local Collision = self.collisionArm[varName];
	local constr = JointConstructor:new();
	constr:setActors(self.rootNode, Collision.collision);
	constr:setJointTransforms(Collision.armAttacher, Collision.collisionAttacher);
	for i=1, 3 do
		constr:setRotationLimit(i-1, 0, 0, 0);
		constr:setTranslationLimit(i-1, true, 0, 0);
	end;
	Collision.index = constr:finalize();
end;










