--
-- Mod: FS19_RealLifeNumbers by Kaj-Aage Henneberg "Ki", ArmChairFarming
-- Script: RealNumbersSpraying by Kaj-Aage Henneberg "Ki", ArmChairFarming
-- e-mail: kaj-aage.henneberg@outlook.dk
-- Download: www.modhoster.com
-- All rights reserved.
-- Version 1.1.4.0
-- 30.11.2018 - 29.06.2019

-- Names for FillTypes

-- WHEAT BARLEY OAT CANOLA SUNFLOWER SOYBEAN MAIZE POTATO SUGARBEET OILSEEDRADISH
-- MANURE SEEDS FORAGE FORAGE_MIXING CHAFF WOODCHIPS SILAGE
-- STRAW GRASS_WINDROW DRYGRASS_WINDROW SUGARCANE FERTILIZER PIGFOOD LIME
-- WOOL TREESAPLINGS EGG
-- MILK FUEL WATER DIESEL DEF
-- LIQUIDFERTILIZER HERBICIDE
-- CHAFF GRASS_WINDROW
-- LIQUIDMANURE DIGESTATE
-- COW_TYPE_BRAHMAN_GREY COW_TYPE_BRAHMAN_LIGHT_BROWN COW_TYPE_BRAHMAN_WHITE COW_TYPE_BRAHMAN_BROWN
-- COW_TYPE_BROWN COW_TYPE_BROWN_WHITE COW_TYPE_BLACK COW_TYPE_BLACK_WHITE
-- SHEEP_TYPE_WHITE SHEEP_TYPE_BROWN SHEEP_TYPE_BLACK_WHITE SHEEP_TYPE_BLACK
-- PIG_TYPE_RED PIG_TYPE_WHITE PIG_TYPE_BLACK_WHITE PIG_TYPE_BLACK
-- CHICKEN_TYPE_BLACK CHICKEN_TYPE_WHITE CHICKEN_TYPE_BROWN CHICKEN_TYPE_ROOSTER

--[[

	Version 1.1 is a complete redesign of the code. It now aims to be used in cooperation with the mod VariableSprayUsage, which 
	allows the user to adjust the spray rate wen driving in the fields. Together, the two mods allow the user to apply spray
	types at different rates to different crops.
	

Crop nutrient need

	The strategy of this script is to add as much nutrient as is taken up by the crops and removed from the field at harvest.
	A crop's uptake of nutrients (nitrogen (N), phospate (P), and potassium (K)) depends on the yield of each crop. Data for nutrient
	uptake is taken from a USDA database, where the uptake per mass is dependent on moisture content in the crop. Linear regression
	was used to obtain a moisture scaling model, so that the mod user can change the moisture content of the crop, if so desired.
	Many countries, but not all, require N, P and K to be listed in specific forms, such as N, P2O5, and K2O. This convention is used
	in this script.

	The script writes a table to the log file with the NPK needs for each defined fruit. If a map has extra fruits, which have not 
	been defined in RealNumbersInitializtion, their NPK needs will an average need.

NPK content in organic fertlizers

	If one were to use organic fertilizers (slurry, manure, and digestate) to cover the total need for NPK replacement, one would
	need many tank loads per hectar. For this reason a parameter (nutrient.organicFertilizerFraction) is used to split the applied
	fertilizer between organic and artificial. The default split is 30% organic and 70% artificial. This plit ratio can be changed
	by the mod user. This approach implies that the first application of NPK is by an organic source and the second by an artificial
	fertilizer.

	The NPK content of organic fertilizers varies. In FS we have five types available: pig slurry, cow slurry, pig manure, cow manure,
	and digestate (from silage fermentation). For slurry and manure, the mod user can set a mixing ratio betwwen pig and cow wastes:


	If your slurry and manure productions are dominated by one type of animal, you can change the two fractions. Information about
	your annual slurry and manure production is provided in log print-outs from another script: RealNumbersAnimalCare.

	Far from all nutrients in a fertilizer is aborbed by the crop. The uptake fraction varies both between the nutients (N, P, K) and between
	the types and sources of organic fertilizers (slurry/manure, pig/cow). This is included in the script by parameters as shown here:

	nutrient.pigSlurryNCropAvailability = 0.55;
	nutrient.pigSlurryPCropAvailability = 0.50;
	nutrient.pigSlurryKCropAvailability = 0.90;
	nutrient.cowManureNCropAvailability = 0.10;
	nutrient.cowManurePCropAvailability = 0.60;
	nutrient.cowManureKCropAvailability = 0.90;

	It is seen that the N utilization from cow manure is particularly low, due to gasseous nitrogen release to the air.

	Using the mixing ratios and the crop-availablility paramters, the script defines the NPK content in a representative slurry/manure.

Nutrients delivered

	The script writes a table to the log file, listing how much of N, P, and K is needed for each fruit type. FS19 does not have
	individual sources of N, P, and K, hence a mix is required. A weight average application need is therefore also printed. The
	cost for each fertilizer type per hectare is also printed, assuming the weighted application rate. The user can adjust the weights
	to make the mix more influenced by one of the three nutrients.

	The amount of liquid fertilizer needed is about half of that for solid fertilizer, as the nutrients come in closer contact with the plants.
	This is included in the script using the parameter (liqfert.liquidReductionFactor = 2).

	Liquid fertilizers can be diluted with water for the sprayer to work effectively at very low nozzle flow rates. The spray rate parameter 
	must take this into account.
	The script provides a parameter (liqfert.dilutionFactor) to set the dilution factor. From ver. 1.1.3 it is set so that 1 Liter of liquid fertilizer is
	diluted to a 1 Liter solution (no dilution).

Lime application

	Lime is spread to raise the pH of the soil. How much to spread depends on (1) how much the pH needs to be rised, (2) on the soil type,
	and (3) on the lime source.

	The script allows the user to define these parameters:

	soil.Type = 1;				 		-- 1: Sands and loamy sands: 2: Sandy loams and silt loam; 3: Clay loams and clay
	soil.currentpH = 6;
	soil.targetpH = 6.7;
	lime.NV = 50;  				 		-- (NV = Neutralizing Value) concentration of calcium in lime material, 0 - 100

Herbicide application

	Herbicides are sprayed to kill weeds. In this script, the default amount is 2 kg/ha, but this can be changed by the mod user.
	Herbicides are usually diluted with water and sprayed with a liquid fertilizer sprayer. In the script the default dilution is set
	by the parameter:

	herbicide.dilutionFactor = 200;		-- 1 liter of herbicide to 200 liter of water

]]--

RealNumbersSpraying = {};

