print();

local modDirectory = g_currentModDirectory

function onLoadMapFinished(mission, node)
	local pricecaffeine = g_fillTypeManager:getFillTypeByName("MAIZE").pricePerLiter
	
	
	if node ~= 0 then
	
	local caffeineHudFile = "Paletten/hud_fill_caffeine.dds"
	local caffeineHudFileSmall = "Paletten/hud_fill_caffeine_small.dds"
	
    local caffeineFilType = g_fillTypeManager:addFillType("CAFFEINE", g_i18n:getText("caffeine"), true, pricecaffeine * 2.2, 0.00045, math.rad(40), caffeineHudFile, caffeineHudFileSmall,modDirectory, nil, { 1, 1, 1 }, nil, false)
	 
	g_currentMission.hud.fillLevelsDisplay:refreshFillTypes(g_fillTypeManager)
	end;
end;

function load(id, xmlFile, key,customEnvironment)
	local hasmaize =false
	local hascaffeine=false	
	
	
	local object=id
	if object == nil then
	else
	hasmaize =false
	hascaffeine=false
	
	
	for i,filltype in pairs(object.acceptedFillTypes) do
	local fillname=g_fillTypeManager.indexToName[i]
		if fillname == "MAIZE" then
		hasmaize=true
	end;
		if fillname == "CAFFEINE" then
		hascaffeine=true
	end;
	   
end;

		if hasmaize and not hascaffeine then
		local filltypen = g_fillTypeManager:getFillTypeIndexByName("CAFFEINE")
		local price = g_fillTypeManager:getFillTypeByName("CAFFEINE").pricePerLiter
			object:addAcceptedFillType(filltypen,price,true,false)
			object.priceMultipliers[ g_fillTypeManager:getFillTypeIndexByName("CAFFEINE")]=object.priceMultipliers[ g_fillTypeManager:getFillTypeIndexByName("MAIZE")]
			object:initPricingDynamics()
		end;
		
	end;
end;

FSBaseMission.loadMapFinished = Utils.prependedFunction(FSBaseMission.loadMapFinished, onLoadMapFinished)
SellingStation.load = Utils.appendedFunction(SellingStation.load, load)