pinzaMordente = {};
function pinzaMordente.prerequisitesPresent(specializations) return true; end;
function pinzaMordente:load(xmlFile) self.objectInRangeM = pinzaMordente.objectInRangeM;
	self.tubiIdraulici = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.tubiIdraulici#index")); 
	self.tubiIdrauliciA = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.tubiIdraulici#indexA"));	
	self.tuboSupporto = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.tuboSupporto#index")); 
	self.currentBalle = -1; self.sceltaPunteD = 3; self.currentPunte = 1; self.resetBracci = false;
	self.setcurrentBracci = SpecializationUtil.callSpecializationsFunction("setcurrentBracci"); self.currentBracci = 0;
	self.setcurrentChiave = SpecializationUtil.callSpecializationsFunction("setcurrentChiave"); self.currentChiave = -1; 
	self.setcurrentdadoDxD = SpecializationUtil.callSpecializationsFunction("setcurrentdadoDxD"); self.currentdadoDxD = 0;
	self.setcurrentdadoDxS = SpecializationUtil.callSpecializationsFunction("setcurrentdadoDxS"); self.currentdadoDxS = 0;
	self.setcurrentdadoSxD = SpecializationUtil.callSpecializationsFunction("setcurrentdadoSxD"); self.currentdadoSxD = 0;
	self.setcurrentdadoSxS = SpecializationUtil.callSpecializationsFunction("setcurrentdadoSxS"); self.currentdadoSxS = 0; 
	self.setcurrentPosizione = SpecializationUtil.callSpecializationsFunction("setcurrentPosizione"); self.currentPosizione = 1;
	self.setcurrentState = SpecializationUtil.callSpecializationsFunction("setcurrentState"); self.currentState = 0;
	self.extraWeightsDefaultMass = getMass(self.components[1].node); end;
function pinzaMordente:delete() end;
function pinzaMordente:readStream(streamId, connection) self:setcurrentBracci(streamReadInt8(streamId), true); self:setcurrentState(streamReadInt8(streamId), true); self:setcurrentPosizione(streamReadInt8(streamId), true); self:setcurrentChiave(streamReadInt8(streamId), true); self:setcurrentdadoDxD(streamReadInt8(streamId), true); self:setcurrentdadoDxS(streamReadInt8(streamId), true); self:setcurrentdadoSxD(streamReadInt8(streamId), true); self:setcurrentdadoSxS(streamReadInt8(streamId), true); end;
function pinzaMordente:writeStream(streamId, connection) streamWriteInt8(streamId, self.currentBracci); streamWriteInt8(streamId, self.currentState); streamWriteInt8(streamId, self.currentPosizione); streamWriteInt8(streamId, self.currentChiave); streamWriteInt8(streamId, self.currentdadoDxD); streamWriteInt8(streamId, self.currentdadoDxS); streamWriteInt8(streamId, self.currentdadoSxD); streamWriteInt8(streamId, self.currentdadoSxS); end;
function pinzaMordente:setcurrentBracci(int, noEventSend) self.currentBracci = int; setcurrentBracciEvent.sendEvent(self, int, noEventSend); end;
function pinzaMordente:setcurrentPosizione(int, noEventSend) self.currentPosizione = int; setcurrentPosizioneEvent.sendEvent(self, int, noEventSend); end;
function pinzaMordente:setcurrentState(int, noEventSend) self.currentState = int; setcurrentStateEvent.sendEvent(self, int, noEventSend); end;
function pinzaMordente:setcurrentChiave(int, noEventSend) self.currentChiave = int; setcurrentChiaveEvent.sendEvent(self, int, noEventSend); end;
function pinzaMordente:setcurrentdadoDxD(int, noEventSend) self.currentdadoDxD = int; setcurrentdadoDxDEvent.sendEvent(self, int, noEventSend); end;
function pinzaMordente:setcurrentdadoDxS(int, noEventSend) self.currentdadoDxS = int; setcurrentdadoDxSEvent.sendEvent(self, int, noEventSend); end;
function pinzaMordente:setcurrentdadoSxD(int, noEventSend) self.currentdadoSxD = int; setcurrentdadoSxDEvent.sendEvent(self, int, noEventSend); end;
function pinzaMordente:setcurrentdadoSxS(int, noEventSend) self.currentdadoSxS = int; setcurrentdadoSxSEvent.sendEvent(self, int, noEventSend); end;
function pinzaMordente:loadFromAttributesAndNodes(xmlFile, key, resetVehicles) local currentBracci = getXMLInt(xmlFile, key .. "#currentBracci"); if currentBracci ~= nil then self:setcurrentBracci(currentBracci); if currentBracci == 1 then self:playAnimation("bracciSuperiori", -1); local xr, yr, zr = getRotation(self.components[3].node); setRotation(self.components[2].node, xr, yr, zr); local xt, yt, zt = getTranslation(self.components[3].node); setTranslation(self.components[2].node, xt, yt, zt); self:setcurrentPiloni(1); elseif currentBracci == 3 then self:playAnimation("bracciSuperiori", 1); self:setcurrentPiloni(3); end; end; return BaseMission.VEHICLE_LOAD_OK; end;
function pinzaMordente:getSaveAttributesAndNodes(nodeIdent) local attributes = 'currentBracci="' .. self.currentBracci .. '"'; return attributes; end;
function pinzaMordente:mouseEvent(posX, posY, isDown, isUp, button) end;
function pinzaMordente:keyEvent(unicode, sym, modifier, isDown) end;
function pinzaMordente:objectInRangeM(refNode) local nearestDistance = 2; local nearestBale = nil; local px, py, pz = getWorldTranslation(refNode.node);
    for index, item in pairs(g_currentMission.itemsToSave) do if item.item:isa(Bale) then local vx, vy, vz = getWorldTranslation(item.item.nodeId); local distance = Utils.vector3Length(px-vx, py-vy, pz-vz);
		if distance < nearestDistance then
			if getUserAttribute(item.item.nodeId, "isRoundbale") and item.item.baleDiameter ~= nil then nearestDistance = distance; nearestBale = item.item; end; end; end; end; return nearestBale; end;