function myPrintSprayInfo(crop, textWidth, Moisture, N, P, K)
	local text = crop..string.rep(" ",textWidth-string.len(crop))
	print(string.format("%s: Moisture pct = %7.1f, N = %7.1f kg/ha, P2O5 = %7.1f kg/ha, K2O = %7.1f kg/ha", text, Moisture, N, P, K));
end;
function myPrintSprayInfo2(crop, textWidth, N, P, K)
	local text = crop..string.rep(" ",textWidth-string.len(crop))
	print(string.format("%s: N = %7.1f kg/ha, P2O5 = %7.1f kg/ha, K2O = %7.1f kg/ha", text, N, P, K));
end;
function myPrintSprayInfo3(crop, textWidth, unit, S1, S2, S3, S4, S5, S6, S7, S8)
	local text = crop..string.rep(" ",textWidth-string.len(crop))
	print(string.format("%s: %s %7.2f %7.2f %7.2f %7.2f %7.2f %7.2f %7.2f %7.2f", text, unit, S1, S2, S3, S4, S5, S6, S7, S8));
end;
function myPrintSprayInfo4(crop, textWidth, unit, S1, S2, S3, S4, S5, S6, S7, S8)
	local text = crop..string.rep(" ",textWidth-string.len(crop))
	print(string.format("%s: %s %7.0f %7.0f %7.0f %7.0f %7.0f %7.0f %7.0f %7.0f", text, unit, S1, S2, S3, S4, S5, S6, S7, S8));
end;
function myPrintNutrientContent(source, textWidth, N, P, K)
	local text = source..string.rep(" ",textWidth-string.len(source))
	print(string.format("%s: N = %5.1f kg/Tonne, P2O5 = %5.1f kg/Tonne, K2O = %5.1f kg/Tonne", text, N, P, K));
end;
function myPrintNutrientContent2(source, textWidth, N, P, K)
	local text = source..string.rep(" ",textWidth-string.len(source))
	print(string.format("%s: N = %7.0f   L/Ha    , P2O5 = %7.0f   L/Ha    , K2O = %7.0f   L/Ha    ", text, N, P, K));
end;


function RealNumbersSpraying:loadMap()
	local currency = " ";
	local isDebug = RN.isDebug;
	local isDebug2 = false;
	local idx = 0;



    local textWidth = 15;
    local textWidth2 = 27;
	local textWidth3 = 40;
	local nutrient = {};												--parameters for nutrient content in crops and fertilizers
	local slurry = {};													--parameters for slurry sprayers
	local manure = {};													--parameters for manure spreader
	local digestate = {};												--parameters for digestate sprayers
	local fertilizer = {};												--parameters for fertilizer spreader
	local liqfert = {};													--parameters for liquid fertilizer sprayer
	local lime = {};													--parameters for lime spreader
	local herbicide = {};												--parameters for herbicide sprayer
	local soil = {};
	local Fruits = RN.fruits;
	local Density = RN.cropDensity;
	local Yield = RN.cropYield;
	local sprayNames =  RN.sprayNames;
	local sprayTypeDensity = RN.sprayTypeDensity;
	local sprayRates = {};		
	local calibrationTime = 30;											--Time duration of calibration run.

	RN.NCropAvailability = {};
	RN.PCropAvailability = {};
	RN.KCropAvailability = {};

	RN.sprayLitersPerHa = {};
	RN.sprayCost = {};

	nutrient.slurryDensity = RN.sprayTypeDensity[4];					-- kg/Liter
	nutrient.manureDensity = RN.sprayTypeDensity[3];					-- kg/Liter
	nutrient.digestateDensity = RN.sprayTypeDensity[5]; 				-- kg/Liter
	nutrient.pigSlurryFraction = RN.pigSlurryFraction;					-- fraction of slurry spread on fields originating from pigs
	nutrient.cowSlurryFraction = 1 - nutrient.pigSlurryFraction;		-- fraction of slurry spread on fields originating from cows
	nutrient.pigManureFraction = RN.pigManureFraction;					-- fraction of manure spread on fields originating from pigs
	nutrient.cowManureFraction = 1 - nutrient.pigManureFraction;		-- fraction of manure spread on fields originating from cows
	nutrient.organicFertilizerFraction = RN.organicFertilizerFraction;	-- fraction of fertilizer spread on fields originating from organic sources
	nutrient.artificialNFraction = 30/100;								-- NPK ratio 30:8:10
	nutrient.artificialPFraction = 8/100;								-- NPK ratio 30:8:10
	nutrient.artificialKFraction = 10/100;								-- NPK ratio 30:8:10
	liqfert.dilutionFactor = RN.liqfertDilutionFactor;					-- 1 Liter of liquid fertilizer is diluted to x liter of solution
	liqfert.liquidReductionFactor = RN.liqfertLiquidReductionFactor;	-- liquid fertilizer is needed in smaller dosis due to better uptake
	herbicide.dilutionFactor = RN.herbicideDilutionFactor;				-- 1 liter of herbicide to x liter of water
													-- Volume of sprayTypes per hectare

	local gameMoneyUnit = g_i18n.moneyUnit;
	if gameMoneyUnit == 1 then
        currency = "€";
	elseif gameMoneyUnit == 2 then
        currency = "$";
	elseif gameMoneyUnit == 3 then
        currency = "£";
	end


	print("FS19_RealLifeNumbers: RealNumbersSpraying active")

	if isDebug then
		print("\nAmount of N, P and K fertilzer removed from the field at harvest. \nDepends on crop yield and crop moisture concent.");
		print("Extra crops will have zero values if NPK needs are not defined in RealLifeNumbersInitialization.lua\n");
	end;

-- Summing up crop need to calcule mean value

	local NSum = 0;
	local PSum = 0;
	local KSum = 0;
	local counter = 0;

--	for i, v in pairs(g_currentMission.fruitTypeManager.fruitTypes) do
--		local fruitName = g_currentMission.fruitTypeManager.fruitTypes[i].name;
	for i,fruitName in ipairs(RN.sortedFruits) do
		iFillType = g_fillTypeManager:getFillTypeIndexByName(tostring(fruitName));
		iFruitType = g_fruitTypeManager:getFruitTypeIndexByFillTypeIndex(iFillType);
		if Fruits[fruitName] == nil then 		-- for undefined fruitTypes
			RN.Nitrogen[fruitName]  = 0;	-- kg/ha Nitrogen
			RN.Phosphate[fruitName]  = 0;	-- kg/ha Nitrogen
			RN.Potassium[fruitName] = 0;	-- kg/ha Nitrogen
		end;
		if isDebug then myPrintSprayInfo2(fruitName, textWidth, RN.Nitrogen[fruitName], RN.Phosphate[fruitName], RN.Potassium[fruitName]); end;
		if RN.Nitrogen[fruitName]  > 0 then
			NSum = NSum + RN.Nitrogen[fruitName];
			PSum = PSum + RN.Phosphate[fruitName];
			KSum = KSum + RN.Potassium[fruitName];
			counter = counter + 1;
		end;
	end;

