--Name: SoilExtension - SoilExtension
--Author: kevink98
--Date: 06.08.2016
--Version: 1.0

--Versionen: 
--				V 0.9: creation
--				V 1.0: Release, many fixes,....
	
--Keine Änderung ohne meine Erlaubnis!
--No modification without my permission!

SoilExtension = {};
SoilExtension_directory = g_currentModDirectory;
SoilExtension_directoryMods = g_modsDirectory;


print("SoilExtension v1.0 loaded! Support on Marhu.net");

function SoilExtension:appStore ()
	local appStore = {};
		appStore.version = 1.0;
		appStore.titel = "SoilExtension";
		appStore.author = "kevink98";
		appStore.icon = createImageOverlay(FarmingTablet_directory.."hudsAll/huds_Appstore/shop_Soil.dds");
		appStore.price = 23000;
		appStore.description = {};
		appStore.description.z1 = "Sie spielen mit dem Soilmod?";
		appStore.description.z2 = "Mit dieser App können Sie alle Schritte planen und verwalten."
		appStore.description.z3 = "Im Kalender werden zusätzlich alle Schritte als Termin angezeigt."
	return appStore;
end;

function SoilExtension:loadXml(xml)
	local key = "FarmingTablet.SoilExtension";
	if hasXMLProperty(xml, key .. "#numFields") then
		local numFields = getXMLInt(xml, key .. "#numFields");
		for i = 1, numFields do
			local fieldKey = key..".field"..tostring(i);
			g_currentMission.FarmingTablet.SoilExtension.daten.fields[i] = {};
			g_currentMission.FarmingTablet.SoilExtension.daten.fields[i].name = getXMLString(xml, fieldKey.."#name");
			g_currentMission.FarmingTablet.SoilExtension.daten.fields[i].frucht = getXMLString(xml, fieldKey.."#frucht");
			local keyStartwerte = fieldKey..".startwerte";
			g_currentMission.FarmingTablet.SoilExtension.daten.fields[i].startwerte = {};
			g_currentMission.FarmingTablet.SoilExtension.daten.fields[i].startwerte.ph = getXMLFloat(xml, keyStartwerte.."#ph");
			g_currentMission.FarmingTablet.SoilExtension.daten.fields[i].startwerte.feuchte = getXMLInt(xml, keyStartwerte.."#feuchte");
			g_currentMission.FarmingTablet.SoilExtension.daten.fields[i].startwerte.nWert = getXMLInt(xml, keyStartwerte.."#n");
			g_currentMission.FarmingTablet.SoilExtension.daten.fields[i].startwerte.pkWert = getXMLInt(xml, keyStartwerte.."#pk");
			local keyWetter = fieldKey..".wetter";
			g_currentMission.FarmingTablet.SoilExtension.daten.fields[i].wetter = {};
			g_currentMission.FarmingTablet.SoilExtension.daten.fields[i].wetter.regenTage = getXMLInt(xml, keyWetter.."#regen");
			g_currentMission.FarmingTablet.SoilExtension.daten.fields[i].wetter.warm = getXMLInt(xml, keyWetter.."#warm");
			
			g_currentMission.FarmingTablet.SoilExtension.daten.fields[i].tag = getXMLInt(xml, fieldKey.."#tag");
			g_currentMission.FarmingTablet.SoilExtension.daten.fields[i].tage = getXMLInt(xml, fieldKey.."#tage");
			g_currentMission.FarmingTablet.SoilExtension.daten.fields[i].schritte = {};
			for j = 1, 10 do
				local schrittKey = fieldKey..".schritte"..tostring(j);
				g_currentMission.FarmingTablet.SoilExtension.daten.fields[i].schritte[j] = {};
				g_currentMission.FarmingTablet.SoilExtension.daten.fields[i].schritte[j].art = getXMLString(xml, schrittKey.."#art");
				g_currentMission.FarmingTablet.SoilExtension.daten.fields[i].schritte[j].pic = getXMLString(xml, schrittKey.."#pic");
				g_currentMission.FarmingTablet.SoilExtension.daten.fields[i].schritte[j].mittel = getXMLString(xml, schrittKey.."#mittel");
			end;
		end;
	end;
end;

function SoilExtension:saveXml(xml)
	local key = "FarmingTablet.SoilExtension";
	local numFields = table.getn(g_currentMission.FarmingTablet.SoilExtension.daten.fields);
	setXMLInt(xml, key .. "#numFields", numFields);
	for i = 1, numFields do
		local fieldKey = key..".field"..tostring(i);
		local keyStartwerte = fieldKey..".startwerte";
		local keyWetter = fieldKey..".wetter";
		setXMLString(xml, fieldKey.."#name", g_currentMission.FarmingTablet.SoilExtension.daten.fields[i].name);
		setXMLString(xml, fieldKey.."#frucht", g_currentMission.FarmingTablet.SoilExtension.daten.fields[i].frucht);
		setXMLFloat(xml, keyStartwerte.."#ph", g_currentMission.FarmingTablet.SoilExtension.daten.fields[i].startwerte.ph);
		setXMLInt(xml, keyStartwerte.."#feuchte", g_currentMission.FarmingTablet.SoilExtension.daten.fields[i].startwerte.feuchte);
		setXMLInt(xml, keyStartwerte.."#n", g_currentMission.FarmingTablet.SoilExtension.daten.fields[i].startwerte.nWert);
		setXMLInt(xml, keyStartwerte.."#pk", g_currentMission.FarmingTablet.SoilExtension.daten.fields[i].startwerte.pkWert);
		setXMLInt(xml, keyWetter.."#regen", g_currentMission.FarmingTablet.SoilExtension.daten.fields[i].wetter.regenTage);
		setXMLInt(xml, keyWetter.."#warm", g_currentMission.FarmingTablet.SoilExtension.daten.fields[i].wetter.warm);
		setXMLInt(xml, fieldKey.."#tag", g_currentMission.FarmingTablet.SoilExtension.daten.fields[i].tag);
		setXMLInt(xml, fieldKey.."#tage", g_currentMission.FarmingTablet.SoilExtension.daten.fields[i].tage);
		for j = 1, 10 do
			local schrittKey = fieldKey..".schritte"..tostring(j);
			setXMLString(xml, schrittKey.."#art", g_currentMission.FarmingTablet.SoilExtension.daten.fields[i].schritte[j].art);
			setXMLString(xml, schrittKey.."#pic", g_currentMission.FarmingTablet.SoilExtension.daten.fields[i].schritte[j].pic);
			setXMLString(xml, schrittKey.."#mittel", g_currentMission.FarmingTablet.SoilExtension.daten.fields[i].schritte[j].mittel);
		end;
	end;
end;

function SoilExtension:loadSoilExtension ()
	--g_currentMission.FarmingTablet.SoilExtension = {};
	--g_currentMission.FarmingTablet.SoilExtension.daten = {};
	
	SoilExtension.werte = {};
	source(FarmingTablet_directory.."Scripts/actions/SoilExtensionAddOn.lua");
	SoilExtensionAddOn:loadWerte();
	
	self.windows = {};
	self.windows.uerbersicht = {};
	self.windows.erstellen = {};
	self.windows.bearbeiten = {};
	self.windows.speichern = {};
	self.windows.fruchtAuswahl = {};
	self.windows.wetterAuswahl = {};
	self.windows.art = {};
	self.windows.art2 = {};
	self.windows.mittelPflug = false;
	self.windows.mittelGrubbern = false;
	self.windows.mittelAusbringen = false;
	self.windows.startwerteAuswahl = {};
	self.windows.uerbersicht.show = true;
	self.windows.uerbersicht.kz = {};
	self.windows.erstellen.show = false;
	self.windows.erstellen.text = "";
	self.windows.bearbeiten.show= false;
	self.windows.speichern.show = false;
	self.windows.fruchtAuswahl.show = false;
	self.windows.wetterAuswahl.show = false;
	self.windows.startwerteAuswahl.show = false;
	self.windows.art.show = false;
	self.windows.art2.show = false;
	self.loeschen = false;
	self.abbrechen = false;
	self.saveBalken = 0;
	self.kz = 0;
	self.art = 0;
	self.art2 = 0;
	self.artAusbringen = 0;
	self.artPflugen = 0;
	self.artGrubbern = 0;
	g_currentMission.FarmingTablet.SoilExtension.daten.fields = {};
	self.wetter1 = 0;
	self.wetter2 = 0;
	self.startwert1 = 0;
	self.startwert2 = 0;
	self.startwert3 = 0;
	self.startwert4 = 0;
end;