function pinzaMordente:update(dt) if self:getIsActiveForInput() or self.currentAttacco == 1 then
	if self.currentdadoDxD ~= 0 or self.currentdadoDxS ~= 0 or self.currentdadoSxD ~= 0 or self.currentdadoSxS ~= 0 then g_currentMission:addWarning(string.format(g_i18n:getText("mordenteWarning")), 0, 0); return false; end; 
	if not self.resetBracci and (self.currentBracci == 1 or self.currentBracci == 3) then g_currentMission:showBlinkingWarning(g_i18n:getText("CSZReset"), 1000); self.currentBracci = self.currentBracci - 1; end; 
	if self.currentChiave > 0 then if self.currentChiave == 1 then self:setcurrentChiave(0); end; if self.currentChiave == 3 then self:setcurrentChiave(-2); end; if self.currentChiave == 5 then self:setcurrentChiave(-4); end; if self.currentChiave == 7 then self:setcurrentChiave(-6); end; end;
	if InputBinding.hasEvent(InputBinding.OpenClose) and self.setBaleLoader == 0 and not self.balesAttached then 
		if self.currentSupport then self:playAnimation("telaioMobile", -1); self:setcurrentSupport(false); self:setcurrentBalle(-1);
		else self:playAnimation("telaioMobile", 1); self:setcurrentSupport(true); self:setcurrentBalle(-1); end; end;
	if self.currentBalle == -1 and self.currentSupport then local baleSize = 0; local bale = self:objectInRangeM(self.lockPrima); if bale ~= nil then
		if bale.baleDiameter > 0.99 then baleSize = 0.000; end; if bale.baleDiameter > 1.31 then baleSize = 0.078; end; if bale.baleDiameter > 1.41 then baleSize = 0.141; end; if bale.baleDiameter > 1.51 then baleSize = 0.168; end; if bale.baleDiameter > 1.61 then baleSize = 0.348; end; self:setcurrentBaleSize(baleSize); end;
		if self.balesAttached and self.currentPosizione == 0 then self:setcurrentState(1); self:setcurrentPosizione(2); end;
		if not self.balesAttached then if self.currentState == 1 and self.currentPosizione == 2 
			then if self.currentBaleSize == 0.000 then self:playAnimation("bracciRotazione130", 0.5); end; if self.currentBaleSize == 0.078 then self:playAnimation("bracciRotazione140", 0.5); end; if self.currentBaleSize == 0.141 then self:playAnimation("bracciRotazione150", 0.5); end; if self.currentBaleSize == 0.168 then self:playAnimation("bracciRotazione160", 0.5); end; if self.currentBaleSize == 0.348 then self:playAnimation("bracciRotazione180", 0.5); end; self:setcurrentState(1); self:setcurrentPosizione(1); end; 
			if self.currentState == 1 and self.currentPosizione == 1 then self:setcurrentState(0); end;
			if InputBinding.hasEvent(InputBinding.IMPLEMENT_EXTRA) and bale ~= nil then 
				if self.currentPosizione == 0 then if self.currentBaleSize == 0.000 then self:playAnimation("bracciRotazione130", 0.5); end; if self.currentBaleSize == 0.078 then self:playAnimation("bracciRotazione140", 0.5); end; if self.currentBaleSize == 0.141 then self:playAnimation("bracciRotazione150", 0.5); end;	if self.currentBaleSize == 0.168 then self:playAnimation("bracciRotazione160", 0.5); end; if self.currentBaleSize == 0.348 then self:playAnimation("bracciRotazione180", 0.5); end; self:setcurrentState(0); self:setcurrentPosizione(1); 
				elseif self.currentPosizione == 1 then if self.currentBaleSize == 0.000 then self:playAnimation("bracciRotazione130", -1); end; if self.currentBaleSize == 0.078 then self:playAnimation("bracciRotazione140", -1); end; if self.currentBaleSize == 0.141 then self:playAnimation("bracciRotazione150", -1); end; if self.currentBaleSize == 0.168 then self:playAnimation("bracciRotazione160", -1); end; if self.currentBaleSize == 0.348 then self:playAnimation("bracciRotazione180", -1); end; self:setcurrentState(1); self:setcurrentPosizione(0.99); end; end; 
			if self.currentPosizione < 1 and self.currentPosizione > 0 then self.currentPosizione = self.currentPosizione - dt/1500; end; 
			if self.currentPosizione < 0 then self:setcurrentPosizione(0); self:setWorkState(not self.attachBales); end; end; end; end;
 	if self.currentBalle == 3 and self.currentSupport then local baleSize = 0; local bale = self:objectInRangeM(self.lockPrima); if bale ~= nil and self.lockPrima.baleId == nil then
		if bale.baleDiameter > 0.99 then baleSize = 0.000; end; if bale.baleDiameter > 1.31 then baleSize = 0.078; end; if bale.baleDiameter > 1.41 then baleSize = 0.141; end; if bale.baleDiameter > 1.51 then baleSize = 0.168; end; if bale.baleDiameter > 1.61 then baleSize = 0.348; end; self:setcurrentBaleSize(baleSize); end;
		if self.fillLevel > 0 and self.currentPosizione == 1 then if self.currentBaleSize == 0.000 then self:playAnimation("bracciRotazione130", -1); end; if self.currentBaleSize == 0.078 then self:playAnimation("bracciRotazione140", -1); end; if self.currentBaleSize == 0.141 then self:playAnimation("bracciRotazione150", -1); end; if self.currentBaleSize == 0.168 then self:playAnimation("bracciRotazione160", -1); end; if self.currentBaleSize == 0.348 then self:playAnimation("bracciRotazione180", -1); end; self.currentPosizione = 0.99; end; 
		if self.fillLevel == 0 and self.currentPosizione < 1 then if self.currentBaleSize == 0.000 then self:playAnimation("bracciRotazione130", 0.5); end; if self.currentBaleSize == 0.078 then self:playAnimation("bracciRotazione140", 0.5); end; if self.currentBaleSize == 0.141 then self:playAnimation("bracciRotazione150", 0.5); end; if self.currentBaleSize == 0.168 then self:playAnimation("bracciRotazione160", 0.5); end; if self.currentBaleSize == 0.348 then self:playAnimation("bracciRotazione180", 0.5); end; self.currentPosizione = 1; if self.currentBracci == 3 then self:setcurrentPiloni(3); end; end; 
		if self.currentPosizione < 1 and self.currentPosizione > 0 then self.currentPosizione = self.currentPosizione - dt/750; end; if self.currentPosizione < 0 then self.currentPosizione = 0; end;
		if self.currentPosizione == 0 then if self.fillLevel < 2 then self:setcurrentPiloni(1); self.fillLevel = 1; elseif self.currentBracci == 3 then self:setcurrentPiloni(3); end; end; end;	
	if g_currentMission.player ~= nil and g_currentMission.player.isEntered then local px, py, pz = getWorldTranslation(g_currentMission.player.rootNode); local tx, ty, tz = getWorldTranslation(self.components[1].node);
	if Utils.vector3Length(px-tx, py-ty, pz-tz) < 3 and not self.currentSupport then 
		if InputBinding.hasEvent(InputBinding.attachCSZ) and self.currentdadoDxD == 7 and self.currentdadoDxS == 7 and self.currentdadoSxD == 7 and self.currentdadoSxS == 7 then
			if self.currentBracci == 1 and not self:getIsAnimationPlaying("bracciSuperiori") then local px, py, pz = getWorldTranslation(self.components[1].node); local tx, ty, tz = getWorldTranslation(self.components[2].node); if Utils.vector3Length(px-tx, py-ty, pz-tz) < 3 then self:setcurrentBracci(2); end; elseif self.currentBracci == 3 and not self:getIsAnimationPlaying("bracciSuperiori") and self.fillLevel < 2 then self:setcurrentBracci(0); end; end;
		if self.currentdadoDxD == 7 and self.currentdadoDxS == 7 and self.currentdadoSxD == 7 and self.currentdadoSxS == 7 then	if self.currentBracci == 1 then local px, py, pz = getWorldTranslation(self.components[1].node); local tx, ty, tz = getWorldTranslation(self.components[2].node); 
		if Utils.vector3Length(px-tx, py-ty, pz-tz) < 3 then g_currentMission:addHelpButtonText(g_i18n:getText("bracciAttacca"), InputBinding.attachCSZ); end; elseif self.currentBracci == 3 and self.fillLevel < 2 then g_currentMission:addHelpButtonText(g_i18n:getText("bracciStacca"), InputBinding.attachCSZ); end; end;
		if self.currentdadoSxS == 0 then if self.currentdadoSxD == 0 then g_currentMission:addExtraPrintText(g_i18n:getText("braccioSx")..string.format(" [ C C C ] ")..g_i18n:getText("dadoSx")..string.format(" [ C C C ] ")..g_i18n:getText("dadoDx")); end;
		if (self.currentdadoSxD == 2 or self.currentdadoSxD == 1) then g_currentMission:addExtraPrintText(g_i18n:getText("braccioSx")..string.format(" [ C C C ] ")..g_i18n:getText("dadoSx")..string.format(" [ C C O ] ")..g_i18n:getText("dadoDx")); end;
		if (self.currentdadoSxD == 3 or self.currentdadoSxD == 4) then g_currentMission:addExtraPrintText(g_i18n:getText("braccioSx")..string.format(" [ C C C ] ")..g_i18n:getText("dadoSx")..string.format(" [ C O O ] ")..g_i18n:getText("dadoDx")); end;
		if (self.currentdadoSxD == 5 or self.currentdadoSxD == 6) then g_currentMission:addExtraPrintText(g_i18n:getText("braccioSx")..string.format(" [ C C C ] ")..g_i18n:getText("dadoSx")..string.format(" [ O O O ] ")..g_i18n:getText("dadoDx")); end;
		if self.currentdadoSxD == 7 then g_currentMission:addExtraPrintText(g_i18n:getText("braccioSx")..string.format(" [ C C C ] ")..g_i18n:getText("dadoSx")..string.format(" [  O K  ] ")..g_i18n:getText("dadoDx")); end; end;
		if (self.currentdadoSxS == 2 or self.currentdadoSxS == 1) then if self.currentdadoSxD == 0 then g_currentMission:addExtraPrintText(g_i18n:getText("braccioSx")..string.format(" [ C C O ] ")..g_i18n:getText("dadoSx")..string.format(" [ C C C ] ")..g_i18n:getText("dadoDx")); end;
		if (self.currentdadoSxD == 2 or self.currentdadoSxD == 1) then g_currentMission:addExtraPrintText(g_i18n:getText("braccioSx")..string.format(" [ C C O ] ")..g_i18n:getText("dadoSx")..string.format(" [ C C O ] ")..g_i18n:getText("dadoDx")); end;
		if (self.currentdadoSxD == 3 or self.currentdadoSxD == 4) then g_currentMission:addExtraPrintText(g_i18n:getText("braccioSx")..string.format(" [ C C O ] ")..g_i18n:getText("dadoSx")..string.format(" [ C O O ] ")..g_i18n:getText("dadoDx")); end;
		if (self.currentdadoSxD == 5 or self.currentdadoSxD == 6) then g_currentMission:addExtraPrintText(g_i18n:getText("braccioSx")..string.format(" [ C C O ] ")..g_i18n:getText("dadoSx")..string.format(" [ O O O ] ")..g_i18n:getText("dadoDx")); end;
		if self.currentdadoSxD == 7 then g_currentMission:addExtraPrintText(g_i18n:getText("braccioSx")..string.format(" [ C C O ] ")..g_i18n:getText("dadoSx")..string.format(" [  O K  ] ")..g_i18n:getText("dadoDx")); end; end;
		if (self.currentdadoSxS == 3 or self.currentdadoSxS == 4) then if self.currentdadoSxD == 0 then g_currentMission:addExtraPrintText(g_i18n:getText("braccioSx")..string.format(" [ C O O ] ")..g_i18n:getText("dadoSx")..string.format(" [ C C C ] ")..g_i18n:getText("dadoDx")); end;
		if (self.currentdadoSxD == 2 or self.currentdadoSxD == 1) then g_currentMission:addExtraPrintText(g_i18n:getText("braccioSx")..string.format(" [ C O O ] ")..g_i18n:getText("dadoSx")..string.format(" [ C C O ] ")..g_i18n:getText("dadoDx")); end;
		if (self.currentdadoSxD == 3 or self.currentdadoSxD == 4) then g_currentMission:addExtraPrintText(g_i18n:getText("braccioSx")..string.format(" [ C O O ] ")..g_i18n:getText("dadoSx")..string.format(" [ C O O ] ")..g_i18n:getText("dadoDx")); end;
		if (self.currentdadoSxD == 5 or self.currentdadoSxD == 6) then g_currentMission:addExtraPrintText(g_i18n:getText("braccioSx")..string.format(" [ C O O ] ")..g_i18n:getText("dadoSx")..string.format(" [ O O O ] ")..g_i18n:getText("dadoDx")); end;
		if self.currentdadoSxD == 7 then g_currentMission:addExtraPrintText(g_i18n:getText("braccioSx")..string.format(" [ C O O ] ")..g_i18n:getText("dadoSx")..string.format(" [  O K  ] ")..g_i18n:getText("dadoDx")); end; end;		
		if (self.currentdadoSxS == 5 or self.currentdadoSxS == 6) then if self.currentdadoSxD == 0 then g_currentMission:addExtraPrintText(g_i18n:getText("braccioSx")..string.format(" [ O O O ] ")..g_i18n:getText("dadoSx")..string.format(" [ C C C ] ")..g_i18n:getText("dadoDx")); end;
		if (self.currentdadoSxD == 2 or self.currentdadoSxD == 1) then g_currentMission:addExtraPrintText(g_i18n:getText("braccioSx")..string.format(" [ O O O ] ")..g_i18n:getText("dadoSx")..string.format(" [ C C O ] ")..g_i18n:getText("dadoDx")); end;
		if (self.currentdadoSxD == 3 or self.currentdadoSxD == 4) then g_currentMission:addExtraPrintText(g_i18n:getText("braccioSx")..string.format(" [ O O O ] ")..g_i18n:getText("dadoSx")..string.format(" [ C O O ] ")..g_i18n:getText("dadoDx")); end;
		if (self.currentdadoSxD == 5 or self.currentdadoSxD == 6) then g_currentMission:addExtraPrintText(g_i18n:getText("braccioSx")..string.format(" [ O O O ] ")..g_i18n:getText("dadoSx")..string.format(" [ O O O ] ")..g_i18n:getText("dadoDx")); end;
		if self.currentdadoSxD == 7 then g_currentMission:addExtraPrintText(g_i18n:getText("braccioSx")..string.format(" [ O O O ] ")..g_i18n:getText("dadoSx")..string.format(" [  O K  ] ")..g_i18n:getText("dadoDx")); end; end;	
		if self.currentdadoSxS == 7 then if self.currentdadoSxD == 0 then g_currentMission:addExtraPrintText(g_i18n:getText("braccioSx")..string.format(" [  O K  ] ")..g_i18n:getText("dadoSx")..string.format(" [ C C C ] ")..g_i18n:getText("dadoDx")); end;
		if (self.currentdadoSxD == 2 or self.currentdadoSxD == 1) then g_currentMission:addExtraPrintText(g_i18n:getText("braccioSx")..string.format(" [  O K  ] ")..g_i18n:getText("dadoSx")..string.format(" [ C C O ] ")..g_i18n:getText("dadoDx")); end;
		if (self.currentdadoSxD == 3 or self.currentdadoSxD == 4) then g_currentMission:addExtraPrintText(g_i18n:getText("braccioSx")..string.format(" [  O K  ] ")..g_i18n:getText("dadoSx")..string.format(" [ C O O ] ")..g_i18n:getText("dadoDx")); end;
		if (self.currentdadoSxD == 5 or self.currentdadoSxD == 6) then g_currentMission:addExtraPrintText(g_i18n:getText("braccioSx")..string.format(" [  O K  ] ")..g_i18n:getText("dadoSx")..string.format(" [ O O O ] ")..g_i18n:getText("dadoDx")); end;
		if self.currentdadoSxD == 7 then g_currentMission:addExtraPrintText(g_i18n:getText("braccioSx")..string.format(" [  O K  ] ")..g_i18n:getText("dadoSx")..string.format(" [  O K  ] ")..g_i18n:getText("dadoDx")); end; end;
		if self.currentdadoDxS == 0 then if self.currentdadoDxD == 0 then g_currentMission:addExtraPrintText(g_i18n:getText("braccioDx")..string.format(" [ C C C ] ")..g_i18n:getText("dadoSx")..string.format(" [ C C C ] ")..g_i18n:getText("dadoDx")); end;
		if (self.currentdadoDxD == 2 or self.currentdadoDxD == 1) then g_currentMission:addExtraPrintText(g_i18n:getText("braccioDx")..string.format(" [ C C C ] ")..g_i18n:getText("dadoSx")..string.format(" [ C C O ] ")..g_i18n:getText("dadoDx")); end;
		if (self.currentdadoDxD == 3 or self.currentdadoDxD == 4) then g_currentMission:addExtraPrintText(g_i18n:getText("braccioDx")..string.format(" [ C C C ] ")..g_i18n:getText("dadoSx")..string.format(" [ C O O ] ")..g_i18n:getText("dadoDx")); end;
		if (self.currentdadoDxD == 5 or self.currentdadoDxD == 6) then g_currentMission:addExtraPrintText(g_i18n:getText("braccioDx")..string.format(" [ C C C ] ")..g_i18n:getText("dadoSx")..string.format(" [ O O O ] ")..g_i18n:getText("dadoDx")); end;
		if self.currentdadoDxD == 7 then g_currentMission:addExtraPrintText(g_i18n:getText("braccioDx")..string.format(" [ C C C ] ")..g_i18n:getText("dadoSx")..string.format(" [  O K  ] ")..g_i18n:getText("dadoDx")); end; end;
		if (self.currentdadoDxS == 2 or self.currentdadoDxS == 1) then if self.currentdadoDxD == 0 then g_currentMission:addExtraPrintText(g_i18n:getText("braccioDx")..string.format(" [ C C O ] ")..g_i18n:getText("dadoSx")..string.format(" [ C C C ] ")..g_i18n:getText("dadoDx")); end;
		if (self.currentdadoDxD == 2 or self.currentdadoDxD == 1) then g_currentMission:addExtraPrintText(g_i18n:getText("braccioDx")..string.format(" [ C C O ] ")..g_i18n:getText("dadoSx")..string.format(" [ C C O ] ")..g_i18n:getText("dadoDx")); end;
		if (self.currentdadoDxD == 3 or self.currentdadoDxD == 4) then g_currentMission:addExtraPrintText(g_i18n:getText("braccioDx")..string.format(" [ C C O ] ")..g_i18n:getText("dadoSx")..string.format(" [ C O O ] ")..g_i18n:getText("dadoDx")); end;
		if (self.currentdadoDxD == 5 or self.currentdadoDxD == 6) then g_currentMission:addExtraPrintText(g_i18n:getText("braccioDx")..string.format(" [ C C O ] ")..g_i18n:getText("dadoSx")..string.format(" [ O O O ] ")..g_i18n:getText("dadoDx")); end;
		if self.currentdadoDxD == 7 then g_currentMission:addExtraPrintText(g_i18n:getText("braccioDx")..string.format(" [ C C O ] ")..g_i18n:getText("dadoSx")..string.format(" [  O K  ] ")..g_i18n:getText("dadoDx")); end; end;
		if (self.currentdadoDxS == 3 or self.currentdadoDxS == 4) then if self.currentdadoDxD == 0 then g_currentMission:addExtraPrintText(g_i18n:getText("braccioDx")..string.format(" [ C O O ] ")..g_i18n:getText("dadoSx")..string.format(" [ C C C ] ")..g_i18n:getText("dadoDx")); end;
		if (self.currentdadoDxD == 2 or self.currentdadoDxD == 1) then g_currentMission:addExtraPrintText(g_i18n:getText("braccioDx")..string.format(" [ C O O ] ")..g_i18n:getText("dadoSx")..string.format(" [ C C O ] ")..g_i18n:getText("dadoDx")); end;
		if (self.currentdadoDxD == 3 or self.currentdadoDxD == 4) then g_currentMission:addExtraPrintText(g_i18n:getText("braccioDx")..string.format(" [ C O O ] ")..g_i18n:getText("dadoSx")..string.format(" [ C O O ] ")..g_i18n:getText("dadoDx")); end;
		if (self.currentdadoDxD == 5 or self.currentdadoDxD == 6) then g_currentMission:addExtraPrintText(g_i18n:getText("braccioDx")..string.format(" [ C O O ] ")..g_i18n:getText("dadoSx")..string.format(" [ O O O ] ")..g_i18n:getText("dadoDx")); end;
		if self.currentdadoDxD == 7 then g_currentMission:addExtraPrintText(g_i18n:getText("braccioDx")..string.format(" [ C O O ] ")..g_i18n:getText("dadoSx")..string.format(" [  O K  ] ")..g_i18n:getText("dadoDx")); end; end;
		if (self.currentdadoDxS == 5 or self.currentdadoDxS == 6) then if self.currentdadoDxD == 0 then g_currentMission:addExtraPrintText(g_i18n:getText("braccioDx")..string.format(" [ O O O ] ")..g_i18n:getText("dadoSx")..string.format(" [ C C C ] ")..g_i18n:getText("dadoDx")); end;
		if (self.currentdadoDxD == 2 or self.currentdadoDxD == 1) then g_currentMission:addExtraPrintText(g_i18n:getText("braccioDx")..string.format(" [ O O O ] ")..g_i18n:getText("dadoSx")..string.format(" [ C C O ] ")..g_i18n:getText("dadoDx")); end;
		if (self.currentdadoDxD == 3 or self.currentdadoDxD == 4) then g_currentMission:addExtraPrintText(g_i18n:getText("braccioDx")..string.format(" [ O O O ] ")..g_i18n:getText("dadoSx")..string.format(" [ C O O ] ")..g_i18n:getText("dadoDx")); end;
		if (self.currentdadoDxD == 5 or self.currentdadoDxD == 6) then g_currentMission:addExtraPrintText(g_i18n:getText("braccioDx")..string.format(" [ O O O ] ")..g_i18n:getText("dadoSx")..string.format(" [ O O O ] ")..g_i18n:getText("dadoDx")); end;
		if self.currentdadoDxD == 7 then g_currentMission:addExtraPrintText(g_i18n:getText("braccioDx")..string.format(" [ O O O ] ")..g_i18n:getText("dadoSx")..string.format(" [  O K  ] ")..g_i18n:getText("dadoDx")); end; end;
		if self.currentdadoDxS == 7 then if self.currentdadoDxD == 0 then g_currentMission:addExtraPrintText(g_i18n:getText("braccioDx")..string.format(" [  O K  ] ")..g_i18n:getText("dadoSx")..string.format(" [ C C C ] ")..g_i18n:getText("dadoDx")); end;
		if (self.currentdadoDxD == 2 or self.currentdadoDxD == 1) then g_currentMission:addExtraPrintText(g_i18n:getText("braccioDx")..string.format(" [  O K  ] ")..g_i18n:getText("dadoSx")..string.format(" [ C C O ] ")..g_i18n:getText("dadoDx")); end;
		if (self.currentdadoDxD == 3 or self.currentdadoDxD == 4) then g_currentMission:addExtraPrintText(g_i18n:getText("braccioDx")..string.format(" [  O K  ] ")..g_i18n:getText("dadoSx")..string.format(" [ C O O ] ")..g_i18n:getText("dadoDx")); end;
		if (self.currentdadoDxD == 5 or self.currentdadoDxD == 6) then g_currentMission:addExtraPrintText(g_i18n:getText("braccioDx")..string.format(" [  O K  ] ")..g_i18n:getText("dadoSx")..string.format(" [ O O O ] ")..g_i18n:getText("dadoDx")); end;
		if self.currentdadoDxD == 7 then g_currentMission:addExtraPrintText(g_i18n:getText("braccioDx")..string.format(" [  O K  ] ")..g_i18n:getText("dadoSx")..string.format(" [  O K  ] ")..g_i18n:getText("dadoDx")); end; end;
		if InputBinding.hasEvent(InputBinding.CAMERA_SWITCH) then 
			if     self.currentChiave == 1 or self.currentChiave == -1 then self:setcurrentChiave(-2); if self.currentdadoDxS < 7 then self:setcurrentChiave(4); else self:setcurrentChiave(-2); end;
			elseif self.currentChiave == 3 or self.currentChiave == -3 then self:setcurrentChiave(-4); if self.currentdadoSxD < 7 then self:setcurrentChiave(6); else self:setcurrentChiave(-4); end;
			elseif self.currentChiave == 5 or self.currentChiave == -5 then self:setcurrentChiave(-6); if self.currentdadoSxS < 7 then self:setcurrentChiave(8); else self:setcurrentChiave(-6); end;
			elseif self.currentChiave == 7 or self.currentChiave == -7 then self:setcurrentChiave(0);  if self.currentdadoDxD < 7 then self:setcurrentChiave(2); else self:setcurrentChiave(0); end; end; end;
		if self.currentChiave == 1 or self.currentChiave == -1 then g_currentMission:addHelpButtonText(g_i18n:getText("dadoDxS"), InputBinding.CAMERA_SWITCH); g_currentMission:addExtraPrintText(g_i18n:getText("dadoDxDX")); end;
		if self.currentChiave == 3 or self.currentChiave == -3 then g_currentMission:addHelpButtonText(g_i18n:getText("dadoSxD"), InputBinding.CAMERA_SWITCH); g_currentMission:addExtraPrintText(g_i18n:getText("dadoDxSX")); end;
		if self.currentChiave == 5 or self.currentChiave == -5 then g_currentMission:addHelpButtonText(g_i18n:getText("dadoSxS"), InputBinding.CAMERA_SWITCH); g_currentMission:addExtraPrintText(g_i18n:getText("dadoSxDX")); end;
		if self.currentChiave == 7 or self.currentChiave == -7 then g_currentMission:addHelpButtonText(g_i18n:getText("dadoDxD"), InputBinding.CAMERA_SWITCH); g_currentMission:addExtraPrintText(g_i18n:getText("dadoSxSX")); end;
		if InputBinding.hasEvent(InputBinding.attachCSZ) then 
			if self.currentChiave == 1 and self.currentdadoDxD < 7 then self:setcurrentChiave(0); elseif not self:getIsAnimationPlaying("dadoDxDS") and self.currentChiave == -1 then self:setcurrentChiave(2); end;
			if self.currentChiave == 3 and self.currentdadoDxS < 7 then self:setcurrentChiave(-2); elseif not self:getIsAnimationPlaying("dadoDxSS") and self.currentChiave == -3 then self:setcurrentChiave(4); end;
			if self.currentChiave == 5 and self.currentdadoSxD < 7 then self:setcurrentChiave(-4); elseif not self:getIsAnimationPlaying("dadoSxDS") and self.currentChiave == -5 then self:setcurrentChiave(6); end;
			if self.currentChiave == 7 and self.currentdadoSxS < 7 then self:setcurrentChiave(-6); elseif not self:getIsAnimationPlaying("dadoSxSS") and self.currentChiave == -7 then self:setcurrentChiave(8); end; end;
		if self.currentChiave == 1 and self.currentdadoDxD < 7 then g_currentMission:addHelpButtonText(g_i18n:getText("disattivaChiave"), InputBinding.attachCSZ); elseif self.currentdadoDxD < 7 and self.currentChiave == -1 and not self:getIsAnimationPlaying("dadoDxDS") then g_currentMission:addHelpButtonText(g_i18n:getText("attivaChiave"), InputBinding.attachCSZ); end;
		if self.currentChiave == 3 and self.currentdadoDxS < 7 then g_currentMission:addHelpButtonText(g_i18n:getText("disattivaChiave"), InputBinding.attachCSZ); elseif self.currentdadoDxS < 7 and self.currentChiave == -3 and not self:getIsAnimationPlaying("dadoDxDS") then g_currentMission:addHelpButtonText(g_i18n:getText("attivaChiave"), InputBinding.attachCSZ); end;
		if self.currentChiave == 5 and self.currentdadoSxD < 7 then g_currentMission:addHelpButtonText(g_i18n:getText("disattivaChiave"), InputBinding.attachCSZ); elseif self.currentdadoSxD < 7 and self.currentChiave == -5 and not self:getIsAnimationPlaying("dadoDxDS") then g_currentMission:addHelpButtonText(g_i18n:getText("attivaChiave"), InputBinding.attachCSZ); end;
		if self.currentChiave == 7 and self.currentdadoSxS < 7 then g_currentMission:addHelpButtonText(g_i18n:getText("disattivaChiave"), InputBinding.attachCSZ); elseif self.currentdadoSxS < 7 and self.currentChiave == -7 and not self:getIsAnimationPlaying("dadoDxDS") then g_currentMission:addHelpButtonText(g_i18n:getText("attivaChiave"), InputBinding.attachCSZ); end;
		if InputBinding.hasEvent(InputBinding.TOGGLE_COVER) then 
			if self.currentdadoDxD == 7 and self.currentChiave == -1 then self:setcurrentdadoDxD(5); self:playAnimation("dadoDxDRC2", -1); self:playAnimation("dadoDxDS", -1); end; 
			if self.currentdadoDxS == 7 and self.currentChiave == -3 then self:setcurrentdadoDxS(5); self:playAnimation("dadoDxSRC2", -1); self:playAnimation("dadoDxSS", -1); end; 
			if self.currentdadoSxD == 7 and self.currentChiave == -5 then self:setcurrentdadoSxD(5); self:playAnimation("dadoSxDRC2", -1); self:playAnimation("dadoSxDS", -1); end; 
			if self.currentdadoSxS == 7 and self.currentChiave == -7 then self:setcurrentdadoSxS(5); self:playAnimation("dadoSxSRC2", -1); self:playAnimation("dadoSxSS", -1); end; end;
		if self.currentdadoDxD == 7 and self.currentChiave == -1 then g_currentMission:addHelpButtonText(g_i18n:getText("dadoRimetti"), InputBinding.TOGGLE_COVER); end;
		if self.currentdadoDxS == 7 and self.currentChiave == -3 then g_currentMission:addHelpButtonText(g_i18n:getText("dadoRimetti"), InputBinding.TOGGLE_COVER); end;
		if self.currentdadoSxD == 7 and self.currentChiave == -5 then g_currentMission:addHelpButtonText(g_i18n:getText("dadoRimetti"), InputBinding.TOGGLE_COVER); end;
		if self.currentdadoSxS == 7 and self.currentChiave == -7 then g_currentMission:addHelpButtonText(g_i18n:getText("dadoRimetti"), InputBinding.TOGGLE_COVER); end;
		if self.currentChiave == 1 then if InputBinding.isPressed(InputBinding.activatekey) then self:playAnimation("dadoDxD", 1);
				if InputBinding.hasEvent(InputBinding.selectUp) and self.currentdadoDxD == 0 then self:playAnimation("dadoDxDR", 1); self:setcurrentdadoDxD(1); end;
				if InputBinding.hasEvent(InputBinding.selectDown) and self.currentdadoDxD == 1 then self:playAnimation("dadoDxDR", -1); self:setcurrentdadoDxD(0); end;
				if InputBinding.hasEvent(InputBinding.selectUp) and self.currentdadoDxD == 2 then self:playAnimation("dadoDxDR1", 1); self:setcurrentdadoDxD(3); end;
				if InputBinding.hasEvent(InputBinding.selectDown) and self.currentdadoDxD == 3 then self:playAnimation("dadoDxDR1", -1); self:setcurrentdadoDxD(2); end;
				if InputBinding.hasEvent(InputBinding.selectUp) and self.currentdadoDxD == 4 then self:playAnimation("dadoDxDR2", 1); self:setcurrentdadoDxD(5); end;
				if InputBinding.hasEvent(InputBinding.selectDown) and self.currentdadoDxD == 5 then self:playAnimation("dadoDxDR2", -1); self:setcurrentdadoDxD(4); end;
				if self.currentdadoDxD == 6 then self:setcurrentChiave(0); self:playAnimation("dadoDxDS", 1); self:setcurrentdadoDxD(7); end;
			else self:playAnimation("dadoDxD", -1);
				if InputBinding.hasEvent(InputBinding.selectDown) and self.currentdadoDxD == 1 then self:playAnimation("dadoDxDRC", 1); self:setcurrentdadoDxD(2); end;
				if InputBinding.hasEvent(InputBinding.selectUp) and self.currentdadoDxD == 2 then self:playAnimation("dadoDxDRC", -1); self:setcurrentdadoDxD(1); end; 
				if InputBinding.hasEvent(InputBinding.selectDown) and self.currentdadoDxD == 3 then self:playAnimation("dadoDxDRC1", 1); self:setcurrentdadoDxD(4); end;
				if InputBinding.hasEvent(InputBinding.selectUp) and self.currentdadoDxD == 4 then self:playAnimation("dadoDxDRC1", -1); self:setcurrentdadoDxD(3); end;
				if InputBinding.hasEvent(InputBinding.selectDown) and self.currentdadoDxD == 5 then self:playAnimation("dadoDxDRC2", 1); self:setcurrentdadoDxD(6); end;
				if InputBinding.hasEvent(InputBinding.selectUp) and self.currentdadoDxD == 6 then self:playAnimation("dadoDxDRC2", -1); self:setcurrentdadoDxD(5); end; end; end;
		if self.currentChiave == 3 then	if InputBinding.isPressed(InputBinding.activatekey) then self:playAnimation("dadoDxS", 1);
				if InputBinding.hasEvent(InputBinding.selectUp) and self.currentdadoDxS == 0 then self:playAnimation("dadoDxSR", 1); self:setcurrentdadoDxS(1); end;
				if InputBinding.hasEvent(InputBinding.selectDown) and self.currentdadoDxS == 1 then self:playAnimation("dadoDxSR", -1); self:setcurrentdadoDxS(0); end;
				if InputBinding.hasEvent(InputBinding.selectUp) and self.currentdadoDxS == 2 then self:playAnimation("dadoDxSR1", 1); self:setcurrentdadoDxS(3); end;
				if InputBinding.hasEvent(InputBinding.selectDown) and self.currentdadoDxS == 3 then self:playAnimation("dadoDxSR1", -1); self:setcurrentdadoDxS(2); end;
				if InputBinding.hasEvent(InputBinding.selectUp) and self.currentdadoDxS == 4 then self:playAnimation("dadoDxSR2", 1); self:setcurrentdadoDxS(5); end;
				if InputBinding.hasEvent(InputBinding.selectDown) and self.currentdadoDxS == 5 then self:playAnimation("dadoDxSR2", -1); self:setcurrentdadoDxS(4); end;
				if self.currentdadoDxS == 6 then self:setcurrentChiave(-2); self:playAnimation("dadoDxSS", 1); self:setcurrentdadoDxS(7); end;
			else self:playAnimation("dadoDxS", -1);
				if InputBinding.hasEvent(InputBinding.selectDown) and self.currentdadoDxS == 1 then self:playAnimation("dadoDxSRC", 1); self:setcurrentdadoDxS(2); end;
				if InputBinding.hasEvent(InputBinding.selectUp) and self.currentdadoDxS == 2 then self:playAnimation("dadoDxSRC", -1); self:setcurrentdadoDxS(1); end; 
				if InputBinding.hasEvent(InputBinding.selectDown) and self.currentdadoDxS == 3 then self:playAnimation("dadoDxSRC1", 1); self:setcurrentdadoDxS(4); end;
				if InputBinding.hasEvent(InputBinding.selectUp) and self.currentdadoDxS == 4 then self:playAnimation("dadoDxSRC1", -1); self:setcurrentdadoDxS(3); end;
				if InputBinding.hasEvent(InputBinding.selectDown) and self.currentdadoDxS == 5 then self:playAnimation("dadoDxSRC2", 1); self:setcurrentdadoDxS(6); end;
				if InputBinding.hasEvent(InputBinding.selectUp) and self.currentdadoDxS == 6 then self:playAnimation("dadoDxSRC2", -1); self:setcurrentdadoDxS(5); end; end; end;
		if self.currentChiave == 5 then	if InputBinding.isPressed(InputBinding.activatekey) then self:playAnimation("dadoSxD", 1);
				if InputBinding.hasEvent(InputBinding.selectUp) and self.currentdadoSxD == 0 then self:playAnimation("dadoSxDR", 1); self:setcurrentdadoSxD(1); end;
				if InputBinding.hasEvent(InputBinding.selectDown) and self.currentdadoSxD == 1 then self:playAnimation("dadoSxDR", -1); self:setcurrentdadoSxD(0); end;
				if InputBinding.hasEvent(InputBinding.selectUp) and self.currentdadoSxD == 2 then self:playAnimation("dadoSxDR1", 1); self:setcurrentdadoSxD(3); end;
				if InputBinding.hasEvent(InputBinding.selectDown) and self.currentdadoSxD == 3 then self:playAnimation("dadoSxDR1", -1); self:setcurrentdadoSxD(2); end;
				if InputBinding.hasEvent(InputBinding.selectUp) and self.currentdadoSxD == 4 then self:playAnimation("dadoSxDR2", 1); self:setcurrentdadoSxD(5); end;
				if InputBinding.hasEvent(InputBinding.selectDown) and self.currentdadoSxD == 5 then self:playAnimation("dadoSxDR2", -1); self:setcurrentdadoSxD(4); end;
				if self.currentdadoSxD == 6 then self:setcurrentChiave(-4); self:playAnimation("dadoSxDS", 1); self:setcurrentdadoSxD(7); end;
			else self:playAnimation("dadoSxD", -1);
				if InputBinding.hasEvent(InputBinding.selectDown) and self.currentdadoSxD == 1 then self:playAnimation("dadoSxDRC", 1); self:setcurrentdadoSxD(2); end;
				if InputBinding.hasEvent(InputBinding.selectUp) and self.currentdadoSxD == 2 then self:playAnimation("dadoSxDRC", -1); self:setcurrentdadoSxD(1); end; 
				if InputBinding.hasEvent(InputBinding.selectDown) and self.currentdadoSxD == 3 then self:playAnimation("dadoSxDRC1", 1); self:setcurrentdadoSxD(4); end;
				if InputBinding.hasEvent(InputBinding.selectUp) and self.currentdadoSxD == 4 then self:playAnimation("dadoSxDRC1", -1); self:setcurrentdadoSxD(3); end;
				if InputBinding.hasEvent(InputBinding.selectDown) and self.currentdadoSxD == 5 then self:playAnimation("dadoSxDRC2", 1); self:setcurrentdadoSxD(6); end;
				if InputBinding.hasEvent(InputBinding.selectUp) and self.currentdadoSxD == 6 then self:playAnimation("dadoSxDRC2", -1); self:setcurrentdadoSxD(5); end; end; end;
		if self.currentChiave == 7 then	if InputBinding.isPressed(InputBinding.activatekey) then self:playAnimation("dadoSxS", 1);
				if InputBinding.hasEvent(InputBinding.selectUp) and self.currentdadoSxS == 0 then self:playAnimation("dadoSxSR", 1); self:setcurrentdadoSxS(1); end;
				if InputBinding.hasEvent(InputBinding.selectDown) and self.currentdadoSxS == 1 then self:playAnimation("dadoSxSR", -1); self:setcurrentdadoSxS(0); end;
				if InputBinding.hasEvent(InputBinding.selectUp) and self.currentdadoSxS == 2 then self:playAnimation("dadoSxSR1", 1); self:setcurrentdadoSxS(3); end;
				if InputBinding.hasEvent(InputBinding.selectDown) and self.currentdadoSxS == 3 then self:playAnimation("dadoSxSR1", -1); self:setcurrentdadoSxS(2); end;
				if InputBinding.hasEvent(InputBinding.selectUp) and self.currentdadoSxS == 4 then self:playAnimation("dadoSxSR2", 1); self:setcurrentdadoSxS(5); end;
				if InputBinding.hasEvent(InputBinding.selectDown) and self.currentdadoSxS == 5 then self:playAnimation("dadoSxSR2", -1); self:setcurrentdadoSxS(4); end;
				if self.currentdadoSxS == 6 then self:setcurrentChiave(-6); self:playAnimation("dadoSxSS", 1); self:setcurrentdadoSxS(7); end;
			else self:playAnimation("dadoSxS", -1);
				if InputBinding.hasEvent(InputBinding.selectDown) and self.currentdadoSxS == 1 then self:playAnimation("dadoSxSRC", 1); self:setcurrentdadoSxS(2); end;
				if InputBinding.hasEvent(InputBinding.selectUp) and self.currentdadoSxS == 2 then self:playAnimation("dadoSxSRC", -1); self:setcurrentdadoSxS(1); end; 
				if InputBinding.hasEvent(InputBinding.selectDown) and self.currentdadoSxS == 3 then self:playAnimation("dadoSxSRC1", 1); self:setcurrentdadoSxS(4); end;
				if InputBinding.hasEvent(InputBinding.selectUp) and self.currentdadoSxS == 4 then self:playAnimation("dadoSxSRC1", -1); self:setcurrentdadoSxS(3); end;
				if InputBinding.hasEvent(InputBinding.selectDown) and self.currentdadoSxS == 5 then self:playAnimation("dadoSxSRC2", 1); self:setcurrentdadoSxS(6); end;
				if InputBinding.hasEvent(InputBinding.selectUp) and self.currentdadoSxS == 6 then self:playAnimation("dadoSxSRC2", -1); self:setcurrentdadoSxS(5); end; end; end;
		if self.currentChiave == 1 and self.currentdadoDxD < 7 then	if InputBinding.isPressed(InputBinding.activatekey) then 
			if self.currentdadoDxD == 1 or self.currentdadoDxD == 3 or self.currentdadoDxD == 5 or self.currentdadoDxD == 7 then g_currentMission:addHelpButtonText(g_i18n:getText("avvitaDado"), InputBinding.selectDown); end; 
			if self.currentdadoDxD == 0 or self.currentdadoDxD == 2 or self.currentdadoDxD == 4 or self.currentdadoDxD == 6 then g_currentMission:addHelpButtonText(g_i18n:getText("svitaDado"), InputBinding.selectUp); end;
			else g_currentMission:addHelpButtonText(g_i18n:getText("attivaDado"), InputBinding.activatekey);
			if self.currentdadoDxD == 1 or self.currentdadoDxD == 3 or self.currentdadoDxD == 5 or self.currentdadoDxD == 7 then g_currentMission:addHelpButtonText(g_i18n:getText("ruotaSO"), InputBinding.selectDown); end;
			if self.currentdadoDxD == 2 or self.currentdadoDxD == 4 or self.currentdadoDxD == 6 then g_currentMission:addHelpButtonText(g_i18n:getText("ruotaSA"), InputBinding.selectUp); end; end; end;
		if self.currentChiave == 3 and self.currentdadoDxS < 7 then	if InputBinding.isPressed(InputBinding.activatekey) then 
			if self.currentdadoDxS == 1 or self.currentdadoDxS == 3 or self.currentdadoDxS == 5 or self.currentdadoDxS == 7 then g_currentMission:addHelpButtonText(g_i18n:getText("avvitaDado"), InputBinding.selectDown); end; 
			if self.currentdadoDxS == 0 or self.currentdadoDxS == 2 or self.currentdadoDxS == 4 or self.currentdadoDxS == 6 then g_currentMission:addHelpButtonText(g_i18n:getText("svitaDado"), InputBinding.selectUp); end;
			else g_currentMission:addHelpButtonText(g_i18n:getText("attivaDado"), InputBinding.activatekey);
			if self.currentdadoDxS == 1 or self.currentdadoDxS == 3 or self.currentdadoDxS == 5 or self.currentdadoDxS == 7 then g_currentMission:addHelpButtonText(g_i18n:getText("ruotaSO"), InputBinding.selectDown); end;
			if self.currentdadoDxS == 2 or self.currentdadoDxS == 4 or self.currentdadoDxS == 6 then g_currentMission:addHelpButtonText(g_i18n:getText("ruotaSA"), InputBinding.selectUp); end; end; end;
		if self.currentChiave == 5 and self.currentdadoSxD < 7 then	if InputBinding.isPressed(InputBinding.activatekey) then 
			if self.currentdadoSxD == 1 or self.currentdadoSxD == 3 or self.currentdadoSxD == 5 or self.currentdadoSxD == 7 then g_currentMission:addHelpButtonText(g_i18n:getText("avvitaDado"), InputBinding.selectDown); end; 
			if self.currentdadoSxD == 0 or self.currentdadoSxD == 2 or self.currentdadoSxD == 4 or self.currentdadoSxD == 6 then g_currentMission:addHelpButtonText(g_i18n:getText("svitaDado"), InputBinding.selectUp); end;
			else g_currentMission:addHelpButtonText(g_i18n:getText("attivaDado"), InputBinding.activatekey);
			if self.currentdadoSxD == 1 or self.currentdadoSxD == 3 or self.currentdadoSxD == 5 or self.currentdadoSxD == 7 then g_currentMission:addHelpButtonText(g_i18n:getText("ruotaSO"), InputBinding.selectDown); end;
			if self.currentdadoSxD == 2 or self.currentdadoSxD == 4 or self.currentdadoSxD == 6 then g_currentMission:addHelpButtonText(g_i18n:getText("ruotaSA"), InputBinding.selectUp); end; end; end;
		if self.currentChiave == 7 and self.currentdadoSxS < 7 then	if InputBinding.isPressed(InputBinding.activatekey) then 
			if self.currentdadoSxS == 1 or self.currentdadoSxS == 3 or self.currentdadoSxS == 5 or self.currentdadoSxS == 7 then g_currentMission:addHelpButtonText(g_i18n:getText("avvitaDado"), InputBinding.selectDown); end; 
			if self.currentdadoSxS == 0 or self.currentdadoSxS == 2 or self.currentdadoSxS == 4 or self.currentdadoSxS == 6 then g_currentMission:addHelpButtonText(g_i18n:getText("svitaDado"), InputBinding.selectUp); end;
			else g_currentMission:addHelpButtonText(g_i18n:getText("attivaDado"), InputBinding.activatekey);
			if self.currentdadoSxS == 1 or self.currentdadoSxS == 3 or self.currentdadoSxS == 5 or self.currentdadoSxS == 7 then g_currentMission:addHelpButtonText(g_i18n:getText("ruotaSO"), InputBinding.selectDown); end;
			if self.currentdadoSxS == 2 or self.currentdadoSxS == 4 or self.currentdadoSxS == 6 then g_currentMission:addHelpButtonText(g_i18n:getText("ruotaSA"), InputBinding.selectUp); end; end; end; end; end; end;
