Zaehler = {};


function Zaehler.prerequisitesPresent(specializations)
    
	return true;

end;

function Zaehler:load(xmlFile)
	self.Zaehler = Overlay:new("ZaehlerOverlay", Utils.getFilename("Textur/Zaehler.dds", self.baseDirectory), 0.754, 0.212, 0.118, 0.04);

	
self.Balle_neu = 0;	
	self.Balle_alt = 0;
	


end;



function Zaehler:getSaveAttributesAndNodes(nodeIdent)
	
	local attributes = 'Balle_neu="'.. tostring(self.Balle_neu) ..'"';	
	return attributes, nil;

end;



function Zaehler:loadFromAttributesAndNodes(xmlFile, key, resetVehicles)
		
	self.Balle_neu = Utils.getNoNil(getXMLInt(xmlFile, key.."#Balle_neu"), 0);
		
end;


function Zaehler:delete()
	
	if self.Zaehler ~= nil then
		self.Zaehler:delete();
	end;

end;

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

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

end;



function Zaehler:update(dt)	
	if table.getn(self.bales) > self.Balle_alt then		
		self.Balle_neu = self.Balle_neu + 1;
	
		self.Balle_alt = self.Balle_alt + 1;		
	elseif table.getn(self.bales) < self.Balle_alt then
	
		self.Balle_alt = self.Balle_alt - 1;
	
	end;	
	if self:getIsActive() then
    		if InputBinding.hasEvent(InputBinding.Reset) then

			
self.Balle_neu = 0;
    		end;
    	end;
end;
function Zaehler:readStream(streamId, connection) 
     self.Balle_neu = streamReadInt32(streamId) 
end;

function Zaehler:writeStream(streamId, connection) 
    streamWriteInt32(streamId, self.Balle_neu);
 
end;
	

function Zaehler:draw()
			
	self.Zaehler:render();
	
	setTextAlignment(RenderText.ALIGN_RIGHT);
	
	setTextBold(true);	

	setTextColor(1, 1, 1, 1);
	
	renderText(0.833, 0.22, 0.022, tostring(self.Balle_neu));		

	if self:getIsActive() then	
                g_currentMission:addHelpButtonText(g_i18n:getText("Reset"), InputBinding.Reset);
	end;
end;