-- WHEAT STRAW

	fruitName = "WHEAT";
	nutrient.wheatStrawNslope = -0.0000980;								-- moisture dependency parameters
	nutrient.wheatStrawPslope = -0.0000224;
	nutrient.wheatStrawKslope = -0.0002179;
	nutrient.wheatStrawNintercept = 0.0098015;
	nutrient.wheatStrawPintercept = 0.002244;
	nutrient.wheatStrawKintercept = 0.0217827;
	nutrient.wheatStrawMoisture = 9.22;
	nutrient.wheatStrawNtakeoutPerKg = (nutrient.wheatStrawNintercept + nutrient.wheatStrawNslope * nutrient.wheatStrawMoisture);
	nutrient.wheatStrawPtakeoutPerKg = (nutrient.wheatStrawPintercept + nutrient.wheatStrawPslope * nutrient.wheatStrawMoisture);
	nutrient.wheatStrawKtakeoutPerKg = (nutrient.wheatStrawKintercept + nutrient.wheatStrawKslope * nutrient.wheatStrawMoisture);
	nutrient.wheatStrawNtakeout = nutrient.wheatStrawNtakeoutPerKg * RN.windrowYieldkgPerHa[fruitName];
	nutrient.wheatStrawPtakeout = nutrient.wheatStrawPtakeoutPerKg * RN.windrowYieldkgPerHa[fruitName];
	nutrient.wheatStrawKtakeout = nutrient.wheatStrawKtakeoutPerKg * RN.windrowYieldkgPerHa[fruitName];
	if isDebug then myPrintSprayInfo2("WHEAT STRAW", textWidth, nutrient.wheatStrawNtakeout, nutrient.wheatStrawPtakeout, nutrient.wheatStrawKtakeout); end;
	NSum = NSum + nutrient.wheatStrawNtakeout;
	PSum = PSum + nutrient.wheatStrawPtakeout;
	KSum = KSum + nutrient.wheatStrawKtakeout;
	counter = counter + 1;

-- BARLEY STRAW

	fruitName = "BARLEY";
	nutrient.barleyStrawNslope = -0.0001029;							-- moisture dependency parameters
	nutrient.barleyStrawPslope = -0.0000328;
	nutrient.barleyStrawKslope = -0.0003256;
	nutrient.barleyStrawNintercept = 0.0102879;
	nutrient.barleyStrawPintercept = 0.0032819;
	nutrient.barleyStrawKintercept = 0.0325517;
	nutrient.barleyStrawMoisture = 11.25;
	nutrient.barleyStrawNtakeoutPerKg = (nutrient.barleyStrawNintercept + nutrient.barleyStrawNslope * nutrient.barleyStrawMoisture);
	nutrient.barleyStrawPtakeoutPerKg = (nutrient.barleyStrawPintercept + nutrient.barleyStrawPslope * nutrient.barleyStrawMoisture);
	nutrient.barleyStrawKtakeoutPerKg = (nutrient.barleyStrawKintercept + nutrient.barleyStrawKslope * nutrient.barleyStrawMoisture);
	nutrient.barleyStrawNtakeout = nutrient.barleyStrawNtakeoutPerKg * RN.windrowYieldkgPerHa[fruitName];
	nutrient.barleyStrawPtakeout = nutrient.barleyStrawPtakeoutPerKg * RN.windrowYieldkgPerHa[fruitName];
	nutrient.barleyStrawKtakeout = nutrient.barleyStrawKtakeoutPerKg * RN.windrowYieldkgPerHa[fruitName];
	if isDebug then myPrintSprayInfo2("BARLEY STRAW", textWidth, nutrient.barleyStrawNtakeout, nutrient.barleyStrawPtakeout, nutrient.barleyStrawKtakeout); end;
	NSum = NSum + nutrient.barleyStrawNtakeout;
	PSum = PSum + nutrient.barleyStrawPtakeout;
	KSum = KSum + nutrient.barleyStrawKtakeout;
	counter = counter + 1;