function pinzaMordente:updateTick(dt) if self.currentBracci == 0 then self:playAnimation("bracciSuperiori", -1, nil, true); if self.resetBracci then local xr, yr, zr = getRotation(self.components[3].node); setRotation(self.components[2].node, xr, yr, zr); local xt, yt, zt = getTranslation(self.components[3].node); setTranslation(self.components[2].node, xt, yt, zt); end; self.resetBracci = true; setMass(self.components[1].node, self.extraWeightsDefaultMass); self:setcurrentPiloni(1); self.currentBracci = 1;
	elseif self.currentBracci == 2 then	self:playAnimation("bracciSuperiori", 1, nil, true); self.resetBracci = true; self:setcurrentPiloni(3); self.currentBracci = 3; setMass(self.components[1].node, self.extraWeightsDefaultMass + 0.2); end;
	if self.currentChiave == 2 then self:playAnimation("dadoDxDCV", 1); self.currentChiave = 1; end; if self.currentChiave == 4 then self:playAnimation("dadoDxSCV", 1); self.currentChiave = 3; end; if self.currentChiave == 6 then self:playAnimation("dadoSxDCV", 1); self.currentChiave = 5; end; if self.currentChiave == 8 then self:playAnimation("dadoSxSCV", 1); self.currentChiave = 7; end;
	if self.currentChiave == 0 then self:playAnimation("dadoCV", 1); self.currentChiave = -1; end; if self.currentChiave == -2 then self:playAnimation("dadoCV", 1); self.currentChiave = -3; end; if self.currentChiave == -4 then self:playAnimation("dadoCV", 1); self.currentChiave = -5; end; if self.currentChiave == -6 then self:playAnimation("dadoCV", 1); self.currentChiave = -7; end; if self.currentPiloni == 0 then self.currentPiloni = 1; end; end;