function SoilExtension:StartscreenApp (posX, posY, isDown, button)
	if self.windows.uerbersicht.show then
		if posX > 0.752 and posX < 0.913 and posY < 0.807 and posY > 0.738 and isDown and button == 1 then
			self.windows.uerbersicht.show = false;
			self.windows.erstellen.show = true;
			self.windows.bearbeiten.show = false;
			self.windows.speichern.show = false;
			self.loeschen = false;
			self.abbrechen = false;
		elseif posX > 0.752 and posX < 0.913 and posY < 0.704 and posY > 0.635 and isDown and button == 1 then 
			self.windows.uerbersicht.show = false;
			self.windows.erstellen.show = false;
			self.windows.bearbeiten.show = true;
			self.windows.speichern.show = false;
			self.loeschen = false;
			self.abbrechen = false;
		elseif posX > 0.752 and posX < 0.913 and posY < 0.601 and posY > 0.532 and isDown and button == 1 then 
			self.windows.uerbersicht.show = true;
			self.windows.erstellen.show = false;
			self.windows.bearbeiten.show = false;
			self.windows.speichern.show = false;
			self.loeschen = true;
			self.abbrechen = false;
		elseif posX > 0.752 and posX < 0.913 and posY > 0.362 and posY < 0.431 and isDown and button == 1 then 
			self.windows.uerbersicht.show = false;
			self.windows.erstellen.show = false;
			self.windows.bearbeiten.show = false;
			self.windows.speichern.show = true;
			self.loeschen = false;
			self.abbrechen = false;
		elseif posX > 0.752 and posX < 0.913 and posY < 0.335 and posY > 0.265 and isDown and button == 1 then 
			self.windows.uerbersicht.show = false;
			self.windows.erstellen.show = false;
			self.windows.bearbeiten.show = false;
			self.windows.speichern.show = false;
			self.loeschen = false;
			self.abbrechen = true;
			
		end;
		local lenght = table.getn(g_currentMission.FarmingTablet.SoilExtension.daten.fields);
		for i = 1, lenght do
			if posX > 0.12 and posX < 0.284 and posY < 0.788-((i-1)*0.05) and posY > 0.759-((i-1)*0.05) and isDown and button == 1 and lenght >= i then
				for j = 1, lenght do
					self.windows.uerbersicht.kz[j] = false;
				end;
				self.windows.uerbersicht.kz[i] = true;
				self.kz = i;
				return
			end;
		end;
	
	end;
	if self.loeschen then
		local lenght = table.getn(g_currentMission.FarmingTablet.SoilExtension.daten.fields);
		for i = 1, lenght do
			if self.windows.uerbersicht.kz[i] then
				g_currentMission.FarmingTablet.SoilExtension.daten.fields[i] = {};
				SoilExtensionAddOn:createField(i);
			end;
		end;
		self.loeschen = false;
	elseif self.abbrechen then
		FarmingTablet.kz.app3 = false;
		self.windows.uerbersicht.show = true;
		self.abbrechen = false;
		
	elseif self.windows.erstellen.show then
		if posX > 0.325 and posX < 0.501 and posY < 0.324 and posY > 0.271 and isDown and button == 1 and self.windows.erstellen.text ~= "" then
			local lenght = table.getn(g_currentMission.FarmingTablet.SoilExtension.daten.fields);
			self.angelegt = false;
			for i = 1, lenght do
				if g_currentMission.FarmingTablet.SoilExtension.daten.fields[i].name == nil then
					g_currentMission.FarmingTablet.SoilExtension.daten.fields[i] = {};
					g_currentMission.FarmingTablet.SoilExtension.daten.fields[i].name = self.windows.erstellen.text;
					SoilExtensionAddOn:createField(i);
					self.angelegt = true;
				end;
			end;
			if self.angelegt == false then
				g_currentMission.FarmingTablet.SoilExtension.daten.fields[lenght+1] = {};
				g_currentMission.FarmingTablet.SoilExtension.daten.fields[lenght+1].name = self.windows.erstellen.text;
				SoilExtensionAddOn:createField(lenght+1);
			end;
			g_currentMission.FarmingTablet.SoilExtension.daten.lenght = table.getn(g_currentMission.FarmingTablet.SoilExtension.daten.fields);
			self.windows.uerbersicht.kz[lenght+1] = false;
			self.windows.erstellen.text = "";
			self.windows.erstellen.show = false;
			self.windows.uerbersicht.show = true;
		elseif posX > 0.513 and posX < 0.688 and posY < 0.324 and posY > 0.271 and isDown and button == 1 then
			self.windows.erstellen.text = "";
			self.windows.erstellen.show = false;
			self.windows.uerbersicht.show = true;
		end;
		
	elseif self.windows.bearbeiten.show then
		
		if self.kz ~= 0 and self.kz ~= nil then
			--if not g_server ~= nil then 
				--SoilFieldEvent:sendEvent(self.kz);
			--end;
			if g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].name ~= nil then
				if posX > 0.174 and posX < 0.328 and posY > 0.751 and posY < 0.797 and isDown and button == 1 then
					self.windows.fruchtAuswahl.show = true;
					self.windows.bearbeiten.show = false;
				elseif posX > 0.611 and posX < 0.651 and posY < 0.805 and posY > 0.755 and isDown and button == 1 then
					self.windows.wetterAuswahl.show = true;
					self.windows.bearbeiten.show = false;
					self.wetter1 = g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].wetter.warm;
					self.wetter2 = g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].wetter.regenTage;
				elseif posX > 0.099 and posX < 0.135 and posY < 0.756 and posY > 0.7 and isDown and button == 1 then
					self.windows.startwerteAuswahl.show = true;
					self.windows.bearbeiten.show = false;
					self.startwert1 = g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].startwerte.ph;
					self.startwert2 = g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].startwerte.feuchte;
					self.startwert3 = g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].startwerte.nWert;
					self.startwert4 = g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].startwerte.pkWert;
				end;
				
				for i = 0, 3 do
					if posX > 0.117+(i*0.135) and posX < 0.183+(i*0.135) and posY > 0.587 and posY < 0.626 and isDown and button == 1 then 
						if i == 0 then
							self.art = i;
							self.windows.art.show = true;
							self.windows.bearbeiten.show = false;
						elseif i == 1 then
							if g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[1].art ~= SoilExtension.schritte[4] then
								self.art = i;
								self.windows.art.show = true;
								self.windows.bearbeiten.show = false;
							end;
						elseif i == 2 then
							if g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[1].art ~= SoilExtension.schritte[4]
							and g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[2].art ~= SoilExtension.schritte[4] then
								self.art = i;
								self.windows.art.show = true;
								self.windows.bearbeiten.show = false;
							end;
						elseif i == 3 then
							if g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[1].art ~= SoilExtension.schritte[4]
							and g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[2].art ~= SoilExtension.schritte[4]
							and g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[3].art ~= SoilExtension.schritte[4] then
								self.art = i;
								self.windows.art.show = true;
								self.windows.bearbeiten.show = false;
							end;
						end;
					end;
				end;
				
				if g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[1].art == SoilExtension.schritte[4] then
					for i = 0, 3 do
						if posX > 0.503+(i*0.135) and posX < 0.623+(i*0.135) and posY > 0.526 and posY < 0.56 and isDown and button == 1 and g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[i+3].art ~= SoilExtension.schritte[12] and g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[i+2].art ~= SoilExtension.schritte[12] and i < 3 then 
							self.art2 = i+4;
							self.windows.art2.show = true;
							self.windows.bearbeiten.show = false;
						elseif posX > 0.1 and posX < 0.23 and posY > 0.283 and posY < 0.332 and isDown and button == 1 and g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[6].art ~= SoilExtension.schritte[12] and i == 3 then 
							self.art2 = i+4;
							self.windows.art2.show = true;
							self.windows.bearbeiten.show = false;
						end;
					end;
					
					for i = 0, 5  do 
						if posX > 0.242+(i*0.135) and posX < 0.341+(i*0.135) and posY > 0.47 and posY < 0.521 and isDown and button == 1 and g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[i+2].art == SoilExtension.schritte[3] and i < 5 then 
							self.windows.mittelAusbringen = true;	
							self.artAusbringen = i+2;
							self.windows.bearbeiten.show = false;
						elseif posX > 0.104 and posX < 0.204 and posY > 0.246 and posY < 0.3 and isDown and button == 1 and g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[i+2].art == SoilExtension.schritte[3] and g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[6].art ~= SoilExtension.schritte[12] and i >= 5 then 
							self.windows.mittelAusbringen = true;	
							self.artAusbringen = i+2;
							self.windows.bearbeiten.show = false;
						end;
					end;
					
				elseif g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[2].art == SoilExtension.schritte[4] then
					for i = 1, 4 do
						if posX > 0.503+(i*0.135) and posX < 0.623+(i*0.135) and posY > 0.526 and posY < 0.56 and isDown and button == 1 and g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[i+2].art ~= SoilExtension.schritte[12] and g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[i+2].art ~= SoilExtension.schritte[12] and i < 3 then 
							self.art2 = i+4;
							self.windows.art2.show = true;
							self.windows.bearbeiten.show = false;
						elseif posX > 0.1+((i-3)*0.13) and posX < 0.23+((i-3)*0.13) and posY > 0.283 and posY < 0.332 and isDown and button == 1 and g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[6].art ~= SoilExtension.schritte[12] and g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[5].art ~= SoilExtension.schritte[12] and g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[7].art ~= SoilExtension.schritte[12] and i >= 3 then 
							self.art2 = i+4;
							self.windows.art2.show = true;
							self.windows.bearbeiten.show = false;
						end;
					end;
					
					for i = 1, 6 do 
						if posX > 0.242+(i*0.135) and posX < 0.341+(i*0.135) and posY > 0.47 and posY < 0.521 and isDown and button == 1 and g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[i+2].art ~= SoilExtension.schritte[12] and g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[i+2].art ~= SoilExtension.schritte[12] and i < 5 then 
							self.windows.mittelAusbringen = true;	
							self.artAusbringen = i+2;
							self.windows.bearbeiten.show = false;
						elseif posX > 0.104+((i-5)*0.13) and posX < 0.204+((i-5)*0.13) and posY > 0.246 and posY < 0.3 and isDown and button == 1 and g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[6].art ~= SoilExtension.schritte[12] and g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[5].art ~= SoilExtension.schritte[12] and g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[7].art ~= SoilExtension.schritte[12] and i >= 5 then 
							self.windows.mittelAusbringen = true;	
							self.artAusbringen = i+2;
							self.windows.bearbeiten.show = false;
						end;
					end;
					if posX > 0.097 and posX < 0.218 and posY > 0.519 and posY < 0.57 and isDown and button == 1 then
						if g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[1].art == SoilExtension.schritte[1] then
							self.windows.mittelPflug = true;	
							self.artPflugen = 1;
							self.windows.bearbeiten.show = false;
						elseif g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[1].art == SoilExtension.schritte[2] then
							self.windows.mittelGrubbern = true;	
							self.artGrubbern = 1;
							self.windows.bearbeiten.show = false;
						elseif g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[1].art == SoilExtension.schritte[3] then
							self.windows.mittelAusbringen = true;	
							self.artAusbringen = 1;
							self.windows.bearbeiten.show = false;
						end;
					end;
				elseif g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[3].art == SoilExtension.schritte[4] then
					for i = 2, 5 do
						if posX > 0.503+(i*0.135) and posX < 0.623+(i*0.135) and posY > 0.526 and posY < 0.56 and isDown and button == 1 and g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[i+1].art ~= SoilExtension.schritte[12] and g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[i].art ~= SoilExtension.schritte[12] and i < 3 then 
							self.art2 = i+4;
							self.windows.art2.show = true;
							self.windows.bearbeiten.show = false;
						elseif posX > 0.1+((i-3)*0.13) and posX < 0.23+((i-3)*0.13) and posY > 0.283 and posY < 0.332 and isDown and button == 1 and i >= 3 then
							if i == 3 and g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[6].art ~= SoilExtension.schritte[12] then
								self.art2 = i+4;
								self.windows.art2.show = true;
								self.windows.bearbeiten.show = false;
							elseif i == 4 and g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[7].art ~= SoilExtension.schritte[12] and g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[6].art ~= SoilExtension.schritte[12] then
								self.art2 = i+4;
								self.windows.art2.show = true;
								self.windows.bearbeiten.show = false;
							elseif i == 5 and g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[8].art ~= SoilExtension.schritte[12] and g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[7].art ~= SoilExtension.schritte[12] and g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[6].art ~= SoilExtension.schritte[12] then
								self.art2 = i+4;
								self.windows.art2.show = true;
								self.windows.bearbeiten.show = false;
							end;
						end;
					end;
					
					for i = 2, 7 do 
						if posX > 0.242+(i*0.135) and posX < 0.341+(i*0.135) and posY > 0.47 and posY < 0.521 and isDown and button == 1 and g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[i+2].art ~= SoilExtension.schritte[12] and i < 5 then 
							self.windows.mittelAusbringen = true;	
							self.artAusbringen = i+2;
							self.windows.bearbeiten.show = false;
						elseif posX > 0.104+((i-5)*0.13) and posX < 0.204+((i-5)*0.13) and posY > 0.246 and posY < 0.3 and isDown and button == 1 and i >= 5 and g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[i+2].art ~= SoilExtension.schritte[12] then 
							self.windows.mittelAusbringen = true;	
							self.artAusbringen = i+2;
							self.windows.bearbeiten.show = false;
						end;
					end;
					if posX > 0.097 and posX < 0.218 and posY > 0.519 and posY < 0.57 and isDown and button == 1 then
						if g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[1].art == SoilExtension.schritte[1] then
							self.windows.mittelPflug = true;	
							self.artPflugen = 1;
							self.windows.bearbeiten.show = false;
						elseif g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[1].art == SoilExtension.schritte[2] then
							self.windows.mittelGrubbern = true;	
							self.artGrubbern = 1;
							self.windows.bearbeiten.show = false;
						elseif g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[1].art == SoilExtension.schritte[3] then
							self.windows.mittelAusbringen = true;	
							self.artAusbringen = 1;
							self.windows.bearbeiten.show = false;
						end;
					elseif posX > 0.239 and posX < 0.36 and posY > 0.519 and posY < 0.57 and isDown and button == 1 then
						if g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[2].art == SoilExtension.schritte[1] then
							self.windows.mittelPflug = true;	
							self.artPflugen = 2;
							self.windows.bearbeiten.show = false;
						elseif g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[2].art == SoilExtension.schritte[2] then
							self.windows.mittelGrubbern = true;	
							self.artGrubbern = 2;
							self.windows.bearbeiten.show = false;
						elseif g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[2].art == SoilExtension.schritte[3] then
							self.windows.mittelAusbringen = true;	
							self.artAusbringen = 2;
							self.windows.bearbeiten.show = false;
						end;
					end;
				elseif g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[4].art == SoilExtension.schritte[4] then
					for i = 3, 6 do
						if posX > 0.1+((i-3)*0.13) and posX < 0.23+((i-3)*0.13) and posY > 0.283 and posY < 0.332 and isDown and button == 1 and i >= 3 then
							if i == 3 then
								self.art2 = i+4;
								self.windows.art2.show = true;
								self.windows.bearbeiten.show = false;
							elseif i == 4 and g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[7].art ~= SoilExtension.schritte[12] then
								self.art2 = i+4;
								self.windows.art2.show = true;
								self.windows.bearbeiten.show = false;
							elseif i == 5 and g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[7].art ~= SoilExtension.schritte[12] and g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[8].art ~= SoilExtension.schritte[12] then
								self.art2 = i+4;
								self.windows.art2.show = true;
								self.windows.bearbeiten.show = false;
							elseif i == 6 and g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[7].art ~= SoilExtension.schritte[12] and g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[8].art ~= SoilExtension.schritte[12] and g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[9].art ~= SoilExtension.schritte[12] then
								self.art2 = i+4;
								self.windows.art2.show = true;
								self.windows.bearbeiten.show = false;
							end;
						end;
					end;
					
					for i = 3, 8 do 
						if posX > 0.242+(i*0.135) and posX < 0.341+(i*0.135) and posY > 0.47 and posY < 0.521 and isDown and button == 1 and g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[i+2].art ~= SoilExtension.schritte[12] and i < 5 then 
							self.windows.mittelAusbringen = true;	
							self.artAusbringen = i+2;
							self.windows.bearbeiten.show = false;
						elseif posX > 0.104+((i-5)*0.13) and posX < 0.204+((i-5)*0.13) and posY > 0.246 and posY < 0.3 and isDown and button == 1 and i >= 5 and g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[i+2].art ~= SoilExtension.schritte[12] then 
							self.windows.mittelAusbringen = true;	
							self.artAusbringen = i+2;
							self.windows.bearbeiten.show = false;
						end;
					end;
					if posX > 0.097 and posX < 0.218 and posY > 0.519 and posY < 0.57 and isDown and button == 1 then
						if g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[1].art == SoilExtension.schritte[1] then
							self.windows.mittelPflug = true;	
							self.artPflugen = 1;
							self.windows.bearbeiten.show = false;
						elseif g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[1].art == SoilExtension.schritte[2] then
							self.windows.mittelGrubbern = true;	
							self.artGrubbern = 1;
							self.windows.bearbeiten.show = false;
						elseif g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[1].art == SoilExtension.schritte[3] then
							self.windows.mittelAusbringen = true;	
							self.artAusbringen = 1;
							self.windows.bearbeiten.show = false;
						end;
					elseif posX > 0.239 and posX < 0.36 and posY > 0.519 and posY < 0.57 and isDown and button == 1 then
						if g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[2].art == SoilExtension.schritte[1] then
							self.windows.mittelPflug = true;	
							self.artPflugen = 2;
							self.windows.bearbeiten.show = false;
						elseif g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[2].art == SoilExtension.schritte[2] then
							self.windows.mittelGrubbern = true;	
							self.artGrubbern = 2;
							self.windows.bearbeiten.show = false;
						elseif g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[2].art == SoilExtension.schritte[3] then
							self.windows.mittelAusbringen = true;	
							self.artAusbringen = 2;
							self.windows.bearbeiten.show = false;
						end;
					elseif posX > 0.375 and posX < 0.494 and posY > 0.519 and posY < 0.57 and isDown and button == 1 then
						if g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[3].art == SoilExtension.schritte[1] then
							self.windows.mittelPflug = true;	
							self.artPflugen = 3;
							self.windows.bearbeiten.show = false;
						elseif g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[3].art == SoilExtension.schritte[2] then
							self.windows.mittelGrubbern = true;	
							self.artGrubbern = 3;
							self.windows.bearbeiten.show = false;
						elseif g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[3].art == SoilExtension.schritte[3] then
							self.windows.mittelAusbringen = true;	
							self.artAusbringen = 3;
							self.windows.bearbeiten.show = false;
						end;
					end;
				end;
				if posX > 0.591 and posX < 0.745 and posY > 0.171 and posY < 0.218 and isDown and button == 1 then
					self.windows.bearbeiten.show = false;
					self.windows.uerbersicht.show = true;
				elseif posX > 0.758 and posX < 0.91 and posY > 0.171 and posY < 0.218 and isDown and button == 1 then
					SoilExtensionAddOn:createField(self.kz);
				end;
			else
				self.windows.bearbeiten.show = false;
				self.windows.uerbersicht.show = true;
			end;
		elseif self.kz == 0 then
			self.windows.bearbeiten.show = false;
			self.windows.uerbersicht.show = true;
		end;

	elseif self.windows.fruchtAuswahl.show then
		for i=0, 13 do
			if posX > 0.25 and posX < 0.33 and posY > 0.616-(i*0.055) and posY < 0.653-(i*0.055) and isDown and button == 1 and i <= 3 then
				g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].frucht = SoilExtension.werte.fruechte[i+1];
				self.windows.fruchtAuswahl.show = false;
				self.windows.bearbeiten.show = true;
				break;
			end;
			if posX > 0.36 and posX < 0.44 and posY > 0.616-((i-4)*0.055) and posY < 0.653-((i-4)*0.055) and isDown and button == 1 and i > 3 and i <= 7 then
				g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].frucht = SoilExtension.werte.fruechte[i+1];
				self.windows.fruchtAuswahl.show = false;
				self.windows.bearbeiten.show = true;
				return;
			end;
			if posX > 0.47 and posX < 0.595 and posY > 0.616-((i-8)*0.055) and posY < 0.653-((i-8)*0.055) and isDown and button == 1 and i > 7 and i <= 11 then
				g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].frucht = SoilExtension.werte.fruechte[i+1];
				self.windows.fruchtAuswahl.show = false;
				self.windows.bearbeiten.show = true;
				return;
			end;
			if posX > 0.6 and posX < 0.65 and posY > 0.616-((i-12)*0.055) and posY < 0.653-((i-12)*0.055) and isDown and button == 1 and i > 11 and i <= 13 then
				g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].frucht = SoilExtension.werte.fruechte[i+1];
				self.windows.fruchtAuswahl.show = false;
				self.windows.bearbeiten.show = true;
				return;
			end;
		end; 
		if posX > 0.378 and posX < 0.654 and posY < 0.283 and posY > 0.211 and isDown and button == 1 then
			self.windows.fruchtAuswahl.show = false;
			self.windows.bearbeiten.show = true;
		end;
	elseif self.windows.wetterAuswahl.show then
		if posX > 0.566 and posX < 0.595 and posY < 0.614 and posY > 0.564 and isDown and button == 1 then
			g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].wetter.warm = g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].wetter.warm + 1;
		elseif posX > 0.603 and posX < 0.631 and posY < 0.614 and posY > 0.564 and isDown and button == 1 then
			if g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].wetter.warm == 0 then
				g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].wetter.warm = 0;
			else
				g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].wetter.warm = g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].wetter.warm - 1;
			end;
		elseif posX > 0.566 and posX < 0.595 and posY < 0.508 and posY > 0.457 and isDown and button == 1 then
			g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].wetter.regenTage = g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].wetter.regenTage + 1;
		elseif posX > 0.603 and posX < 0.631 and posY < 0.508 and posY > 0.457 and isDown and button == 1 then
			if g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].wetter.regenTage == 0 then
				g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].wetter.regenTage = 0;
			else
				g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].wetter.regenTage = g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].wetter.regenTage - 1;
			end;
		elseif posX > 0.241 and posX < 0.517 and posY < 0.291 and posY > 0.218 and isDown and button == 1 then
			self.windows.bearbeiten.show = true;
			self.windows.wetterAuswahl.show = false;
		elseif posX > 0.524 and posX < 0.8 and posY < 0.291 and posY > 0.218 and isDown and button == 1 then
			self.windows.bearbeiten.show = true;
			self.windows.wetterAuswahl.show = false;
			g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].wetter.warm = self.wetter1;
			g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].wetter.regenTage = self.wetter2;
		end;
	elseif self.windows.startwerteAuswahl.show then
		if posX > 0.566 and posX < 0.595 and posY < 0.629 and posY > 0.586 and isDown and button == 1 then
			g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].startwerte.ph = g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].startwerte.ph + 0.1;
		elseif posX > 0.601 and posX < 0.629 and posY < 0.629 and posY > 0.586 and isDown and button == 1 then
			g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].startwerte.ph = g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].startwerte.ph - 0.1;
		elseif posX > 0.566 and posX < 0.595 and posY < 0.534 and posY > 0.485 and isDown and button == 1 then
			g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].startwerte.feuchte = g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].startwerte.feuchte + 1;
		elseif posX > 0.601 and posX < 0.629 and posY < 0.534 and posY > 0.485 and isDown and button == 1 then
			g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].startwerte.feuchte = g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].startwerte.feuchte - 1;
		elseif posX > 0.566 and posX < 0.595 and posY < 0.444 and posY > 0.4 and isDown and button == 1 then
			g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].startwerte.nWert = g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].startwerte.nWert + 1;
		elseif posX > 0.601 and posX < 0.629 and posY < 0.444 and posY > 0.4 and isDown and button == 1 then
			g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].startwerte.nWert = g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].startwerte.nWert - 1;
		elseif posX > 0.566 and posX < 0.595 and posY < 0.348 and posY > 0.306 and isDown and button == 1 then
			g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].startwerte.pkWert = g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].startwerte.pkWert + 1;
		elseif posX > 0.601 and posX < 0.629 and posY < 0.348 and posY > 0.306 and isDown and button == 1 then
			g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].startwerte.pkWert = g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].startwerte.pkWert - 1;
		elseif posX > 0.241 and posX < 0.517 and posY < 0.291 and posY > 0.218 and isDown and button == 1 then
			self.windows.bearbeiten.show = true;
			self.windows.startwerteAuswahl.show = false;
		elseif posX > 0.524 and posX < 0.8 and posY < 0.291 and posY > 0.218 and isDown and button == 1 then
			self.windows.bearbeiten.show = true;
			self.windows.startwerteAuswahl.show = false;
			g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].startwerte.ph = self.startwert1;
			g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].startwerte.feuchte = self.startwert2;
			g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].startwerte.nWert = self.startwert3;
			g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].startwerte.pkWert = self.startwert4;
		end;
	elseif self.windows.art.show then
		for i = 0, 3 do
			if posX > 0.245 and posX < 0.365 and posY < 0.652-(i*0.055) and posY > 0.612-(i*0.055) and isDown and button == 1 then
				g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[self.art+1].art = SoilExtension.schritte[i+1];
				g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[self.art+1].mittel = SoilExtension.schritte[13];
				g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[self.art+1].pic = SoilExtension.schritte[i+1];
				if g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[self.art+1].art == SoilExtension.schritte[4] then
					g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[self.art+2].art = SoilExtension.schritte[3];
					g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[self.art+3].art = SoilExtension.schritte[3];
					g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[self.art+4].art = SoilExtension.schritte[13];
					g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[self.art+5].art = SoilExtension.schritte[13];
					g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[self.art+6].art = SoilExtension.schritte[13];
					g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[self.art+7].art = SoilExtension.schritte[13];
					g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[self.art+1].pic = SoilExtension.schritte[4];
					g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[self.art+2].pic = SoilExtension.schritte[5];
					g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[self.art+3].pic = SoilExtension.schritte[6];
					g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[self.art+4].pic = SoilExtension.schritte[7];
					g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[self.art+5].pic = SoilExtension.schritte[8];
					g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[self.art+6].pic = SoilExtension.schritte[9];
					g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[self.art+7].pic = SoilExtension.schritte[10];
					g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].tage = self.art+7;
				end;
				self.windows.art.show = false;
				self.windows.bearbeiten.show = true;
			end;
		end; 
		
		if posX > 0.378 and posX < 0.654 and posY < 0.283 and posY > 0.211 and isDown and button == 1 then
			self.windows.art.show = false;
			self.windows.bearbeiten.show = true;
		end;
	elseif self.windows.art2.show then
		for i = 0, 1 do
			if posX > 0.245 and posX < 0.365 and posY < 0.652-(i*0.055) and posY > 0.612-(i*0.055) and isDown and button == 1 then
				if i == 0 then
					g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[self.art2].art = SoilExtension.schritte[3];
				elseif i == 1 then
					g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[self.art2].art = SoilExtension.schritte[12];
				end;
				self.windows.art2.show = false;
				self.windows.bearbeiten.show = true;
			end;
		end; 
		if posX > 0.378 and posX < 0.654 and posY < 0.283 and posY > 0.211 and isDown and button == 1 then
			self.windows.art2.show = false;
			self.windows.bearbeiten.show = true;
		end;	
	elseif self.windows.mittelAusbringen then
		for i = 0, 4 do
			if posX > 0.25 and posX < 0.35 and posY < 0.647-(i*0.05) and posY > 0.617-(i*0.05) and isDown and button == 1 then
				g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[self.artAusbringen].mittel = SoilExtension.ausbringen[i+1];
				self.windows.mittelAusbringen= false;
				self.windows.bearbeiten.show = true;
			end;
		end; 
		for i = 5, 9 do
			if posX > 0.425 and posX < 0.57 and posY < 0.647-((i-5)*0.05) and posY > 0.617-((i-5)*0.05) and isDown and button == 1 then
				g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[self.artAusbringen].mittel = SoilExtension.ausbringen[i+1];
				self.windows.mittelAusbringen = false;
				self.windows.bearbeiten.show = true;
			end;
		end;
		for i = 10, 14 do
			if posX > 0.6 and posX < 0.75 and posY < 0.647-((i-10)*0.05) and posY > 0.617-((i-10)*0.05) and isDown and button == 1 then
				g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[self.artAusbringen].mittel = SoilExtension.ausbringen[i+1];
				self.windows.mittelAusbringen = false;
				self.windows.bearbeiten.show = true;
			end;
		end;
		if posX > 0.378 and posX < 0.654 and posY < 0.283 and posY > 0.211 and isDown and button == 1 then
			self.windows.mittelAusbringen = false;
			self.windows.bearbeiten.show = true;
		end;	
	elseif self.windows.mittelPflug then
		for i = 0, 4 do
			if posX > 0.25 and posX < 0.35 and posY < 0.647-(i*0.05) and posY > 0.617-(i*0.05) and isDown and button == 1 then
				g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[self.artPflugen].mittel = SoilExtension.pflug[i+1];
				self.windows.mittelPflug= false;
				self.windows.bearbeiten.show = true;
			end;
		end; 
		for i = 5, 9 do
			if posX > 0.425 and posX < 0.57 and posY < 0.647-((i-5)*0.05) and posY > 0.617-((i-5)*0.05) and isDown and button == 1 then
				g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[self.artPflugen].mittel = SoilExtension.pflug[i+1];
				self.windows.mittelPflug = false;
				self.windows.bearbeiten.show = true;
			end;
		end;
		if posX > 0.378 and posX < 0.654 and posY < 0.283 and posY > 0.211 and isDown and button == 1 then
			self.windows.mittelPflug = false;
			self.windows.bearbeiten.show = true;
		end;
	elseif self.windows.mittelGrubbern then
		for i = 0, 4 do
			if posX > 0.25 and posX < 0.35 and posY < 0.647-(i*0.05) and posY > 0.617-(i*0.05) and isDown and button == 1 then
				g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[self.artGrubbern].mittel = SoilExtension.grubbern[i+1];
				self.windows.mittelGrubbern= false;
				self.windows.bearbeiten.show = true;
			end;
		end; 
		for i = 5, 9 do
			if posX > 0.425 and posX < 0.57 and posY < 0.647-((i-5)*0.05) and posY > 0.617-((i-5)*0.05) and isDown and button == 1 then
				g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[self.artGrubbern].mittel = SoilExtension.grubbern[i+1];
				self.windows.mittelGrubbern = false;
				self.windows.bearbeiten.show = true;
			end;
		end;
		if posX > 0.378 and posX < 0.654 and posY < 0.283 and posY > 0.211 and isDown and button == 1 then
			self.windows.mittelGrubbern = false;
			self.windows.bearbeiten.show = true;
		end;
	end;