-- OAT STRAW

	fruitName = "OAT";
	nutrient.oatStrawNslope = -0.0000914;								-- moisture dependency parameters
	nutrient.oatStrawPslope = -0.0000251;
	nutrient.oatStrawKslope = -0.0003738;
	nutrient.oatStrawNintercept = 0.0091328;
	nutrient.oatStrawPintercept = 0.0025173;
	nutrient.oatStrawKintercept = 0.0373824;
	nutrient.oatStrawMoisture = 9.68;
	nutrient.oatStrawNtakeoutPerKg = (nutrient.oatStrawNintercept + nutrient.oatStrawNslope * nutrient.oatStrawMoisture);
	nutrient.oatStrawPtakeoutPerKg = (nutrient.oatStrawPintercept + nutrient.oatStrawPslope * nutrient.oatStrawMoisture);
	nutrient.oatStrawKtakeoutPerKg = (nutrient.oatStrawKintercept + nutrient.oatStrawKslope * nutrient.oatStrawMoisture);
	nutrient.oatStrawNtakeout = nutrient.oatStrawNtakeoutPerKg * RN.windrowYieldkgPerHa[fruitName];
	nutrient.oatStrawPtakeout = nutrient.oatStrawPtakeoutPerKg * RN.windrowYieldkgPerHa[fruitName];
	nutrient.oatStrawKtakeout = nutrient.oatStrawKtakeoutPerKg * RN.windrowYieldkgPerHa[fruitName];
	if isDebug then myPrintSprayInfo2("OAT STRAW", textWidth, nutrient.oatStrawNtakeout, nutrient.oatStrawPtakeout, nutrient.oatStrawKtakeout); end;
	NSum = NSum + nutrient.oatStrawNtakeout;
	PSum = PSum + nutrient.oatStrawPtakeout;
	KSum = KSum + nutrient.oatStrawKtakeout;
	counter = counter + 1;
	local NMean = NSum/counter;
	local PMean = PSum/counter;
	local KMean = KSum/counter;
	if isDebug then print(" ");end;
	if isDebug then myPrintSprayInfo2("Mean values", textWidth,  NMean, PMean, KMean); end;

	RN.Nitrogen.UNDEFINED 	= NMean;	-- to use for extra fruits not defined in the mod
	RN.Phosphate.UNDEFINED 	= PMean;	-- to use for extra fruits not defined in the mod
	RN.Potassium.UNDEFINED 	= KMean;	-- to use for extra fruits not defined in the mod



	if isDebug then print("\n------------Fertilizer nutrient content------------\n"); end;

	local sprayType 		     = {"FERTILIZER","LIQUIDFERTILIZER","pigMANURE","cowMANURE","pigLIQUIDMANURE","cowLIQUIDMANURE","DIGESTATE","COMPOST","LIME","HERBICIDE"};
	local sprayTypeDensity 	     = {    0.8,           0.9,             0.6,        0.6,           0.9,             0.9,            0.9,        0.83,   1.2,      1.0   };
	local sprayCalibrationFactor = {      1,             1,               1,          1,             1,               1,              1,           1,     1,        1   };

	RN.NPerTonne = {};
	RN.PPerTonne = {};
	RN.KPerTonne = {};
	RN.NCropAvailability = {};
	RN.PCropAvailability = {};
	RN.KCropAvailability = {};

	RN.NPerTonne.FERTILIZER = 140;	-- kg/Tonne
	RN.PPerTonne.FERTILIZER =  70;	-- kg/Tonne
	RN.KPerTonne.FERTILIZER = 140;	-- kg/Tonne

	RN.NPerTonne.LIQUIDFERTILIZER = 300;	-- kg/Tonne
	RN.PPerTonne.LIQUIDFERTILIZER =  80;	-- kg/Tonne
	RN.KPerTonne.LIQUIDFERTILIZER = 100;	-- kg/Tonne

	RN.NPerTonne.pigLIQUIDMANURE = 3.600;	-- kg/Tonne
	RN.PPerTonne.pigLIQUIDMANURE = 1.500;	-- kg/Tonne
	RN.KPerTonne.pigLIQUIDMANURE = 2.200;	-- kg/Tonne

	RN.NPerTonne.cowLIQUIDMANURE = 2.600;	-- kg/Tonne
	RN.PPerTonne.cowLIQUIDMANURE = 1.200;	-- kg/Tonne
	RN.KPerTonne.cowLIQUIDMANURE = 2.500;	-- kg/Tonne

	RN.NPerTonne.pigMANURE = 7.000;	-- kg/Tonne
	RN.PPerTonne.pigMANURE = 6.000;	-- kg/Tonne
	RN.KPerTonne.pigMANURE = 8.000;	-- kg/Tonne

	RN.NPerTonne.cowMANURE = 6.000;	-- kg/Tonne
	RN.PPerTonne.cowMANURE = 3.200;	-- kg/Tonne
	RN.KPerTonne.cowMANURE = 9.400;	-- kg/Tonne

	RN.NPerTonne.DIGESTATE = 4.900;	-- kg/Tonne
	RN.PPerTonne.DIGESTATE = 1.100;	-- kg/Tonne
	RN.KPerTonne.DIGESTATE = 3.500;	-- kg/Tonne
	
	RN.NPerTonne.COMPOST = RN.kgNPerTonneCompost;	-- kg/Tonne Set in RealNumbersInitiaization.lua
	RN.PPerTonne.COMPOST = RN.kgPPerTonneCompost;	-- kg/Tonne Set in RealNumbersInitiaization.lua
	RN.KPerTonne.COMPOST = RN.kgKPerTonneCompost;	-- kg/Tonne Set in RealNumbersInitiaization.lua
	
	RN.NPerTonne.LIME = 0.000;	-- kg/Tonne
	RN.PPerTonne.LIME = 0.000;	-- kg/Tonne
	RN.KPerTonne.LIME = 0.000;	-- kg/Tonne

	RN.NPerTonne.HERBICIDE = 0.000;	-- kg/Tonne
	RN.PPerTonne.HERBICIDE = 0.000;	-- kg/Tonne
	RN.KPerTonne.HERBICIDE = 0.000;	-- kg/Tonne

	RN.NCropAvailability.FERTILIZER = 0.80;
	RN.PCropAvailability.FERTILIZER = 0.80;
	RN.KCropAvailability.FERTILIZER = 0.90;

	RN.NCropAvailability.LIQUIDFERTILIZER = 0.95;
	RN.PCropAvailability.LIQUIDFERTILIZER = 0.95;
	RN.KCropAvailability.LIQUIDFERTILIZER = 0.95;

	RN.NCropAvailability.pigLIQUIDMANURE = 0.55;
	RN.PCropAvailability.pigLIQUIDMANURE = 0.50;
	RN.KCropAvailability.pigLIQUIDMANURE = 0.90;

	RN.NCropAvailability.cowLIQUIDMANURE = 0.40;
	RN.PCropAvailability.cowLIQUIDMANURE = 0.60;
	RN.KCropAvailability.cowLIQUIDMANURE = 0.90;

	RN.NCropAvailability.pigMANURE = 0.15;
	RN.PCropAvailability.pigMANURE = 0.60;
	RN.KCropAvailability.pigMANURE = 0.90;

	RN.NCropAvailability.cowMANURE = 0.10;
	RN.PCropAvailability.cowMANURE = 0.60;
	RN.KCropAvailability.cowMANURE = 0.90;

	RN.NCropAvailability.DIGESTATE = 0.55;
	RN.PCropAvailability.DIGESTATE = 0.60;
	RN.KCropAvailability.DIGESTATE = 0.90;
	
	RN.NCropAvailability.COMPOST = 0.55;
	RN.PCropAvailability.COMPOST = 0.60;
	RN.KCropAvailability.COMPOST = 0.90;

	RN.NAvailablePerTonne = {};
	RN.PAvailablePerTonne = {};
	RN.KAvailablePerTonne = {};

	RN.NAvailablePerTonne.FERTILIZER = RN.NCropAvailability.FERTILIZER * RN.NPerTonne.FERTILIZER; -- kg/Tonne
	RN.PAvailablePerTonne.FERTILIZER = RN.PCropAvailability.FERTILIZER * RN.PPerTonne.FERTILIZER; -- kg/Tonne
	RN.KAvailablePerTonne.FERTILIZER = RN.KCropAvailability.FERTILIZER * RN.KPerTonne.FERTILIZER; -- kg/Tonne
	if isDebug then myPrintNutrientContent("FERTILIZER", textWidth2, RN.NPerTonne.FERTILIZER, RN.PPerTonne.FERTILIZER, RN.KPerTonne.FERTILIZER);  end;
	if isDebug then myPrintNutrientContent("FERTILIZER crop av.", textWidth2, RN.NAvailablePerTonne.FERTILIZER, RN.PAvailablePerTonne.FERTILIZER, RN.KAvailablePerTonne.FERTILIZER);  end;
	
	RN.NAvailablePerTonne.LIQUIDFERTILIZER = RN.NCropAvailability.LIQUIDFERTILIZER * RN.NPerTonne.LIQUIDFERTILIZER; -- kg/Tonne
	RN.PAvailablePerTonne.LIQUIDFERTILIZER = RN.PCropAvailability.LIQUIDFERTILIZER * RN.PPerTonne.LIQUIDFERTILIZER; -- kg/Tonne
	RN.KAvailablePerTonne.LIQUIDFERTILIZER = RN.KCropAvailability.LIQUIDFERTILIZER * RN.KPerTonne.LIQUIDFERTILIZER; -- kg/Tonne
	if isDebug then myPrintNutrientContent("LIQUIDFERTILIZER", textWidth2, RN.NPerTonne.LIQUIDFERTILIZER, RN.PPerTonne.LIQUIDFERTILIZER, RN.KPerTonne.LIQUIDFERTILIZER);  end;
	if isDebug then myPrintNutrientContent("LIQUIDFERTILIZER crop av.", textWidth2, RN.NAvailablePerTonne.LIQUIDFERTILIZER, RN.PAvailablePerTonne.LIQUIDFERTILIZER, RN.KAvailablePerTonne.LIQUIDFERTILIZER);  end;

	RN.NAvailablePerTonne.pigLIQUIDMANURE = RN.NCropAvailability.pigLIQUIDMANURE * RN.NPerTonne.pigLIQUIDMANURE; -- kg/Tonne
	RN.PAvailablePerTonne.pigLIQUIDMANURE = RN.PCropAvailability.pigLIQUIDMANURE * RN.PPerTonne.pigLIQUIDMANURE; -- kg/Tonne
	RN.KAvailablePerTonne.pigLIQUIDMANURE = RN.KCropAvailability.pigLIQUIDMANURE * RN.KPerTonne.pigLIQUIDMANURE; -- kg/Tonne
	if isDebug then myPrintNutrientContent("pigLIQUIDMANURE", textWidth2, RN.NPerTonne.pigLIQUIDMANURE, RN.PPerTonne.pigLIQUIDMANURE, RN.KPerTonne.pigLIQUIDMANURE);  end;
	if isDebug then myPrintNutrientContent("pigLIQUIDMANURE crop av.", textWidth2, RN.NAvailablePerTonne.pigLIQUIDMANURE, RN.PAvailablePerTonne.pigLIQUIDMANURE, RN.KAvailablePerTonne.pigLIQUIDMANURE);  end;

	RN.NAvailablePerTonne.cowLIQUIDMANURE = RN.NCropAvailability.cowLIQUIDMANURE * RN.NPerTonne.cowLIQUIDMANURE; -- kg/Tonne
	RN.PAvailablePerTonne.cowLIQUIDMANURE = RN.PCropAvailability.cowLIQUIDMANURE * RN.PPerTonne.cowLIQUIDMANURE; -- kg/Tonne
	RN.KAvailablePerTonne.cowLIQUIDMANURE = RN.KCropAvailability.cowLIQUIDMANURE * RN.KPerTonne.cowLIQUIDMANURE; -- kg/Tonne
	if isDebug then myPrintNutrientContent("cowLIQUIDMANURE", textWidth2, RN.NPerTonne.cowLIQUIDMANURE, RN.PPerTonne.cowLIQUIDMANURE, RN.KPerTonne.cowLIQUIDMANURE);  end;
	if isDebug then myPrintNutrientContent("cowLIQUIDMANURE crop av.", textWidth2, RN.NAvailablePerTonne.cowLIQUIDMANURE, RN.PAvailablePerTonne.cowLIQUIDMANURE, RN.KAvailablePerTonne.cowLIQUIDMANURE);  end;

	RN.NAvailablePerTonne.pigMANURE = RN.NCropAvailability.pigMANURE * RN.NPerTonne.pigMANURE; -- kg/Tonne
	RN.PAvailablePerTonne.pigMANURE = RN.PCropAvailability.pigMANURE * RN.PPerTonne.pigMANURE; -- kg/Tonne
	RN.KAvailablePerTonne.pigMANURE = RN.KCropAvailability.pigMANURE * RN.KPerTonne.pigMANURE; -- kg/Tonne
	if isDebug then myPrintNutrientContent("pigMANURE", textWidth2, RN.NPerTonne.pigMANURE, RN.PPerTonne.pigMANURE, RN.KPerTonne.pigMANURE);  end;
	if isDebug then myPrintNutrientContent("pigMANURE crop av.", textWidth2, RN.NAvailablePerTonne.pigMANURE, RN.PAvailablePerTonne.pigMANURE, RN.KAvailablePerTonne.pigMANURE);  end;

	RN.NAvailablePerTonne.cowMANURE = RN.NCropAvailability.cowMANURE * RN.NPerTonne.cowMANURE; -- kg/Tonne
	RN.PAvailablePerTonne.cowMANURE = RN.PCropAvailability.cowMANURE * RN.PPerTonne.cowMANURE; -- kg/Tonne
	RN.KAvailablePerTonne.cowMANURE = RN.KCropAvailability.cowMANURE * RN.KPerTonne.cowMANURE; -- kg/Tonne
	if isDebug then myPrintNutrientContent("cowMANURE", textWidth2, RN.NPerTonne.cowMANURE, RN.PPerTonne.cowMANURE, RN.KPerTonne.cowMANURE);  end;
	if isDebug then myPrintNutrientContent("cowMANURE crop av.", textWidth2, RN.NAvailablePerTonne.cowMANURE, RN.PAvailablePerTonne.cowMANURE, RN.KAvailablePerTonne.cowMANURE);  end;

	RN.NAvailablePerTonne.DIGESTATE = RN.NCropAvailability.DIGESTATE * RN.NPerTonne.DIGESTATE; -- kg/Tonne
	RN.PAvailablePerTonne.DIGESTATE = RN.PCropAvailability.DIGESTATE * RN.PPerTonne.DIGESTATE; -- kg/Tonne
	RN.KAvailablePerTonne.DIGESTATE = RN.KCropAvailability.DIGESTATE * RN.KPerTonne.DIGESTATE; -- kg/Tonne
	if isDebug then myPrintNutrientContent("DIGESTATE", textWidth2, RN.NPerTonne.DIGESTATE, RN.PPerTonne.DIGESTATE, RN.KPerTonne.DIGESTATE);  end;
	if isDebug then myPrintNutrientContent("DIGESTATE crop av.", textWidth2, RN.NAvailablePerTonne.DIGESTATE, RN.PAvailablePerTonne.DIGESTATE, RN.KAvailablePerTonne.DIGESTATE);  end;
	
	RN.NAvailablePerTonne.COMPOST = RN.NCropAvailability.COMPOST * RN.NPerTonne.COMPOST; -- kg/Tonne
	RN.PAvailablePerTonne.COMPOST = RN.PCropAvailability.COMPOST * RN.PPerTonne.COMPOST; -- kg/Tonne
	RN.KAvailablePerTonne.COMPOST = RN.KCropAvailability.COMPOST * RN.KPerTonne.COMPOST; -- kg/Tonne
	if isDebug then myPrintNutrientContent("COMPOST", textWidth2, RN.NPerTonne.COMPOST, RN.PPerTonne.COMPOST, RN.KPerTonne.COMPOST);  end;
	if isDebug then myPrintNutrientContent("COMPOST crop av.", textWidth2, RN.NAvailablePerTonne.COMPOST, RN.PAvailablePerTonne.COMPOST, RN.KAvailablePerTonne.COMPOST);  end;


	RN.sprayDensity = {};
	RN.sprayDensity.FERTILIZER  		= RN.sprayTypeDensity[1];
	RN.sprayDensity.LIQUIDFERTILIZER 	= RN.sprayTypeDensity[2];
	RN.sprayDensity.pigMANURE  			= RN.sprayTypeDensity[3];
	RN.sprayDensity.cowMANURE  			= RN.sprayTypeDensity[3];
	RN.sprayDensity.COMPOST  			= RN.sprayTypeDensity[3];	
	RN.sprayDensity.pigLIQUIDMANURE  	= RN.sprayTypeDensity[4];	
	RN.sprayDensity.cowLIQUIDMANURE  	= RN.sprayTypeDensity[4];	
	RN.sprayDensity.DIGESTATE  			= RN.sprayTypeDensity[5];	
	RN.sprayDensity.LIME       			= RN.sprayTypeDensity[6];
	RN.sprayDensity.HERBICIDE  			= RN.sprayTypeDensity[7];
	
	RN.sprayCostPerTonne = {};
	RN.sprayCostPerTonne.FERTILIZER  			= 10 * RN.commodityPricePer100kg.FERTILIZER;		-- cost per tonne	
	RN.sprayCostPerTonne.LIQUIDFERTILIZER 		= 10 * RN.commodityPricePer100kg.LIQUIDFERTILIZER/liqfert.dilutionFactor;	-- cost per tonne
	RN.sprayCostPerTonne.pigMANURE  			= 10 * RN.commodityPricePer100kg.MANURE;			-- cost per tonne
	RN.sprayCostPerTonne.cowMANURE  			= 10 * RN.commodityPricePer100kg.MANURE;			-- cost per tonne
	RN.sprayCostPerTonne.COMPOST  				= 10 * RN.commodityPricePer100kg.COMPOST;			-- cost per tonne
	RN.sprayCostPerTonne.pigLIQUIDMANURE  		= 10 * RN.commodityPricePer100kg.LIQUIDMANURE;		-- cost per tonne	
	RN.sprayCostPerTonne.cowLIQUIDMANURE  		= 10 * RN.commodityPricePer100kg.LIQUIDMANURE;		-- cost per tonne	
	RN.sprayCostPerTonne.DIGESTATE  			= 10 * RN.commodityPricePer100kg.DIGESTATE;			-- cost per tonne
	RN.sprayCostPerTonne.LIME       			= 10 * RN.commodityPricePer100kg.LIME;				-- cost per tonne
	RN.sprayCostPerTonne.HERBICIDE  			= 10 * RN.commodityPricePer100kg.HERBICIDE/herbicide.dilutionFactor;			-- cost per tonne

	RN.NTonneSprayRate 		= {};
	RN.PTonneSprayRate 		= {};
	RN.KTonneSprayRate 		= {};
	RN.meanTonneSprayRate 	= {};
	RN.N1000LSprayRate 		= {};
	RN.P1000LSprayRate 		= {};
	RN.K1000LSprayRate 		= {};
	RN.mean1000LSprayRate 	= {};
	RN.sprayCostPerHa 	 	= {};
	RN.sprayCostPerLiter	= {};