function pinzaMordente:draw() if self.currentBalle == -1 and self.currentSupport then 
	if self.currentPosizione == 0 and not self.balesAttached then g_currentMission:addHelpButtonText(g_i18n:getText("bracciApri"), InputBinding.IMPLEMENT_EXTRA); elseif self.currentPosizione == 1 then g_currentMission:addHelpButtonText(g_i18n:getText("bracciChiudi"), InputBinding.IMPLEMENT_EXTRA); end; end; if self.setBaleLoader == 0 and not self.balesAttached then if self.currentSupport then g_currentMission:addHelpButtonText(g_i18n:getText("forcaApri"), InputBinding.OpenClose); else g_currentMission:addHelpButtonText(g_i18n:getText("forcaChiudi"), InputBinding.OpenClose); end; end; end;
function pinzaMordente:onAttach(attacherVehicle, jointDescIndex) setVisibility(self.tubiIdraulici, false); setVisibility(self.tubiIdrauliciA, true); setVisibility(self.tuboSupporto, false); end;
function pinzaMordente:onDetach() setVisibility(self.tubiIdraulici, true); setVisibility(self.tubiIdrauliciA, false); setVisibility(self.tuboSupporto, true); end;
function pinzaMordente:onDeactivate() end;
setcurrentBracciEvent = {}; setcurrentBracciEvent_mt = Class(setcurrentBracciEvent, Event); InitEventClass(setcurrentBracciEvent, "setcurrentBracciEvent");
function setcurrentBracciEvent:emptyNew() local self = Event:new(setcurrentBracciEvent_mt); self.className="setcurrentBracciEvent"; return self; end;
function setcurrentBracciEvent:new(vehicle, currentBracci) local self = setcurrentBracciEvent:emptyNew() self.vehicle = vehicle; self.currentBracci = currentBracci; return self; end;
function setcurrentBracciEvent:readStream(streamId, connection) local id = streamReadInt32(streamId); self.vehicle = networkGetObject(id); self.currentBracci = streamReadInt8(streamId);	self.vehicle:setcurrentBracci(self.currentBracci, true);
	if not connection:getIsServer() then g_server:broadcastEvent(setcurrentBracciEvent:new(self.vehicle, self.currentBracci), nil, connection, self.vehicle); end; end;