end;

function SoilExtension:updateSoilExtension (dt)
	if g_currentMission.environment.currentHour < 10 then
		self.uhr1 = tostring("0"..g_currentMission.environment.currentHour);
	else
		self.uhr1 = tostring(g_currentMission.environment.currentHour);
	end;
	if g_currentMission.environment.currentMinute < 10 then
		self.uhr2 = tostring("0"..g_currentMission.environment.currentMinute);
	else
		self.uhr2 = tostring(g_currentMission.environment.currentMinute);
	end;
	if g_currentMission.FarmingTablet.Appstore.apps[3] ~= nil then
		g_currentMission.FarmingTablet.Appstore.apps[3] = true;
	end;
	local daynum = string.format("%f", g_currentMission.environment.currentDay);
	Weekday = math.mod (daynum, 7);
	
	if self.kz ~= 0 then
		if g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[1].art ~= SoilExtension.schritte[4] 
		and g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[2].art ~= SoilExtension.schritte[4] 
		and g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[3].art ~= SoilExtension.schritte[4]
		and g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[4].art ~= SoilExtension.schritte[4]	then
			g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[4].art = SoilExtension.schritte[4];
			g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[5].art = SoilExtension.schritte[5];
			g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[6].art = SoilExtension.schritte[6];
			g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[7].art = SoilExtension.schritte[7];
			g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[8].art = SoilExtension.schritte[8];
			g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[9].art = SoilExtension.schritte[9];
			g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[4].pic = SoilExtension.schritte[4];
			g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[5].pic = SoilExtension.schritte[5];
			g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[6].pic = SoilExtension.schritte[6];
			g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[7].pic = SoilExtension.schritte[7];
			g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[8].pic = SoilExtension.schritte[8];
			g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[9].pic = SoilExtension.schritte[9];
			g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].tage = 10;
			if g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[2].pic == SoilExtension.schritte[5] then
				g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[2].art = SoilExtension.schritte[13];
				g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[2].pic = SoilExtension.schritte[13];
				g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[3].art = SoilExtension.schritte[13];
				g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[3].pic = SoilExtension.schritte[13];
			end;
			if g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[3].pic == SoilExtension.schritte[5] or g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[3].pic == SoilExtension.schritte[6] then
				g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[3].art = SoilExtension.schritte[13];
				g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[3].pic = SoilExtension.schritte[13];
			end;
			
		end;
		
	end;
	
	--Berechnung Endwerte
	
	if self.windows.bearbeiten.show then
		g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].endwerte = {};
		g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].endwerte.ph = g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].startwerte.ph;
		g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].endwerte.feuchte = g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].startwerte.feuchte;
		g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].endwerte.nWert = g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].startwerte.nWert;
		g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].endwerte.pkWert = g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].startwerte.pkWert;

		for i = 1, 10 do
			local ph = g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].endwerte.ph;
			local feuchte = g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].endwerte.feuchte;
			local nWert = g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].endwerte.nWert;
			local pkWert = 	g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].endwerte.pkWert;
			if g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[i].art == SoilExtension.schritte[1] then
				local endwerte = SoilExtensionAddOn:countPfluegen(g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[i].mittel, ph, feuchte, nWert, pkWert);
				g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].endwerte.ph = endwerte.ph;
				g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].endwerte.feuchte = endwerte.feuchte;
				g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].endwerte.nWert = endwerte.nWert;
				g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].endwerte.pkWert = endwerte.pkWert;
			elseif g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[i].art == SoilExtension.schritte[2] then
				local endwerte = SoilExtensionAddOn:countGrubbern(g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[i].mittel, ph, feuchte, nWert, pkWert);
				g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].endwerte.ph = endwerte.ph;
				g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].endwerte.feuchte = endwerte.feuchte;
				g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].endwerte.nWert = endwerte.nWert;
				g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].endwerte.pkWert = endwerte.pkWert;
			elseif g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[i].art == SoilExtension.schritte[3] then
				local endwerte = SoilExtensionAddOn:countAusbringen(g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[i].mittel, ph, feuchte, nWert, pkWert);
				g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].endwerte.ph = endwerte.ph;
				g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].endwerte.feuchte = endwerte.feuchte;
				g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].endwerte.nWert = endwerte.nWert;
				g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].endwerte.pkWert = endwerte.pkWert;
			end;
			
			if g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[i].pic == SoilExtension.schritte[5] then
				g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].endwerte.nWert = g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].endwerte.nWert - 1;
			elseif g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[i].pic == SoilExtension.schritte[6] then
				g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].endwerte.nWert = g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].endwerte.nWert - 1;
				g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].endwerte.feuchte = g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].endwerte.feuchte - 14;
			elseif g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[i].pic == SoilExtension.schritte[7] then
				if g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[i].art == SoilExtension.schritte[12] then
					return
				else
					g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].endwerte.nWert = g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].endwerte.nWert - 1;
					g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].endwerte.feuchte = g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].endwerte.feuchte - 14;
					g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].endwerte.pkWert = g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].endwerte.pkWert - 1;
					g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].endwerte.ph = g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].endwerte.ph - 1;
				end;
			elseif g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[i].pic == SoilExtension.schritte[8] then
				g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].endwerte.nWert = g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].endwerte.nWert - 1;
			elseif g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[i].pic == SoilExtension.schritte[9] then
				g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].endwerte.nWert = g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].endwerte.nWert - 1;
				g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].endwerte.feuchte = g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].endwerte.feuchte - 14;
				g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].endwerte.pkWert = g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].endwerte.pkWert - 1;
			elseif g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[i].pic == SoilExtension.schritte[10] then
				g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].endwerte.nWert = g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].endwerte.nWert - 1;
			end;
		end;
		
		
		
	end;