-- LIME

	soil.Name = {"Sands and loamy sands", "Sandy loams and silt loam", "Clay loams and clay"};
	soil.Type = RN.soilType;				-- 1: Sands and loamy sands: 2: Sandy loams and silt loam; 3: Clay loams and clay
	soil.currentpH = RN.soilCurrentpH;
	soil.targetpH = RN.soilTargetpH;

	idx = 9;
	lime.factor = {6, 7, 8};
	lime.NV = RN.limeNV;  																	-- concentration of calcium in lime material, 0 - 100
	lime.kgPerHa = 1000 * 50 *(soil.targetpH - soil.currentpH)*lime.factor[soil.Type]/lime.NV;
	lime.LitersPerHa = lime.kgPerHa / RN.sprayDensity["LIME"];
	lime.LitersPerSqm = lime.LitersPerHa / 10000;
	lime.calibrationFactor = sprayCalibrationFactor[idx];
	sprayRates.LIME = lime.calibrationFactor * lime.LitersPerSqm/3.6;
	RN.sprayLitersPerHa.LIME = lime.LitersPerHa;

	if isDebug then
		print("\n---Lime---\n");
		myPrint("Lime kg per ha:", lime.kgPerHa,textWidth3, " kg/Ha");
		myPrint("Lime liter per ha:", lime.LitersPerHa,textWidth3, " L/Ha");
	end;