function setcurrentBracciEvent:writeStream(streamId, connection) streamWriteInt32(streamId, networkGetObjectId(self.vehicle)); streamWriteInt8(streamId, self.currentBracci); end;
function setcurrentBracciEvent.sendEvent(vehicle, currentBracci, noEventSend) if noEventSend == nil or noEventSend == false then
	if g_server ~= nil then	g_server:broadcastEvent(setcurrentBracciEvent:new(vehicle, currentBracci), nil, nil, vehicle);
	else g_client:getServerConnection():sendEvent(setcurrentBracciEvent:new(vehicle, currentBracci)); end; end; end;
setcurrentChiaveEvent = {}; setcurrentChiaveEvent_mt = Class(setcurrentChiaveEvent, Event); InitEventClass(setcurrentChiaveEvent, "setcurrentChiaveEvent");
function setcurrentChiaveEvent:emptyNew() local self = Event:new(setcurrentChiaveEvent_mt); self.className="setcurrentChiaveEvent"; return self; end;
function setcurrentChiaveEvent:new(vehicle, currentChiave) local self = setcurrentChiaveEvent:emptyNew() self.vehicle = vehicle; self.currentChiave = currentChiave; return self; end;
function setcurrentChiaveEvent:readStream(streamId, connection) local id = streamReadInt32(streamId); self.vehicle = networkGetObject(id); self.currentChiave = streamReadInt8(streamId);	self.vehicle:setcurrentChiave(self.currentChiave, true);
	if not connection:getIsServer() then g_server:broadcastEvent(setcurrentChiaveEvent:new(self.vehicle, self.currentChiave), nil, connection, self.vehicle); end; end;
