print();

local modDirectory = g_currentModDirectory

function onLoadMapFinished(mission, node)
	local priceonion = g_fillTypeManager:getFillTypeByName("MAIZE").pricePerLiter
	
	
	if node ~= 0 then
	
	local onionHudFile = "Paletten/hud_fill_onion.dds"
	local onionHudFileSmall = "Paletten/hud_fill_onion_smal.dds"
	
    local onionFilType = g_fillTypeManager:addFillType("ONION", g_i18n:getText("onion"), true, priceonion * 0.8, 0.00045, math.rad(10), onionHudFile, onionHudFileSmall,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 hasonion=false	
	
	
	local object=id
	if object == nil then
	else
	hasmaize =false
	hasonion=false
	
	
	for i,filltype in pairs(object.acceptedFillTypes) do
	local fillname=g_fillTypeManager.indexToName[i]
		if fillname == "MAIZE" then
		hasmaize=true
	end;
		if fillname == "ONION" then
		hasonion=true
	end;
		
end;

		if hasmaize and not hasonion then
		local filltypen = g_fillTypeManager:getFillTypeIndexByName("ONION")
		local price = g_fillTypeManager:getFillTypeByName("ONION").pricePerLiter
			object:addAcceptedFillType(filltypen,price,true,false)
			object.priceMultipliers[ g_fillTypeManager:getFillTypeIndexByName("ONION")]=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)