-- Herbicide

	idx = 10;
	herbicide.kgPerHa = RN.HerbicideKgPerHa;
	herbicide.LitersPerHa = herbicide.dilutionFactor * herbicide.kgPerHa / RN.commodityDensity.HERBICIDE;
	herbicide.LitersPerSqm = herbicide.LitersPerHa / 10000;
	herbicide.calibrationFactor = sprayCalibrationFactor[idx];
	sprayRates.HERBICIDE = herbicide.calibrationFactor * herbicide.LitersPerSqm/3.6;
	RN.sprayLitersPerHa.HERBICIDE = herbicide.LitersPerHa;
	RN.sprayCostPerLiter.HERBICIDE = RN.commodityDensity.HERBICIDE * RN.commodityPricePer100kg.HERBICIDE/(herbicide.dilutionFactor * 100);
	RN.sprayCostHERBICIDE = RN.sprayCostPerLiter.HERBICIDE * RN.sprayLitersPerHa.HERBICIDE; 		-- cost / ha

	if isDebug then
		print("\n---Herbicide---\n");
		myPrint("Herbicide kg per ha:", herbicide.kgPerHa,textWidth3, " kg/Ha");
		myPrint("Diluted herbicide liter per ha:", herbicide.LitersPerHa,textWidth3, " L/Ha");
		myPrint("Diluted herbicide cost per ha:", RN.sprayCostHERBICIDE,textWidth3, currency.."/Ha\n")
	end;


	if isDebug then
		print("\nApplication rates for different types of fertilizers\n");
		print("Fraction of fertilizer from organic sources: "..nutrient.organicFertilizerFraction); 
		print("Abbreviations for fertilizer types:");
		print("Fert: Solid fertilizer");
		print("LiFe: Liquid fertilizer, diluted with water");
		print("PiMa: Pig manure");
		print("CoMa: Cow manure");
		print("PiLi: Pig liquid manure");
		print("CoLi: Cow liquid manure");
		print("Dige: Digestate");
		print("Comp: Compost");
		print("W   : weighted application")
	end;

	
	