function setcurrentChiaveEvent:writeStream(streamId, connection) streamWriteInt32(streamId, networkGetObjectId(self.vehicle)); streamWriteInt8(streamId, self.currentChiave); end;
function setcurrentChiaveEvent.sendEvent(vehicle, currentChiave, noEventSend) if noEventSend == nil or noEventSend == false then
	if g_server ~= nil then	g_server:broadcastEvent(setcurrentChiaveEvent:new(vehicle, currentChiave), nil, nil, vehicle);
	else g_client:getServerConnection():sendEvent(setcurrentChiaveEvent:new(vehicle, currentChiave)); end; end; end;
setcurrentdadoDxDEvent = {}; setcurrentdadoDxDEvent_mt = Class(setcurrentdadoDxDEvent, Event); InitEventClass(setcurrentdadoDxDEvent, "setcurrentdadoDxDEvent");
function setcurrentdadoDxDEvent:emptyNew() local self = Event:new(setcurrentdadoDxDEvent_mt); self.className="setcurrentdadoDxDEvent"; return self; end;
function setcurrentdadoDxDEvent:new(vehicle, currentdadoDxD) local self = setcurrentdadoDxDEvent:emptyNew() self.vehicle = vehicle; self.currentdadoDxD = currentdadoDxD; return self; end;
function setcurrentdadoDxDEvent:readStream(streamId, connection) local id = streamReadInt32(streamId); self.vehicle = networkGetObject(id); self.currentdadoDxD = streamReadInt8(streamId);	self.vehicle:setcurrentdadoDxD(self.currentdadoDxD, true);
	if not connection:getIsServer() then g_server:broadcastEvent(setcurrentdadoDxDEvent:new(self.vehicle, self.currentdadoDxD), nil, connection, self.vehicle); end; end;
