print("Register filltypes: OnionGreenHaus By TWD Modding");

local modDirectory = g_currentModDirectory

function onLoadMapFinished(mission, node)
	local priceWheatdried= g_fillTypeManager:getFillTypeByName("POTATO").pricePerLiter
	
	if node ~= 0 then
	
	local wheatdriedHudFile = "hud/hud_fill_onion.dds"
         local wheatdriedHudFileSmall = "hud/hud_fill_onion_sml.dds"

	local wheatdriedFilType = g_fillTypeManager:addFillType("ONION", g_i18n:getText("onion"), true, priceWheatdried * 10.0, 0.00045, math.rad(40), wheatdriedHudFile, wheatdriedHudFileSmall,modDirectory, nil, { 1, 1, 1 }, nil, false)

	g_currentMission.hud.fillLevelsDisplay:refreshFillTypes(g_fillTypeManager)
	end;
end;

function load(id, xmlFile, key,customEnvironment)

	local haswheatdried=false
	local hassugar=false	
	
	local object=id
	if object == nil then
	else
	haswheatdried=false
	hassugar=false	
	
	for i,filltype in pairs(object.acceptedFillTypes) do
	local fillname=g_fillTypeManager.indexToName[i]
		if fillname == "POTATO" then
		haswheatdried=true
	end;
		if fillname == "ONION" then
		hassugar=true
	end;
end;

		if  haswheatdried and not hassugar 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("POTATO")]
			object:initPricingDynamics()
		end;
	end;
end;

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