--	for i, v in pairs(g_currentMission.fruitTypeManager.fruitTypes) do
--		local fruitName = g_currentMission.fruitTypeManager.fruitTypes[i].name;
	for i,fruitName in ipairs(RN.sortedFruits) do
		iFillType = g_fillTypeManager:getFillTypeIndexByName(tostring(fruitName));
		iFruitType = g_fruitTypeManager:getFruitTypeIndexByFillTypeIndex(iFillType);

		if Fruits[fruitName] == nil then 		-- for undefined fruitTypes
			RN.Nitrogen[fruitName]  = RN.Nitrogen.UNDEFINED;	-- kg/ha Nitrogen
			RN.Phosphate[fruitName]  = RN.Phosphate.UNDEFINED;	-- kg/ha Nitrogen
			RN.Potassium[fruitName] = RN.Potassium.UNDEFINED;	-- kg/ha Nitrogen
		end;

		RN.NTonneSprayRate[fruitName]    = {};	-- create new rows
		RN.PTonneSprayRate[fruitName]    = {};
		RN.KTonneSprayRate[fruitName]    = {};
		RN.meanTonneSprayRate[fruitName] = {};
		RN.N1000LSprayRate[fruitName]    = {};
		RN.P1000LSprayRate[fruitName]    = {};
		RN.K1000LSprayRate[fruitName]    = {};
		RN.mean1000LSprayRate[fruitName] = {};
		RN.sprayCostPerHa[fruitName] 	 = {};

		for j = 1,8 do
			if j < 3 then
				fertWeight = 1 - RN.organicFertilizerFraction;
			else
				fertWeight = RN.organicFertilizerFraction;
			end;
			local diluteFactor = 1;
			if j == 2 then
				diluteFactor = RN.liqfertDilutionFactor / liqfert.liquidReductionFactor;
			end;
			RN.NTonneSprayRate[fruitName][sprayType[j]] = diluteFactor * fertWeight * RN.Nitrogen[fruitName] / RN.NAvailablePerTonne[sprayType[j]];	-- Tonne/ha for two applications
			RN.PTonneSprayRate[fruitName][sprayType[j]] = diluteFactor * fertWeight * RN.Phosphate[fruitName] / RN.PAvailablePerTonne[sprayType[j]];	-- Tonne/ha for two applications
			RN.KTonneSprayRate[fruitName][sprayType[j]] = diluteFactor * fertWeight * RN.Potassium[fruitName] / RN.KAvailablePerTonne[sprayType[j]];	-- Tonne/ha for two applications
			RN.meanTonneSprayRate[fruitName][sprayType[j]] = (RN.Nweight * RN.NTonneSprayRate[fruitName][sprayType[j]] 
															+ RN.Pweight * RN.PTonneSprayRate[fruitName][sprayType[j]] 
															+ RN.Kweight * RN.KTonneSprayRate[fruitName][sprayType[j]]);

			RN.sprayCostPerHa[fruitName][sprayType[j]] = 	RN.meanTonneSprayRate[fruitName][sprayType[j]] * RN.sprayCostPerTonne[sprayType[j]];										

			RN.N1000LSprayRate[fruitName][sprayType[j]] = RN.NTonneSprayRate[fruitName][sprayType[j]] / RN.sprayDensity[sprayType[j]];			-- 1000 L/ha
			RN.P1000LSprayRate[fruitName][sprayType[j]] = RN.PTonneSprayRate[fruitName][sprayType[j]] / RN.sprayDensity[sprayType[j]];			-- 1000 L/ha
			RN.K1000LSprayRate[fruitName][sprayType[j]] = RN.KTonneSprayRate[fruitName][sprayType[j]] / RN.sprayDensity[sprayType[j]];			-- 1000 L/ha
			RN.mean1000LSprayRate[fruitName][sprayType[j]] = RN.meanTonneSprayRate[fruitName][sprayType[j]] / RN.sprayDensity[sprayType[j]];	-- 1000 L/ha
		end;
		if isDebug then
			print(" ");
			print("                                  Fert    LiFe    PiMa    CoMa    PiLi    CoLi    Dige    Comp");

			myPrintSprayInfo3(fruitName, 16, "N: T/ha     ",RN.NTonneSprayRate[fruitName][sprayType[1]], RN.NTonneSprayRate[fruitName][sprayType[2]],
															RN.NTonneSprayRate[fruitName][sprayType[3]], RN.NTonneSprayRate[fruitName][sprayType[4]],
															RN.NTonneSprayRate[fruitName][sprayType[5]], RN.NTonneSprayRate[fruitName][sprayType[6]],
															RN.NTonneSprayRate[fruitName][sprayType[7]], RN.NTonneSprayRate[fruitName][sprayType[8]]);
			myPrintSprayInfo3(fruitName, 16, "P: T/ha     ",RN.PTonneSprayRate[fruitName][sprayType[1]], RN.PTonneSprayRate[fruitName][sprayType[2]],
															RN.PTonneSprayRate[fruitName][sprayType[3]], RN.PTonneSprayRate[fruitName][sprayType[4]],
															RN.PTonneSprayRate[fruitName][sprayType[5]], RN.PTonneSprayRate[fruitName][sprayType[6]],
															RN.PTonneSprayRate[fruitName][sprayType[7]], RN.PTonneSprayRate[fruitName][sprayType[8]]);
			myPrintSprayInfo3(fruitName, 16, "K: T/ha     ",RN.KTonneSprayRate[fruitName][sprayType[1]], RN.KTonneSprayRate[fruitName][sprayType[2]],
															RN.KTonneSprayRate[fruitName][sprayType[3]], RN.KTonneSprayRate[fruitName][sprayType[4]],
															RN.KTonneSprayRate[fruitName][sprayType[5]], RN.KTonneSprayRate[fruitName][sprayType[6]],
															RN.KTonneSprayRate[fruitName][sprayType[7]], RN.KTonneSprayRate[fruitName][sprayType[8]]);
			myPrintSprayInfo3(fruitName, 16, "W: T/ha     ",RN.meanTonneSprayRate[fruitName][sprayType[1]], RN.meanTonneSprayRate[fruitName][sprayType[2]],
															RN.meanTonneSprayRate[fruitName][sprayType[3]], RN.meanTonneSprayRate[fruitName][sprayType[4]],
															RN.meanTonneSprayRate[fruitName][sprayType[5]], RN.meanTonneSprayRate[fruitName][sprayType[6]],
															RN.meanTonneSprayRate[fruitName][sprayType[7]], RN.meanTonneSprayRate[fruitName][sprayType[8]]);
			myPrintSprayInfo3(fruitName, 16, "W: 1000 L/ha",RN.mean1000LSprayRate[fruitName][sprayType[1]], RN.mean1000LSprayRate[fruitName][sprayType[2]],
															RN.mean1000LSprayRate[fruitName][sprayType[3]], RN.mean1000LSprayRate[fruitName][sprayType[4]],
															RN.mean1000LSprayRate[fruitName][sprayType[5]], RN.mean1000LSprayRate[fruitName][sprayType[6]],
															RN.mean1000LSprayRate[fruitName][sprayType[7]], RN.mean1000LSprayRate[fruitName][sprayType[8]]);
			myPrintSprayInfo4(fruitName, 16, currency.."/ha        ",RN.sprayCostPerHa[fruitName][sprayType[1]], RN.sprayCostPerHa[fruitName][sprayType[2]],
															RN.sprayCostPerHa[fruitName][sprayType[3]], RN.sprayCostPerHa[fruitName][sprayType[4]],
															RN.sprayCostPerHa[fruitName][sprayType[5]], RN.sprayCostPerHa[fruitName][sprayType[6]],
															RN.sprayCostPerHa[fruitName][sprayType[7]], RN.sprayCostPerHa[fruitName][sprayType[8]]);
		end;
	end;
	
	sprayRates.FERTILIZER = 1000 * RN.mean1000LSprayRate["WHEAT"]["FERTILIZER"]/(3.6 * 10000);
	sprayRates.LIQUIDFERTILIZER = 1000 * RN.mean1000LSprayRate["WHEAT"]["LIQUIDFERTILIZER"]/(3.6 * 10000);
	sprayRates.MANURE = 1000 * RN.mean1000LSprayRate["WHEAT"]["cowMANURE"]/(3.6 * 10000);
	sprayRates.LIQUIDMANURE = 1000 * RN.mean1000LSprayRate["WHEAT"]["cowLIQUIDMANURE"]/(3.6 * 10000);
	sprayRates.DIGESTATE = 1000 * RN.mean1000LSprayRate["WHEAT"]["DIGESTATE"]/(3.6 * 10000);
	sprayRates.COMPOST = 1000 * RN.mean1000LSprayRate["WHEAT"]["COMPOST"]/(3.6 * 10000);
	
	if isDebug then print("\n---Game spray parameters---\n"); end;
	if g_sprayTypeManager.sprayTypes  ~= nil then
		for k,sprayType in pairs(g_sprayTypeManager.sprayTypes) do
			if sprayType.fillType  ~= nil then
				local fillType = sprayType.fillType;
				if sprayType.fillType  ~= nil then
					local sprayTypeName  = sprayType.name;
					fillType.startPricePerLiter  = fillType.pricePerLiter;
					fillType.previousHourPrice   = fillType.pricePerLiter;
					if sprayRates[sprayTypeName] ~= nil then
						sprayType.litersPerSecond  = sprayRates[sprayTypeName];			
						if isDebug then myPrintFloat(sprayTypeName, sprayType.litersPerSecond,textWidth3, "Liter/sec"); end;
					else
						print("Original spray rate on map");
						if isDebug then myPrintFloat(sprayTypeName, sprayType.litersPerSecond,textWidth3, "Liter/sec"); end;
					end;
				end;
			end;
		end;
	end;