function setcurrentdadoDxDEvent:writeStream(streamId, connection) streamWriteInt32(streamId, networkGetObjectId(self.vehicle)); streamWriteInt8(streamId, self.currentdadoDxD); end;
function setcurrentdadoDxDEvent.sendEvent(vehicle, currentdadoDxD, noEventSend) if noEventSend == nil or noEventSend == false then
	if g_server ~= nil then	g_server:broadcastEvent(setcurrentdadoDxDEvent:new(vehicle, currentdadoDxD), nil, nil, vehicle);
	else g_client:getServerConnection():sendEvent(setcurrentdadoDxDEvent:new(vehicle, currentdadoDxD)); end; end; end;
setcurrentdadoDxSEvent = {}; setcurrentdadoDxSEvent_mt = Class(setcurrentdadoDxSEvent, Event); InitEventClass(setcurrentdadoDxSEvent, "setcurrentdadoDxSEvent");
function setcurrentdadoDxSEvent:emptyNew() local self = Event:new(setcurrentdadoDxSEvent_mt); self.className="setcurrentdadoDxSEvent"; return self; end;
function setcurrentdadoDxSEvent:new(vehicle, currentdadoDxS) local self = setcurrentdadoDxSEvent:emptyNew() self.vehicle = vehicle; self.currentdadoDxS = currentdadoDxS; return self; end;
function setcurrentdadoDxSEvent:readStream(streamId, connection) local id = streamReadInt32(streamId); self.vehicle = networkGetObject(id); self.currentdadoDxS = streamReadInt8(streamId);	self.vehicle:setcurrentdadoDxS(self.currentdadoDxS, true);
	if not connection:getIsServer() then g_server:broadcastEvent(setcurrentdadoDxSEvent:new(self.vehicle, self.currentdadoDxS), nil, connection, self.vehicle); end; end;