end;

function SoilExtension:keyEventSoilExtension(unicode, sym, modifier, isDown) 
	--if self.tab1.btnErstellen and isDown then
	--	if unicode == 0.0 then
	--	else
	--		self.tab1.fenster_feldhinzu.name = self.tab1.fenster_feldhinzu.name..string.char(unicode);
	--	end;
	--end;
	if self.windows.erstellen.show then
		if sym == 8 then
			local leng = string.len(self.windows.erstellen.text);
			self.windows.erstellen.text = string.sub(self.windows.erstellen.text, 1, leng-1);
		elseif sym ~= 8 and unicode ~= 0.0 then
			self.windows.erstellen.text = self.windows.erstellen.text..string.char(unicode);
		end;
	end;
end;

function SoilExtension:drawSoilExtension ()
	--Allgemein
	setTextColor(1, 1, 1, 1);
	renderText(0.728, 0.833, 0.03, tostring(self.uhr1..":"..self.uhr2));
	if g_currentMission.FarmingTablet.Settings.akkuFuel < 162000 then
		renderOverlay(FarmingTablet.overlay.akkuRed, 0.8, 0.815, 0.05, 0.06);
		renderOverlay(FarmingTablet.overlay.akku1, 0.8, 0.815, 0.05, 0.06);
	elseif g_currentMission.FarmingTablet.Settings.akkuFuel >= 162000 and g_currentMission.FarmingTablet.Settings.akkuFuel < 324000 then
		renderOverlay(FarmingTablet.overlay.akku, 0.8, 0.815, 0.05, 0.06);
		renderOverlay(FarmingTablet.overlay.akku1, 0.8, 0.815, 0.05, 0.06);
		renderOverlay(FarmingTablet.overlay.akku2, 0.8, 0.815, 0.05, 0.06);	
	elseif g_currentMission.FarmingTablet.Settings.akkuFuel >= 324000 and g_currentMission.FarmingTablet.Settings.akkuFuel < 486000 then	
		renderOverlay(FarmingTablet.overlay.akku, 0.8, 0.815, 0.05, 0.06);
		renderOverlay(FarmingTablet.overlay.akku1, 0.8, 0.815, 0.05, 0.06);
		renderOverlay(FarmingTablet.overlay.akku2, 0.8, 0.815, 0.05, 0.06);	
		renderOverlay(FarmingTablet.overlay.akku3, 0.8, 0.815, 0.05, 0.06);	
	elseif g_currentMission.FarmingTablet.Settings.akkuFuel >= 324000 and g_currentMission.FarmingTablet.Settings.akkuFuel < 648000 then	
		renderOverlay(FarmingTablet.overlay.akku, 0.8, 0.815, 0.05, 0.06);
		renderOverlay(FarmingTablet.overlay.akku1, 0.8, 0.815, 0.05, 0.06);
		renderOverlay(FarmingTablet.overlay.akku2, 0.8, 0.815, 0.05, 0.06);	
		renderOverlay(FarmingTablet.overlay.akku3, 0.8, 0.815, 0.05, 0.06);	
		renderOverlay(FarmingTablet.overlay.akku4, 0.8, 0.815, 0.05, 0.06);
	end;
	renderText(0.86, 0.833, 0.03, tostring(string.format("%.f", g_currentMission.FarmingTablet.Settings.akkuFuel/6480))..tostring("%"));
	renderText(0.1, 0.833, 0.03, tostring("Soilmanagement"));
	renderText(0.5, 0.835, 0.03, tostring(SoilExtension.days[Weekday]));
	renderText(0.57, 0.835, 0.03, tostring(g_currentMission.environment.currentDay..". Tag"));
	setTextColor(0, 0, 0, 1);
	--
	
	if 	self.windows.uerbersicht.show then
		
		renderOverlay(FarmingTablet.overlay.acker, 0.01, 0.01, 1, 1.5);
		renderOverlay(FarmingTablet.overlay.buttons, 0.01, 0.01, 1, 1.5);
		renderText(0.765, 0.758, 0.03, tostring("Feld erstellen"));
		renderText(0.765, 0.656, 0.03, tostring("Feld bearbeiten"));
		renderText(0.765, 0.551, 0.03, tostring("Feld löschen"));
		renderText(0.765, 0.383, 0.03, tostring("Speichern"));
		renderText(0.765, 0.288, 0.03, tostring("Schließen"));
		
		if g_currentMission.FarmingTablet.SoilExtension.daten.fields ~= nil then
			for i = 1, #g_currentMission.FarmingTablet.SoilExtension.daten.fields do
				if g_currentMission.FarmingTablet.SoilExtension.daten.fields[i].name ~= nil then
					setTextColor(0, 0, 0, 1);
					renderText(0.12, 0.76-((i-1)*0.05), 0.035, g_currentMission.FarmingTablet.SoilExtension.daten.fields[i].name);
					if self.windows.uerbersicht.kz[i] then
						setTextColor(1,0,0,1);
						renderText(0.12, 0.76-((i-1)*0.05), 0.035, g_currentMission.FarmingTablet.SoilExtension.daten.fields[i].name);
						setTextColor(0, 0, 0, 1);
					end;
				end;
			end;		
		end;
	elseif self.windows.erstellen.show then
	
		renderOverlay(FarmingTablet.overlay.leer, 0.01, 0.01, 1, 1.5);
		renderOverlay(FarmingTablet.overlay.fenster_feldhinzu, 0.01, 0.01, 1, 1.5);
		renderText(0.331, 0.282, 0.03, tostring("Feld hinzufügen"));
		renderText(0.518, 0.282, 0.03, tostring("Abbruch"));				
		renderText(0.338, 0.529, 0.03, tostring(self.windows.erstellen.text));
				
	elseif self.windows.bearbeiten.show then
	
		renderOverlay(FarmingTablet.overlay.weizenfeld, 0.01, 0.01, 1, 1.5);
		renderOverlay(FarmingTablet.overlay.bearbeiten_hud, 0.1, 0.705, 0.04, 0.04);
		renderOverlay(FarmingTablet.overlay.bearbeiten_hud, 0.610, 0.756, 0.04, 0.04);
		renderOverlay(FarmingTablet.overlay.linie, 0.093, 0.685, 0.815, 0.005);
		setTextColor(1, 1, 1, 1);
		renderText(0.4, 0.833, 0.03, tostring(g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].name));
		setTextColor(0, 0, 0, 1);
		renderText(0.596, 0.183, 0.025, tostring("Speichern & Schließen"));
		renderText(0.596, 0.183, 0.025, tostring("Speichern & Schließen"));
		renderText(0.764, 0.183, 0.025, tostring("Zurücksetzen"));
		renderText(0.764, 0.183, 0.025, tostring("Zurücksetzen"));
		renderText(0.1, 0.768, 0.03, tostring("Frucht:"));
		renderText(0.1, 0.768, 0.03, tostring("Frucht:"));
		renderText(0.344, 0.768, 0.03, tostring("Empfohlener Herbizid:"));
		renderText(0.344, 0.768, 0.03, tostring("Empfohlener Herbizid:"));
		renderText(0.524, 0.768, 0.03, tostring"   |    |");
		renderText(0.654, 0.768, 0.03, tostring"Wetter:");
		renderText(0.654, 0.768, 0.03, tostring"Wetter:");
		renderText(0.15, 0.705, 0.03, tostring("Startwerte:"));
		renderText(0.15, 0.705, 0.03, tostring("Startwerte:"));
		renderText(0.26, 0.705, 0.03, tostring("Boden pH:"));
		renderText(0.5, 0.705, 0.03, tostring("Boden Feuchtigkeit:"));
		renderText(0.75, 0.705, 0.03, tostring("N:"));
		renderText(0.82, 0.705, 0.03, tostring("PK:"));
		
		renderText(0.353, 0.705, 0.03, tostring(string.format("%.1f", g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].startwerte.ph)));
		renderText(0.666, 0.705, 0.03, tostring(g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].startwerte.feuchte)..tostring(" %"));
		renderText(0.777, 0.705, 0.03, tostring(g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].startwerte.nWert));
		renderText(0.851, 0.705, 0.03, tostring(g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].startwerte.pkWert));	
		renderText(0.72, 0.768, 0.03, tostring(g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].wetter.warm.." x > 21°C  |"));
		renderText(0.83, 0.768, 0.03, tostring(" "..g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].wetter.regenTage.." h Regen"));
			
		renderText(0.179, 0.768, 0.03, tostring(g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].frucht));
		
		for i=1, 9 do 
			if g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].frucht == SoilExtension.werte.herbizid.art.a[i] then
				setTextColor(0,1,0,1);
				renderText(0.524, 0.768, 0.03, tostring"A");
				renderText(0.524, 0.768, 0.03, tostring"A");
				renderText(0.524, 0.768, 0.03, tostring"A");
				break
			else
				setTextColor(1,0,0,1);
				renderText(0.524, 0.768, 0.03, tostring"A");
				renderText(0.524, 0.768, 0.03, tostring"A");
				renderText(0.524, 0.768, 0.03, tostring"A");
			end;
		end;
		for i=1, 9 do 
			if g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].frucht == SoilExtension.werte.herbizid.art.b[i] then
				setTextColor(0,1,0,1);
				renderText(0.524, 0.768, 0.03, tostring"      B");
				renderText(0.524, 0.768, 0.03, tostring"      B");
				renderText(0.524, 0.768, 0.03, tostring"      B");
				break;
			else
				setTextColor(1,0,0,1);
				renderText(0.524, 0.768, 0.03, tostring"      B");
				renderText(0.524, 0.768, 0.03, tostring"      B");
				renderText(0.524, 0.768, 0.03, tostring"      B");
			end;
		end;
	
		for i=1, 10 do 
			if g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].frucht == SoilExtension.werte.herbizid.art.c[i] then
				setTextColor(0,1,0,1);
				renderText(0.524, 0.768, 0.03, tostring"            C");
				renderText(0.524, 0.768, 0.03, tostring"            C");
				renderText(0.524, 0.768, 0.03, tostring"            C");
				break;
			else
				setTextColor(1,0,0,1);
				renderText(0.524, 0.768, 0.03, tostring"            C");
				renderText(0.524, 0.768, 0.03, tostring"            C");
				renderText(0.524, 0.768, 0.03, tostring"            C");
			end;
		end;
		setTextColor(0, 0, 0, 1);
		for i=0, (g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].tage - 1) do
			if i < 6 then
				renderText((0.102+(0.135*i)), 0.639, 0.027, tostring(SoilExtension.days[math.mod (string.format("%f", (g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].tag+i)), 7)].." ("..g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].tag+(i*1)..")"));
			elseif i >= 6 then
				renderText((0.102+(0.13*(i-6))), 0.420, 0.026, tostring(SoilExtension.days[math.mod (string.format("%f", (g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].tag+i)), 7)].." ("..g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].tag+(i*1)..")"));
			end;
		end;
		if g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].tage == 7 then 
			renderOverlay(FarmingTablet.overlay.feld_grau, 0.098, 0.524, 0.12, 0.05);
		elseif g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].tage == 8 then
			renderOverlay(FarmingTablet.overlay.feld_grau, 0.098, 0.524, 0.12, 0.05);
			renderOverlay(FarmingTablet.overlay.feld_grau, 0.24, 0.524, 0.12, 0.05);
		elseif g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].tage == 9 then
			renderOverlay(FarmingTablet.overlay.feld_grau, 0.098, 0.524, 0.12, 0.05);
			renderOverlay(FarmingTablet.overlay.feld_grau, 0.24, 0.524, 0.12, 0.05);
			renderOverlay(FarmingTablet.overlay.feld_grau, 0.375, 0.524, 0.12, 0.05);
		elseif g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].tage == 10 then
			renderOverlay(FarmingTablet.overlay.feld_grau, 0.098, 0.524, 0.12, 0.05);
			renderOverlay(FarmingTablet.overlay.feld_grau, 0.24, 0.524, 0.12, 0.05);
			renderOverlay(FarmingTablet.overlay.feld_grau, 0.375, 0.524, 0.12, 0.05);
			renderOverlay(FarmingTablet.overlay.feld_grau, 0.508, 0.524, 0.12, 0.05);
		end;	
		for i = 1, g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].tage do
			if g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[i].pic == SoilExtension.schritte[13] then
				SoilExtensionAddOn:setOverlay(i, 13);
			elseif g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[i].pic == SoilExtension.schritte[1] then
				SoilExtensionAddOn:setOverlay(i, 1);
			elseif g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[i].pic == SoilExtension.schritte[2] then
				SoilExtensionAddOn:setOverlay(i, 2);
			elseif g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[i].pic == SoilExtension.schritte[3] then
				SoilExtensionAddOn:setOverlay(i, 3);
			elseif g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[i].pic == SoilExtension.schritte[4] then
				SoilExtensionAddOn:setOverlay(i, 4);
			elseif g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[i].pic == SoilExtension.schritte[5] then
				SoilExtensionAddOn:setOverlay(i, 5);
			elseif g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[i].pic == SoilExtension.schritte[6] then
				SoilExtensionAddOn:setOverlay(i, 6);
			elseif g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[i].pic == SoilExtension.schritte[7] then
				SoilExtensionAddOn:setOverlay(i, 7);
			elseif g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[i].pic == SoilExtension.schritte[8] then
				SoilExtensionAddOn:setOverlay(i, 8);
			elseif g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[i].pic == SoilExtension.schritte[9] then
				SoilExtensionAddOn:setOverlay(i, 9);
			elseif g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[i].pic == SoilExtension.schritte[10] then
				SoilExtensionAddOn:setOverlay(i, 10);
			end;
		end;
		
		if g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[1].art == SoilExtension.schritte[4] then
			renderText(0.242, 0.531, 0.025, tostring("Ausbringen"));
			renderText(0.38, 0.531, 0.025, tostring("Ausbringen"));	
			renderText(0.103, 0.531, 0.03, tostring(g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].frucht));	
			renderText(0.245, 0.481, 0.025, tostring(g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[2].mittel));
			renderText(0.381, 0.481, 0.025, tostring(g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[3].mittel));
			renderOverlay(FarmingTablet.overlay.feld_grau, 0.242, 0.470, 0.1, 0.05);
			renderOverlay(FarmingTablet.overlay.feld_grau, 0.38, 0.470, 0.1, 0.05);
			if g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[4].art == SoilExtension.schritte[12] then
				renderText(0.518, 0.531, 0.025, tostring(g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[4].art));	
			elseif g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[4].art == SoilExtension.schritte[3] or g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[4].art == SoilExtension.schritte[13] then
				renderOverlay(FarmingTablet.overlay.feld_grau, 0.518, 0.470, 0.1, 0.05);
				renderText(0.518, 0.531, 0.025, tostring(g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[4].art));	
				if g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[4].art == SoilExtension.schritte[3] then
					renderText(0.519, 0.481, 0.025, tostring(g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[4].mittel));	
				end;
				if g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[5].art == SoilExtension.schritte[12] then
					renderText(0.656, 0.531, 0.025, tostring(g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[5].art));
				elseif g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[5].art == SoilExtension.schritte[3] or g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[5].art == SoilExtension.schritte[13] then
					renderOverlay(FarmingTablet.overlay.feld_grau, 0.656, 0.470, 0.1, 0.05);
					renderText(0.656, 0.531, 0.025, tostring(g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[5].art));
					if g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[5].art == SoilExtension.schritte[3] then
						renderText(0.658, 0.481, 0.025, tostring(g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[5].mittel));	
					end;
					if g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[6].art == SoilExtension.schritte[12] then
						renderText(0.794, 0.531, 0.025, tostring(g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[6].art));
					elseif	g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[6].art == SoilExtension.schritte[3] or g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[6].art == SoilExtension.schritte[13] then
						renderOverlay(FarmingTablet.overlay.feld_grau, 0.794, 0.470, 0.1, 0.05);
						renderText(0.794, 0.531, 0.025, tostring(g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[6].art));
						if g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[6].art == SoilExtension.schritte[3] then
							renderText(0.796, 0.481, 0.025, tostring(g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[6].mittel));	
						end;
						if g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[7].art == SoilExtension.schritte[12] then
							renderText(0.104, 0.312, 0.025, tostring(g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[7].art));
						elseif	g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[7].art == SoilExtension.schritte[3] or g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[7].art == SoilExtension.schritte[13] then
							renderOverlay(FarmingTablet.overlay.feld_grau, 0.104, 0.247, 0.1, 0.05);
							renderText(0.104, 0.312, 0.025, tostring(g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[7].art));
							if g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[7].art == SoilExtension.schritte[3] then
								renderText(0.104, 0.262, 0.025, tostring(g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[7].mittel));
							end;
						elseif	g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[5].art == SoilExtension.schritte[14] then 
							renderText(0.656, 0.531, 0.025, tostring(""));
						end;
					elseif	g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[5].art == SoilExtension.schritte[14] then
						renderText(0.656, 0.531, 0.025, tostring(""));
					end;
				elseif	g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[5].art == SoilExtension.schritte[14] then
					renderText(0.656, 0.531, 0.025, tostring(""));
				end;
			end;		
		elseif g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[2].art == SoilExtension.schritte[4] then
			renderText(0.38, 0.531, 0.025, tostring("Ausbringen"));	
			renderText(0.518, 0.531, 0.025, tostring("Ausbringen"));
			local art = g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[1].art ;
			if art == SoilExtension.schritte[1] or art == SoilExtension.schritte[2] or art == SoilExtension.schritte[3] then
				renderText(0.1, 0.531, 0.03, tostring(g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[1].mittel));
			end;
			renderText(0.246, 0.531, 0.03, tostring(g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].frucht));
			renderText(0.381, 0.481, 0.025, tostring(g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[3].mittel));
			renderText(0.519, 0.481, 0.025, tostring(g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[4].mittel));	
			renderOverlay(FarmingTablet.overlay.feld_grau, 0.38, 0.470, 0.1, 0.05);
			renderOverlay(FarmingTablet.overlay.feld_grau, 0.518, 0.470, 0.1, 0.05);
			if g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[5].art == SoilExtension.schritte[12] then
				renderText(0.656, 0.531, 0.025, tostring(g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[5].art));
			elseif g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[5].art == SoilExtension.schritte[3] or g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[5].art == SoilExtension.schritte[13] then
				renderOverlay(FarmingTablet.overlay.feld_grau, 0.656, 0.470, 0.1, 0.05);
				renderText(0.656, 0.531, 0.025, tostring(g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[5].art));
				if g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[5].art == SoilExtension.schritte[3] then
					renderText(0.658, 0.481, 0.025, tostring(g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[5].mittel));
				end;
				if g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[6].art == SoilExtension.schritte[12] then
					renderText(0.794, 0.531, 0.025, tostring(g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[6].art));
				elseif	g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[6].art == SoilExtension.schritte[3] or g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[6].art == SoilExtension.schritte[13] then
					renderOverlay(FarmingTablet.overlay.feld_grau, 0.794, 0.470, 0.1, 0.05);
					renderText(0.794, 0.531, 0.025, tostring(g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[6].art));
					if g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[6].art == SoilExtension.schritte[3] then
						renderText(0.796, 0.481, 0.025, tostring(g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[6].mittel));
					end;
					if g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[7].art == SoilExtension.schritte[12] then
						renderText(0.104, 0.312, 0.025, tostring(g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[7].art));
					elseif	g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[7].art == SoilExtension.schritte[3] or g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[7].art == SoilExtension.schritte[13] then
						renderOverlay(FarmingTablet.overlay.feld_grau, 0.104, 0.247, 0.1, 0.05);
						renderText(0.104, 0.312, 0.025, tostring(g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[7].art));
						if g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[7].art == SoilExtension.schritte[3] then
							renderText(0.104, 0.262, 0.025, tostring(g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[7].mittel));
						end;
						if g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[8].art == SoilExtension.schritte[12] then
							renderText(0.24, 0.312, 0.025, tostring(g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[8].art));	
						elseif	g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[8].art == SoilExtension.schritte[3] or g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[8].art == SoilExtension.schritte[13] then
							renderOverlay(FarmingTablet.overlay.feld_grau, 0.24, 0.247, 0.1, 0.05);
							renderText(0.24, 0.312, 0.025, tostring(g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[8].art));	
							if g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[8].art == SoilExtension.schritte[3] then
								renderText(0.24, 0.262, 0.025, tostring(g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[8].mittel));
							end;
						elseif	g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[8].art == SoilExtension.schritte[14] then 
							renderText(0.24, 0.312, 0.025, tostring(""));	
						end;
					elseif	g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[7].art == SoilExtension.schritte[14] then
						renderText(0.104, 0.312, 0.025, tostring(""));
					end;
				elseif	g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[6].art == SoilExtension.schritte[14] then
					renderText(0.794, 0.531, 0.025, tostring(""));
				end;
			end;
			
		elseif g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[3].art == SoilExtension.schritte[4] then
			renderText(0.656, 0.531, 0.025, tostring("Ausbringen"));
			renderText(0.518, 0.531, 0.025, tostring("Ausbringen"));
			local art = g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[1].art ;
			local art2 = g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[2].art ;
			if art == SoilExtension.schritte[1] or art == SoilExtension.schritte[2] or art == SoilExtension.schritte[3] then
				renderText(0.1, 0.531, 0.03, tostring(g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[1].mittel));
			end;
			if art2 == SoilExtension.schritte[1] or art2 == SoilExtension.schritte[2] or art2 == SoilExtension.schritte[3] then
				renderText(0.242, 0.531, 0.03, tostring(g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[2].mittel));
			end;			
			renderText(0.38, 0.531, 0.03, tostring(g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].frucht));	
			renderText(0.519, 0.481, 0.025, tostring(g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[4].mittel));	
			renderText(0.658, 0.481, 0.025, tostring(g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[5].mittel));
			renderOverlay(FarmingTablet.overlay.feld_grau, 0.656, 0.470, 0.1, 0.05);
			renderOverlay(FarmingTablet.overlay.feld_grau, 0.518, 0.470, 0.1, 0.05);
			if g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[6].art == SoilExtension.schritte[12] then
				renderText(0.794, 0.531, 0.025, tostring(g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[6].art));
			elseif g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[6].art == SoilExtension.schritte[3] or g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[6].art == SoilExtension.schritte[13] then
				renderOverlay(FarmingTablet.overlay.feld_grau, 0.794, 0.470, 0.1, 0.05);
				renderText(0.794, 0.531, 0.025, tostring(g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[6].art));
				if g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[6].art == SoilExtension.schritte[3] then
					renderText(0.796, 0.481, 0.025, tostring(g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[6].mittel));
				end;
				if g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[7].art == SoilExtension.schritte[12] then
					renderText(0.104, 0.312, 0.025, tostring(g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[7].art));
				elseif	g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[7].art == SoilExtension.schritte[3] or g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[7].art == SoilExtension.schritte[13] then
					renderOverlay(FarmingTablet.overlay.feld_grau, 0.104, 0.247, 0.1, 0.05);
					renderText(0.104, 0.312, 0.025, tostring(g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[7].art));
					if g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[7].art == SoilExtension.schritte[3] then
						renderText(0.104, 0.262, 0.025, tostring(g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[7].mittel));
					end;
					if g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[8].art == SoilExtension.schritte[12] then
						renderText(0.24, 0.312, 0.025, tostring(g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[8].art));
					elseif g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[8].art == SoilExtension.schritte[3] or g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[8].art == SoilExtension.schritte[13] then
						renderOverlay(FarmingTablet.overlay.feld_grau, 0.24, 0.247, 0.1, 0.05);
						renderText(0.24, 0.312, 0.025, tostring(g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[8].art));
						if g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[8].art == SoilExtension.schritte[3] then
							renderText(0.24, 0.262, 0.025, tostring(g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[8].mittel));
						end;
						if g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[9].art == SoilExtension.schritte[12] then
							renderText(0.361, 0.312, 0.025, tostring(g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[9].art));	
						elseif	g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[9].art == SoilExtension.schritte[3] or g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[9].art == SoilExtension.schritte[13] then
							renderOverlay(FarmingTablet.overlay.feld_grau, 0.361, 0.247, 0.1, 0.05);
							renderText(0.361, 0.312, 0.025, tostring(g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[9].art));
							if g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[9].art == SoilExtension.schritte[3] then
								renderText(0.361, 0.262, 0.025, tostring(g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[9].mittel));
							end;
						elseif	g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[9].art == SoilExtension.schritte[14] then 
							renderText(0.361, 0.312, 0.025, tostring(""));	
						end;
					elseif	g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[8].art == SoilExtension.schritte[14] then
						renderText(0.24, 0.312, 0.025, tostring(""));
					end;
				elseif	g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[7].art == SoilExtension.schritte[14] then
					renderText(0.104, 0.312, 0.025, tostring(""));
				end;
			end;	
		elseif g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[4].art == SoilExtension.schritte[4] then
			renderText(0.794, 0.531, 0.025, tostring("Ausbringen"));
			renderText(0.656, 0.531, 0.025, tostring("Ausbringen"));
			local art = g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[1].art ;
			local art2 = g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[2].art ;
			local art3 = g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[3].art ;
			if art == SoilExtension.schritte[1] or art == SoilExtension.schritte[2] or art == SoilExtension.schritte[3] then
				renderText(0.1, 0.531, 0.03, tostring(g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[1].mittel));
			end;
			if art2 == SoilExtension.schritte[1] or art2 == SoilExtension.schritte[2] or art2 == SoilExtension.schritte[3] then
				renderText(0.242, 0.531, 0.03, tostring(g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[2].mittel));
			end;		
			if art3 == SoilExtension.schritte[1] or art3 == SoilExtension.schritte[2] or art3 == SoilExtension.schritte[3] then
				renderText(0.376, 0.531, 0.03, tostring(g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[3].mittel));
			end;			
			renderText(0.661, 0.481, 0.025, tostring(g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[5].mittel));
			renderText(0.796, 0.481, 0.025, tostring(g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[6].mittel));
			renderText(0.513, 0.531, 0.03, tostring(g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].frucht));	
			renderOverlay(FarmingTablet.overlay.feld_grau, 0.794, 0.470, 0.1, 0.05);
			renderOverlay(FarmingTablet.overlay.feld_grau, 0.656, 0.470, 0.1, 0.05);
			if g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[7].art == SoilExtension.schritte[12] then
				renderText(0.104, 0.312, 0.025, tostring(g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[7].art));
			elseif g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[7].art == SoilExtension.schritte[3] or g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[7].art == SoilExtension.schritte[13] then
				renderOverlay(FarmingTablet.overlay.feld_grau, 0.104, 0.247, 0.1, 0.05);
				renderText(0.104, 0.312, 0.025, tostring(g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[7].art));
				if g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[7].art == SoilExtension.schritte[3] then
					renderText(0.104, 0.262, 0.025, tostring(g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[7].mittel));
				end;
				if g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[8].art == SoilExtension.schritte[12] then
					renderText(0.24, 0.312, 0.025, tostring(g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[8].art));
				elseif	g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[8].art == SoilExtension.schritte[3] or g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[8].art == SoilExtension.schritte[13] then
					renderOverlay(FarmingTablet.overlay.feld_grau, 0.24, 0.247, 0.1, 0.05);
					renderText(0.24, 0.312, 0.025, tostring(g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[8].art));
					if g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[8].art == SoilExtension.schritte[3] then
						renderText(0.24, 0.262, 0.025, tostring(g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[8].mittel));
					end;
					if g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[9].art == SoilExtension.schritte[12] then
						renderText(0.361, 0.312, 0.025, tostring(g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[9].art));
					elseif	g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[9].art == SoilExtension.schritte[3] or g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[9].art == SoilExtension.schritte[13] then
						renderOverlay(FarmingTablet.overlay.feld_grau, 0.361, 0.247, 0.1, 0.05);
						renderText(0.361, 0.312, 0.025, tostring(g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[9].art));
						if g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[9].art == SoilExtension.schritte[3] then
							renderText(0.361, 0.262, 0.025, tostring(g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[9].mittel));
						end;
						if g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[10].art == SoilExtension.schritte[12] then
							renderText(0.489, 0.312, 0.025, tostring(g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[10].art));
						elseif	g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[10].art == SoilExtension.schritte[3] or g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[10].art == SoilExtension.schritte[13] then
							renderOverlay(FarmingTablet.overlay.feld_grau, 0.489, 0.247, 0.1, 0.05);
							renderText(0.489, 0.312, 0.025, tostring(g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[10].art));
							if g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[10].art == SoilExtension.schritte[3] then
								renderText(0.491, 0.262, 0.025, tostring(g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[10].mittel));
							end;
						elseif	g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[10].art == SoilExtension.schritte[14] then 
							renderText(0.489, 0.312, 0.025, tostring(""));
						end;
					elseif	g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[9].art == SoilExtension.schritte[14] then
						renderText(0.361, 0.312, 0.025, tostring(""));
					end;
				elseif	g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].schritte[8].art == SoilExtension.schritte[14] then
					renderText(0.24, 0.312, 0.025, tostring(""));
				end;
			end;
		end;
		if g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].endwerte.feuchte >= 29 and g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].endwerte.feuchte <= 85 and g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].endwerte.nWert >= 3 and g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].endwerte.nWert < 10 and g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].endwerte.pkWert >= 3 and g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].endwerte.pkWert < 6 and g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].endwerte.ph >= 6.2 and g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].endwerte.ph < 7.5 then
			renderOverlay(FarmingTablet.overlay.hud_endwert_grun, 0.01, 0.01, 1, 1.5);
		elseif  (g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].endwerte.feuchte < 29  and g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].endwerte.feuchte >= 14) or (g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].endwerte.feuchte <= 95  and g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].endwerte.feuchte > 85) and (g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].endwerte.nWert < 3 and g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].endwerte.nWert >= 2) or (g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].endwerte.nWert >= 10 and g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].endwerte.nWert < 12) and (g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].endwerte.pkWert < 3 and g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].endwerte.pkWert >= 2) or (g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].endwerte.pkWert >= 6 and g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].endwerte.pkWert <= 7) and (g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].endwerte.ph < 6.2 and g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].endwerte.ph > 5.8) or  (g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].endwerte.ph >= 7.5 and g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].endwerte.ph < 8.1) then
			renderOverlay(FarmingTablet.overlay.hud_endwert_gelb, 0.01, 0.01, 1, 1.5);
		elseif  (g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].endwerte.feuchte < 14  and g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].endwerte.feuchte >= 0) or (g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].endwerte.feuchte <= 100  and g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].endwerte.feuchte > 95) and g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].endwerte.nWert < 2 or g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].endwerte.nWert > 12 and g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].endwerte.pkWert < 2 or g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].endwerte.pkWert > 7 and (g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].endwerte.ph < 5.8 or  g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].endwerte.ph >= 8.1) then
			renderOverlay(FarmingTablet.overlay.hud_endwert_rot, 0.01, 0.01, 1, 1.5);
		else
			renderOverlay(FarmingTablet.overlay.hud_endwert_gelb, 0.01, 0.01, 1, 1.5);
		end;
	
		renderText(0.609, 0.393, 0.03, tostring("Boden pH:"));
		renderText(0.609, 0.354, 0.03, tostring("Boden Feuchtigkeit:"));
		renderText(0.609, 0.315, 0.03, tostring("Nährstoffe (N):"));
		renderText(0.609, 0.276, 0.03, tostring("Nährstoffe (PK):"));
		renderText(0.778, 0.393, 0.03, tostring(string.format("%.1f", g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].endwerte.ph).."   (6.8)"));
		renderText(0.778, 0.354, 0.03, tostring(g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].endwerte.feuchte.." %   (57%)"));
		renderText(0.778, 0.315, 0.03, tostring(g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].endwerte.nWert.."   (5)"));
		renderText(0.778, 0.276, 0.03, tostring(g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].endwerte.pkWert.."   (4)"));
		
	elseif self.windows.speichern.show then
		self.saveBalken = self.saveBalken + 1;
		renderOverlay(FarmingTablet.overlay.leer, 0.01, 0.01, 1, 1.5);
		renderOverlay(FarmingTablet.overlay.fenster_speichern, 0.01, 0.01, 1, 1.5);
		renderOverlay(FarmingTablet.overlay.balken, 0.36, 0.5, 0.3*(self.saveBalken/50), 0.05);
		self.saveBalken = self.saveBalken + 1;
		if self.saveBalken == 50 then
			self.windows.speichern.show = false;
			self.windows.uerbersicht.show = true;
			self.saveBalken = 0;
		end;
		
	elseif self.windows.fruchtAuswahl.show then
		
		renderOverlay(FarmingTablet.overlay.leer, 0.01, 0.01, 1, 1.5);
		renderOverlay(FarmingTablet.overlay.fenster_auswahl2, 0.01, 0.01, 1, 1.5);
		renderText(0.462, 0.23, 0.04, tostring("Abbrechen"));
		renderText(0.246, 0.675, 0.03, tostring("Welche Frucht soll gesäht werden?"));
		renderText(0.246, 0.675, 0.03, tostring("Welche Frucht soll gesäht werden?"));
		for i=0, 13 do
			if i <= 3 then
				renderText(0.25, 0.62-(i*0.055), 0.037, tostring(SoilExtension.werte.fruechte[i+1]));
			elseif i > 3 and i <= 7 then
				renderText(0.36, 0.62-((i-4)*0.055), 0.037, tostring(SoilExtension.werte.fruechte[i+1]));
			elseif i > 7 and i <= 11 then
				renderText(0.47, 0.62-((i-8)*0.055), 0.037, tostring(SoilExtension.werte.fruechte[i+1]));
			elseif i > 11 and i <= 13 then
				renderText(0.6, 0.62-((i-12)*0.055), 0.037, tostring(SoilExtension.werte.fruechte[i+1]));
			end;
		end; 
		
	
	
	elseif self.windows.wetterAuswahl.show then
		renderOverlay(FarmingTablet.overlay.leer, 0.01, 0.01, 1, 1.5);
		renderOverlay(FarmingTablet.overlay.fenster_wetter, 0.01, 0.01, 1, 1.5);
		renderText(0.261, 0.238, 0.04, tostring("Speichern & schließen"));
		renderText(0.604, 0.238, 0.04, tostring("Abbrechen"));
		renderText(0.246, 0.675, 0.03, tostring("Wie wird das Wetter in den kommenden Tagen?"));
		renderText(0.246, 0.675, 0.03, tostring("Wie wird das Wetter in den kommenden Tagen?"));
		renderText(0.257, 0.623, 0.03, tostring("Tage über 21°:"));
		renderText(0.263, 0.462, 0.03, tostring(g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].wetter.regenTage));
		renderText(0.263, 0.575, 0.03, tostring(g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].wetter.warm));
	elseif self.windows.startwerteAuswahl.show then
		renderOverlay(FarmingTablet.overlay.leer, 0.01, 0.01, 1, 1.5);
		renderOverlay(FarmingTablet.overlay.fenster_startwerte, 0.01, 0.01, 1, 1.5);
		renderText(0.261, 0.238, 0.04, tostring("Speichern & schließen"));
		renderText(0.604, 0.238, 0.04, tostring("Abbrechen"));
		renderText(0.246, 0.675, 0.03, tostring("Geben Sie die Startwerte des Feldes ein!"));
		renderText(0.246, 0.675, 0.03, tostring("Geben Sie die Startwerte des Feldes ein!"));
		
		renderText(0.263, 0.635, 0.03, tostring("Boden pH-Wert:"));
		renderText(0.263, 0.537, 0.03, tostring("Boden Feuchtigkeit:"));
		renderText(0.263, 0.452, 0.03, tostring("Nährstoffe (N):"));
		renderText(0.263, 0.352, 0.03, tostring("Nährstoffe (PK):"));
		renderText(0.263, 0.59, 0.03, tostring(string.format("%.1f", g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].startwerte.ph)));
		renderText(0.263, 0.493, 0.03, tostring(g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].startwerte.feuchte));
		renderText(0.263, 0.406, 0.03, tostring(g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].startwerte.nWert));
		renderText(0.263, 0.308, 0.03, tostring(g_currentMission.FarmingTablet.SoilExtension.daten.fields[self.kz].startwerte.pkWert));
	elseif self.windows.art.show then
		renderOverlay(FarmingTablet.overlay.leer, 0.01, 0.01, 1, 1.5);
		renderOverlay(FarmingTablet.overlay.fenster_auswahl2, 0.01, 0.01, 1, 1.5);
		renderText(0.462, 0.23, 0.04, tostring("Abbrechen"));
		renderText(0.246, 0.675, 0.03, tostring("Was wollen Sie tun?"));
		renderText(0.246, 0.675, 0.03, tostring("Was wollen Sie tun?"));
		for i = 0, 3 do
			renderText(0.25, 0.62-(i*0.055), 0.037, tostring(SoilExtension.schritte[i+1]));
		end; 
	elseif self.windows.art2.show then
		renderOverlay(FarmingTablet.overlay.leer, 0.01, 0.01, 1, 1.5);
		renderOverlay(FarmingTablet.overlay.fenster_auswahl2, 0.01, 0.01, 1, 1.5);
		renderText(0.462, 0.23, 0.04, tostring("Abbrechen"));
		renderText(0.246, 0.675, 0.03, tostring("Was wollen Sie tun?"));
		renderText(0.246, 0.675, 0.03, tostring("Was wollen Sie tun?"));
		renderText(0.25, 0.62, 0.037, tostring(SoilExtension.schritte[3]));
		renderText(0.25, 0.565, 0.037, tostring(SoilExtension.schritte[12]));
	elseif self.windows.mittelGrubbern then
		renderOverlay(FarmingTablet.overlay.leer, 0.01, 0.01, 1, 1.5);
		renderOverlay(FarmingTablet.overlay.fenster_auswahl2, 0.01, 0.01, 1, 1.5);
		renderText(0.462, 0.23, 0.04, tostring("Abbrechen"));
		renderText(0.246, 0.675, 0.03, tostring("Was sollen Sie eingrubbern?"));
		renderText(0.246, 0.675, 0.03, tostring("Was sollen Sie eingrubbern?"));
		for i = 0, 4 do
			renderText(0.25, 0.62-(i*0.05), 0.035, tostring(SoilExtension.grubbern[i+1]));
		end; 
		for i = 5, 8 do
			renderText(0.425, 0.62-((i-5)*0.05), 0.035, tostring(SoilExtension.grubbern[i+1]));
		end; 
	elseif self.windows.mittelPflug then
		renderOverlay(FarmingTablet.overlay.leer, 0.01, 0.01, 1, 1.5);
		renderOverlay(FarmingTablet.overlay.fenster_auswahl2, 0.01, 0.01, 1, 1.5);
		renderText(0.462, 0.23, 0.04, tostring("Abbrechen"));
		renderText(0.246, 0.675, 0.03, tostring("Was sollen Sie einpflügen?"));
		renderText(0.246, 0.675, 0.03, tostring("Was sollen Sie einpflügen?"));
		for i = 0, 4 do
			renderText(0.25, 0.62-(i*0.05), 0.035, tostring(SoilExtension.pflug[i+1]));
		end; 
		for i = 5, 8 do
			renderText(0.425, 0.62-((i-5)*0.05), 0.035, tostring(SoilExtension.pflug[i+1]));
		end; 
	elseif self.windows.mittelAusbringen then
		renderOverlay(FarmingTablet.overlay.leer, 0.01, 0.01, 1, 1.5);
		renderOverlay(FarmingTablet.overlay.fenster_auswahl2, 0.01, 0.01, 1, 1.5);
		renderText(0.462, 0.23, 0.04, tostring("Abbrechen"));
		renderText(0.246, 0.675, 0.03, tostring("Was wollen Sie ausbringen?"));
		renderText(0.246, 0.675, 0.03, tostring("Was wollen Sie ausbringen?"));
		for i = 0, 4 do
			renderText(0.25, 0.62-(i*0.05), 0.035, tostring(SoilExtension.ausbringen[i+1]));
		end; 
		for i = 5, 9 do
			renderText(0.425, 0.62-((i-5)*0.05), 0.035, tostring(SoilExtension.ausbringen[i+1]));
		end;
		for i = 10, 14 do
			renderText(0.6, 0.62-((i-10)*0.05), 0.035, tostring(SoilExtension.ausbringen[i+1]));
		end;
	end;
end;


function SoilExtension:delete() end;
 
 
 
 
 
 
 
 
 