end;

function RealNumbersSpraying:keyEvent(unicode, sym, modifier, isDown)
	local isDebug = RN.isDebug;
	local textWidth3 = 40;
	
	if Input.isKeyPressed(Input.KEY_lalt) and Input.isKeyPressed(Input.KEY_r) and Input.isKeyPressed(Input.KEY_s) then
		print("\nlAlt-rs pressed\n");
		local sprayType = {"FERTILIZER","LIQUIDFERTILIZER","pigMANURE","cowMANURE","pigLIQUIDMANURE","cowLIQUIDMANURE","DIGESTATE","COMPOST","LIME","HERBICIDE"};

		print("\nWeighted NPK fertilizing rates by fruit type and fertilizer type\n");
		print("                                  Fert    LiFe    PiMa    CoMa    PiLi    CoLi    Dige    Comp");
		for i,fruitName in ipairs(RN.sortedFruits) do			
			myPrintSprayInfo3(fruitName, 16, "W: 1000 L/ha",RN.mean1000LSprayRate[fruitName][sprayType[1]], RN.mean1000LSprayRate[fruitName][sprayType[2]],
															RN.mean1000LSprayRate[fruitName][sprayType[3]], RN.mean1000LSprayRate[fruitName][sprayType[4]],
															RN.mean1000LSprayRate[fruitName][sprayType[5]], RN.mean1000LSprayRate[fruitName][sprayType[6]],
															RN.mean1000LSprayRate[fruitName][sprayType[7]], RN.mean1000LSprayRate[fruitName][sprayType[8]]);
		end;
		print(" ");
		myPrint("Lime liter per ha:", RN.sprayLitersPerHa.LIME,textWidth3, " L/Ha");
		myPrint("Diluted herbicide liter per ha:", RN.sprayLitersPerHa.HERBICIDE,textWidth3, " L/Ha\n");		
	end;
end;
function RealNumbersSpraying:update(dt)
end;
function RealNumbersSpraying:draw()
end;
function RealNumbersSpraying:deleteMap()
end;
function RealNumbersSpraying:mouseEvent(posX, posY, isDown, isUp, button)
end;

addModEventListener(RealNumbersSpraying);