function setcurrentdadoDxSEvent:writeStream(streamId, connection) streamWriteInt32(streamId, networkGetObjectId(self.vehicle)); streamWriteInt8(streamId, self.currentdadoDxS); end;
function setcurrentdadoDxSEvent.sendEvent(vehicle, currentdadoDxS, noEventSend) if noEventSend == nil or noEventSend == false then
	if g_server ~= nil then	g_server:broadcastEvent(setcurrentdadoDxSEvent:new(vehicle, currentdadoDxS), nil, nil, vehicle);
	else g_client:getServerConnection():sendEvent(setcurrentdadoDxSEvent:new(vehicle, currentdadoDxS)); end; end; end;
setcurrentdadoSxDEvent = {}; setcurrentdadoSxDEvent_mt = Class(setcurrentdadoSxDEvent, Event); InitEventClass(setcurrentdadoSxDEvent, "setcurrentdadoSxDEvent");
function setcurrentdadoSxDEvent:emptyNew() local self = Event:new(setcurrentdadoSxDEvent_mt); self.className="setcurrentdadoSxDEvent"; return self; end;
function setcurrentdadoSxDEvent:new(vehicle, currentdadoSxD) local self = setcurrentdadoSxDEvent:emptyNew() self.vehicle = vehicle; self.currentdadoSxD = currentdadoSxD; return self; end;
function setcurrentdadoSxDEvent:readStream(streamId, connection) local id = streamReadInt32(streamId); self.vehicle = networkGetObject(id); self.currentdadoSxD = streamReadInt8(streamId);	self.vehicle:setcurrentdadoSxD(self.currentdadoSxD, true);
	if not connection:getIsServer() then g_server:broadcastEvent(setcurrentdadoSxDEvent:new(self.vehicle, self.currentdadoSxD), nil, connection, self.vehicle); end; end;
function setcurrentdadoSxDEvent:writeStream(streamId, connection) streamWriteInt32(streamId, networkGetObjectId(self.vehicle)); streamWriteInt8(streamId, self.currentdadoSxD); end;
function setcurrentdadoSxDEvent.sendEvent(vehicle, currentdadoSxD, noEventSend) if noEventSend == nil or noEventSend == false then
	if g_server ~= nil then	g_server:broadcastEvent(setcurrentdadoSxDEvent:new(vehicle, currentdadoSxD), nil, nil, vehicle);
	else g_client:getServerConnection():sendEvent(setcurrentdadoSxDEvent:new(vehicle, currentdadoSxD)); end; end; end;
setcurrentdadoSxSEvent = {}; setcurrentdadoSxSEvent_mt = Class(setcurrentdadoSxSEvent, Event); InitEventClass(setcurrentdadoSxSEvent, "setcurrentdadoSxSEvent");
function setcurrentdadoSxSEvent:emptyNew() local self = Event:new(setcurrentdadoSxSEvent_mt); self.className="setcurrentdadoSxSEvent"; return self; end;
function setcurrentdadoSxSEvent:new(vehicle, currentdadoSxS) local self = setcurrentdadoSxSEvent:emptyNew() self.vehicle = vehicle; self.currentdadoSxS = currentdadoSxS; return self; end;
function setcurrentdadoSxSEvent:readStream(streamId, connection) local id = streamReadInt32(streamId); self.vehicle = networkGetObject(id); self.currentdadoSxS = streamReadInt8(streamId);	self.vehicle:setcurrentdadoSxS(self.currentdadoSxS, true);
	if not connection:getIsServer() then g_server:broadcastEvent(setcurrentdadoSxSEvent:new(self.vehicle, self.currentdadoSxS), nil, connection, self.vehicle); end; end;
function setcurrentdadoSxSEvent:writeStream(streamId, connection) streamWriteInt32(streamId, networkGetObjectId(self.vehicle)); streamWriteInt8(streamId, self.currentdadoSxS); end;
function setcurrentdadoSxSEvent.sendEvent(vehicle, currentdadoSxS, noEventSend) if noEventSend == nil or noEventSend == false then
	if g_server ~= nil then	g_server:broadcastEvent(setcurrentdadoSxSEvent:new(vehicle, currentdadoSxS), nil, nil, vehicle);
	else g_client:getServerConnection():sendEvent(setcurrentdadoSxSEvent:new(vehicle, currentdadoSxS)); end; end; end;
setcurrentPosizioneEvent = {}; setcurrentPosizioneEvent_mt = Class(setcurrentPosizioneEvent, Event); InitEventClass(setcurrentPosizioneEvent, "setcurrentPosizioneEvent");
function setcurrentPosizioneEvent:emptyNew() local self = Event:new(setcurrentPosizioneEvent_mt); self.className="setcurrentPosizioneEvent"; return self; end;
function setcurrentPosizioneEvent:new(vehicle, currentPosizione) local self = setcurrentPosizioneEvent:emptyNew() self.vehicle = vehicle; self.currentPosizione = currentPosizione; return self; end;
function setcurrentPosizioneEvent:readStream(streamId, connection) local id = streamReadInt32(streamId);
    self.vehicle = networkGetObject(id); self.currentPosizione = streamReadInt8(streamId); self.vehicle:setcurrentPosizione(self.currentPosizione, true);
	if not connection:getIsServer() then g_server:broadcastEvent(setcurrentPosizioneEvent:new(self.vehicle, self.currentPosizione), nil, connection, self.vehicle); end; end;
function setcurrentPosizioneEvent:writeStream(streamId, connection) streamWriteInt32(streamId, networkGetObjectId(self.vehicle)); streamWriteInt8(streamId, self.currentPosizione); end;
function setcurrentPosizioneEvent.sendEvent(vehicle, currentPosizione, noEventSend) if noEventSend == nil or noEventSend == false then
	if g_server ~= nil then	g_server:broadcastEvent(setcurrentPosizioneEvent:new(vehicle, currentPosizione), nil, nil, vehicle);
	else g_client:getServerConnection():sendEvent(setcurrentPosizioneEvent:new(vehicle, currentPosizione)); end; end; end;
setcurrentStateEvent = {}; setcurrentStateEvent_mt = Class(setcurrentStateEvent, Event); InitEventClass(setcurrentStateEvent, "setcurrentStateEvent");
function setcurrentStateEvent:emptyNew() local self = Event:new(setcurrentStateEvent_mt); self.className="setcurrentStateEvent"; return self; end;
function setcurrentStateEvent:new(vehicle, currentState) local self = setcurrentStateEvent:emptyNew() self.vehicle = vehicle; self.currentState = currentState; return self; end;
function setcurrentStateEvent:readStream(streamId, connection) local id = streamReadInt32(streamId);
    self.vehicle = networkGetObject(id); self.currentState = streamReadInt8(streamId); self.vehicle:setcurrentState(self.currentState, true);
	if not connection:getIsServer() then g_server:broadcastEvent(setcurrentStateEvent:new(self.vehicle, self.currentState), nil, connection, self.vehicle); end; end;
function setcurrentStateEvent:writeStream(streamId, connection) streamWriteInt32(streamId, networkGetObjectId(self.vehicle)); streamWriteInt8(streamId, self.currentState); end;
function setcurrentStateEvent.sendEvent(vehicle, currentState, noEventSend) if noEventSend == nil or noEventSend == false then
	if g_server ~= nil then	g_server:broadcastEvent(setcurrentStateEvent:new(vehicle, currentState), nil, nil, vehicle);
	else g_client:getServerConnection():sendEvent(setcurrentStateEvent:new(vehicle, currentState)); end; end; end;