------------------------------------------------
------------------------------------------------
----------- A Function Script File -------------
------------------------------------------------
------------------------------------------------

function Random(a, minimum, maximum)
	a = math.random(minimum, maximum)
	-- 248 and 259 for example
end

function DrawShadowString(Font, X, Y, Text, Color)
	screen:fontPrint(Font, X-1, Y-1, Text, Black)
	screen:fontPrint(Font, X, Y, Text, Color)
end

UserInfo = {

	Val = {
		Menu = 0,
		Create = 0,
		EditMenu = 0,
		Manager = 0,
		Editor = 0,
		Game = 0,
		Option = 0,
		
		Copy = "New"
	},
	
	AddVal = function(Cathegory, Value)
		if Cathegory == "Menu" then
			UserInfo.Val.Menu = UserInfo.Val.Menu + Value
		elseif Cathegory == "Create" then
			UserInfo.Val.Create = UserInfo.Val.Create + Value
		elseif Cathegory == "EditMenu" then
			UserInfo.Val.EditMenu = UserInfo.Val.EditMenu + Value
		elseif Cathegory == "Manager" then
			UserInfo.Val.Manager = UserInfo.Val.Manager + Value
		elseif Cathegory == "Editor" then
			UserInfo.Val.Editor = UserInfo.Val.Editor + Value
		elseif Cathegory == "Game" then
			UserInfo.Val.Game = UserInfo.Val.Game + Value
		elseif Cathegory == "Option" then
			UserInfo.Val.Option = UserInfo.Val.Option + Value
		end
		UserInfo.SaveInfo()
	end,
	
	ReadInfo = function()
		dofile("Configuration/Debug Info.cfg")
	end,
	
	SaveInfo = function()
		InfFi = io.open("Configuration/Debug Info.cfg", "w")
		InfFi:write("UserInfo.Val.Menu = "..UserInfo.Val.Menu.."\n")
		InfFi:write("UserInfo.Val.Create = "..UserInfo.Val.Create.."\n")
		InfFi:write("UserInfo.Val.EditMenu = "..UserInfo.Val.EditMenu.."\n")
		InfFi:write("UserInfo.Val.Manager = "..UserInfo.Val.Manager.."\n")
		InfFi:write("UserInfo.Val.Editor = "..UserInfo.Val.Editor.."\n")
		InfFi:write("UserInfo.Val.Game = "..UserInfo.Val.Game.."\n")
		InfFi:write("UserInfo.Val.Option = "..UserInfo.Val.Option.."")
		InfFi:close()
	end,
	
	CheckCopy = function()
		dofile("Game Resources/Copy.cfg")
		if UserInfo.Val.Copy == "New" then
			LogFile = io.open("Game Resources/Copy.cfg", "w")
			LogFile:write("Copy = "..string.format('%q',"Used"))
			LogFile:close()
			UserInfo.VarCopy = "Used"
		end
		
		if UserInfo.VarCopy == "Used" then
			UserInfo.ReadInfo()
		end
		
	end
}

UserInfo.CheckCopy()


-- Default Values
Max = {
	Unit = {
		Villager = 10,
		Militia = 10,
	},
	Building = {
		TownCenter = 8,
		House = 10,
	},
	Other = {
		Berry = 10,
		Tree = 24,
		Gold = 10,
		Stone = 10,
	},
}
dofile("Configuration/Limit.cfg")

-- Size Information
Info = {
	TC = {
		Width = 156,
		Height = 90,
	},
	House = {
		Width = 100,
		Height = 75,
	},
	
	Villager = {
		Width = 28,
		Height = 44,
		Male = {
			Width = nil,
			Height = nil,
		},
		Female = {
			Width = nil,
			Height = nil,
		},
	},
	Militia = {
		Width = 28,
		Height = 45,
	},
	
	
	
	Tree = {
		Width = 63,
		Height = 100,
		A = {
			Width = nil,
			Height = nil,
		},
		B = {
			Width = nil,
			Height = nil,
		},
		C = {
			Width = nil,
			Height = nil,
		},
	},
	Berry = {
		Width = 55,
		Height = 40,
		A = {
			Width = nil,
			Height = nil,
		},
		B = {
			Width = nil,
			Height = nil,
		},
		C = {
			Width = nil,
			Height = nil,
		},
	},
	Gold = {
		Width = 63,
		Height = 37,
	},
	Stone = {
		Width = 60,
		Height = 28,
		A = {
			Width = nil,
			Height = nil,
		},
		B = {
			Width = nil,
			Height = nil,
		},
	},
	
	
	
	Tile = {
		Width = 81,
		Height = 48,
	},
}

function ClearRAM(Param)
	if Param == "EditorMenu" then
		-- Well
	end
	if Param == "Editor" then
		Level = nil
		spr = nil
		EditorSpr = nil
		EditorSprInfo = nil
		Cursor = nil
		mState = nil
		Back = nil
		--MenPar  = nil


		MenParX = nil
		MenParY = nil
		PressedCircle = nil
	end
	
	if Param == "Game" then
		mState = nil
		ScreenCount = nil
		MapColor = nil
		MapChoise = nil
		LoadWorld = nil
		ResCheck = nil
		SaveIndex = nil
		Back = nil
		-- Sprites:
		spr = nil
		OptionsBG = nil
		PanelBG = nil
		ControlsPicture = nil
		GameMenu = nil
		EmptyButton = nil
		
		null = nil -- 
		
		CurButton = nil
		CurButton_old = nil
		ButtonColor = nil
		Cursor = nil
		
		UnSelectUnits = nil
		UnSelectBuildings = nil
		UnSelectResources = nil
		MapTypeBool = nil
		tick = nil
		lim = nil
		OpenMenu = nil
		WindTimer = nil
		
	end
	if Param == "Options" then
		VarPic = nil
		Select = nil
		CheckBox = nil
		
		SaveOptions = nil
	end
	if Param == "MainMenu" then
		BG = nil
		P1 = nil
		P2 = nil
		EB = nil
		
		About = nil
		Options = nil
		SinglePlayer = nil
		Editor = nil
		Training = nil
		
		CHAbout = nil
		CHOption = nil
		CHSinglePlayer = nil
		CHEditor = nil
		CHTraining = nil
		
		CreditPanel = nil
		Sign = nil
	end
end

function LoadMenuParts(Param)
	if Param == "MainMenu" then
		BG = Image.load("Game Resources/Backgrounds/Menu/MenuBG.png")--BackGround
		P1 = Image.load("Game Resources/Backgrounds/Menu/Panel1.png")--Panel1
		P2 = Image.load("Game Resources/Backgrounds/Menu/Panel2.png")--Panel2
		EB = Image.load("Game Resources/Buttons/Buttons/EmptyButton.png")--EmptyButton

		CHAbout = Image.load("Game Resources/Backgrounds/Menu/CHAbout.png")
		CHOptions = Image.load("Game Resources/Backgrounds/Menu/CHOption.png")
		CHSinglePlayer = Image.load("Game Resources/Backgrounds/Menu/CHSinglePlayer.png")
		CHEditor = Image.load("Game Resources/Backgrounds/Menu/CHEditor.png")
		CHTraining = Image.load("Game Resources/Backgrounds/Menu/CHTraining.png")
		
		About = Image.load("Game Resources/Backgrounds/Menu/About.png")
		Options = Image.load("Game Resources/Backgrounds/Menu/Option.png")
		SinglePlayer = Image.load("Game Resources/Backgrounds/Menu/SinglePlayer.png")
		Editor = Image.load("Game Resources/Backgrounds/Menu/Editor.png")
		Training = Image.load("Game Resources/Backgrounds/Menu/Training.png")

		CreditPanel = Image.load("Game Resources/Backgrounds/Menu/Credits.png")
		Sign1 = Image.load("Game Resources/Backgrounds/Menu/Signs1.png")
		Sign2 = Image.load("Game Resources/Backgrounds/Menu/Signs2.png")
	end
	-- More in 0.1 U4 (Already :D)
end

function PlayPathSound(Path)
	Mp3me.stop()
	Mp3me.load(Path)
	Mp3me.play()
end

function PlaySound(Sound)
	if Option.Sounds.Switch == true then
		
		
		
		if Option.Sounds.Buildings == true then
			if Sound == "TownCenter" then
				Mp3me.stop()
				Mp3me.load("Sounds/towncenter.mp3")
				Mp3me.play()
			elseif Sound == "House" then
				Mp3me.stop()
				Mp3me.load("Sounds/house.mp3")
				Mp3me.play()
			end
		end
		
		
		
		if Option.Sounds.Nature == true then
			if Sound == "Wind1" then
				Mp3me.stop()
				Mp3me.load("Sounds/Wind1.mp3")
				Mp3me.play()
			end
			if Sound == "Wind2" then
				Mp3me.stop()
				Mp3me.load("Sounds/Wind2.mp3")
				Mp3me.play()
			end
			if Sound == "Wind3" then
				Mp3me.stop()
				Mp3me.load("Sounds/Wind3.mp3")
				Mp3me.play()
			end
		end
		
		
		
		if Option.Sounds.Unit == true then
			if Sound == "VillageCreate" then
				Mp3me.stop()
				Mp3me.load("Sounds/villagercreation.mp3")
				Mp3me.play()
			end
			if Sound == "MilitaryCreate" then
				Mp3me.stop()
				Mp3me.load("Sounds/militarycreation.mp3")
				Mp3me.play()
			end
		end
		
		
		
		if Option.Sounds.Editor == true then
			
		end
	end
end

-- LoadCustomMap("CustomMap1", "scn2psp")
function LoadCustomMap(FileName, Format)
	if Format == "Default" or Format == "Def" then
		Format = "scn2psp"
	end
	dofile("Scenario/"..FileName.."."..Format)
end

function SavePath(Number)
	PathCFG = io.open("Configuration/MapChoise.cfg", "w")
	PathCFG:write('MapChoise = '..string.format('%q',Number))
	PathCFG:close()
end

function EditorParam(Number, Level)
	-- Edit Scenario
	if Number == 1 then
		PathCFG = io.open("Scenario/Selector.cfg", "w")
		PathCFG:write("Parameter = "..Number)
		PathCFG:write("\nLevel = "..Level)
		PathCFG:close()
	end
	-- Play Senario
	if Number == 2 then
		SavePath("E"..Level)
	end
	-- Delete Scenario Data
	if Number == 3 then
		--DeleteData("Scenario", Level)
		SaveGame("Scenario", "...", "", "", "Normal", "None", MV, Update, Pref, "Scenario Save", Level, true)
	  --SaveGame(Name, DT1, DT2, DT3, MapGenre, Diff, Version, Update, Pref, Place, Slot, Delete)
	end
end


-- LoadTextures()
function Textures(Param)

if Param == "Load" then
	spr = {
		uni = {
			VillagerMale = {
				Down = Image.load("Game Resources/Units/Villager/"..Global.Player.Color.."/Male/VMBAS_FN1.png"),
				Right = Image.load("Game Resources/Units/Villager/"..Global.Player.Color.."/Male/VMBAS_FN6.png"),
				Left = Image.load("Game Resources/Units/Villager/"..Global.Player.Color.."/Male/VMBAS_FN3.png"),
				Up = Image.load("Game Resources/Units/Villager/"..Global.Player.Color.."/Male/VMBAS_FN5.png"),
				UpLeft = Image.load("Game Resources/Units/Villager/"..Global.Player.Color.."/Male/VMBAS_FN4.png"),
				UpRight = Image.load("Game Resources/Units/Villager/"..Global.Player.Color.."/Male/VMBAS_FN6.png"),
				DownLeft = Image.load("Game Resources/Units/Villager/"..Global.Player.Color.."/Male/VMBAS_FN2.png"),
				DownRight = Image.load("Game Resources/Units/Villager/"..Global.Player.Color.."/Male/VMBAS_FN7.png"),
				Icon = Image.load("Game Resources/Icons/Units/"..Global.Player.Color.."/VillagerMaleIcon.jpg"),
			},
			VillagerFemale = {
				Down = Image.load("Game Resources/Units/Villager/"..Global.Player.Color.."/Female/VFBAS_FN1.png"),
				Right = Image.load("Game Resources/Units/Villager/"..Global.Player.Color.."/Female/VFBAS_FN6.png"),
				Left = Image.load("Game Resources/Units/Villager/"..Global.Player.Color.."/Female/VFBAS_FN3.png"),
				Up = Image.load("Game Resources/Units/Villager/"..Global.Player.Color.."/Female/VFBAS_FN5.png"),
				UpLeft = Image.load("Game Resources/Units/Villager/"..Global.Player.Color.."/Female/VFBAS_FN4.png"),
				UpRight = Image.load("Game Resources/Units/Villager/"..Global.Player.Color.."/Female/VFBAS_FN6.png"),
				DownLeft = Image.load("Game Resources/Units/Villager/"..Global.Player.Color.."/Female/VFBAS_FN2.png"),
				DownRight = Image.load("Game Resources/Units/Villager/"..Global.Player.Color.."/Female/VFBAS_FN7.png"),
				
				Icon = Image.load("Game Resources/Icons/Units/"..Global.Player.Color.."/VillagerFemaleIcon.jpg"),
			},
			Militia = {
				Down = Image.load("Game Resources/Units/Militia/"..Global.Player.Color.."/SPRMN_FN.png"),
				Right = Image.load("Game Resources/Units/Militia/"..Global.Player.Color.."/SPRMN_FN7.png"),
				Left = Image.load("Game Resources/Units/Militia/"..Global.Player.Color.."/SPRMN_FN2.png"),
				Up = Image.load("Game Resources/Units/Militia/"..Global.Player.Color.."/SPRMN_FN4.png"),
				UpLeft = Image.load("Game Resources/Units/Militia/"..Global.Player.Color.."/SPRMN_FN3.png"),
				UpRight = Image.load("Game Resources/Units/Militia/"..Global.Player.Color.."/SPRMN_FN6.png"),
				DownLeft = Image.load("Game Resources/Units/Militia/"..Global.Player.Color.."/SPRMN_FN1.png"),
				DownRight = Image.load("Game Resources/Units/Militia/"..Global.Player.Color.."/SPRMN_FN8.png"),
				
				Icon = Image.load("Game Resources/Icons/Units/"..Global.Player.Color.."/MilitiaIcon.jpg"),
			},
			Select = {
				Small = Image.load("Game Resources/Units/SelSmall.png"),
				Medium = nil,
			},
		},
		ico = {
			More = Image.load("Game Resources/Icons/Buildings/More.png"),
			Upgrades = {
				
			},
			Unit = {
				Production = Image.load("Game Resources/Icons/Buildings/Build1.png"),
				Army = Image.load("Game Resources/Icons/Buildings/Build2.png"),
				Repair = Image.load("Game Resources/Icons/Buildings/Repair.png"),
				Death = Image.load("Game Resources/Icons/Units/Other/DeathButton.png"),
			},
		},
		
		build = {
			TC = {
				Dark = Image.load("Game Resources/Buildings/Town Center/"..Global.Player.Color.."/TownCenter.png"),
				
				Icon = Image.load("Game Resources/Icons/Buildings/TownCenter.png"),
			},
			House = {
				DarkTy1 = Image.load("Game Resources/Buildings/House/"..Global.Player.Color.."/House1.png"),
				DarkTy2 = Image.load("Game Resources/Buildings/House/"..Global.Player.Color.."/House2.png"),
				DarkTy3 = Image.load("Game Resources/Buildings/House/"..Global.Player.Color.."/House3.png"),
				
				Icon = Image.load("Game Resources/Icons/Buildings/House.png"),
			},
			Select = {
				S3x3 = Image.load("Game Resources/Buildings/Sel3x3_2.png"),
				S2x2 = Image.load("Game Resources/Buildings/Sel2x2.png"),
				S1x1 = Image.load("Game Resources/Buildings/Sel1x1.png"),
			},
		},
		
		
		
		res = {
			Crystal = {
				Ty1 = Image.load("Game Resources/Resources/Minerals.png")
			},
			Food = {
				Ty1 = Image.load("Game Resources/Resources/Berry/FORAG_NN0.png"),
				Ty2 = Image.load("Game Resources/Resources/Berry/FORAG_NN1.png"),
				Ty3 = Image.load("Game Resources/Resources/Berry/FORAG_NN2.png"),
				Icon = Image.load("Game Resources/Icons/Resources/BerryIco.png"),
			},
			Tree = {
				Oak1 = Image.load("Game Resources/Resources/Tree/Oak/FOAK_NN0.png"),
				Oak2 = Image.load("Game Resources/Resources/Tree/Oak/FOAK_NN1.png"),
				Oak3 = Image.load("Game Resources/Resources/Tree/Oak/FOAK_NN2.png"),
				Oak4 = Image.load("Game Resources/Resources/Tree/Oak/FOAK_NN3.png"),
				Oak5 = Image.load("Game Resources/Resources/Tree/Oak/FOAK_NN4.png"),
				Icon = Image.load("Game Resources/Icons/Resources/TreeIco.png"),
			},
			Stone = { 
				Ty1 = Image.load("Game Resources/Resources/Stone/STONM_NN0.png"),
				Ty2 = Image.load("Game Resources/Resources/Stone/STONM_NN1.png"),
				Ty3 = Image.load("Game Resources/Resources/Stone/STONM_NN2.png"),
				Ty4 = Image.load("Game Resources/Resources/Stone/STONM_NN3.png"),
				Ty5 = Image.load("Game Resources/Resources/Stone/STONM_NN4.png"),
				Ty6 = Image.load("Game Resources/Resources/Stone/STONM_NN5.png"),
				Ty7 = Image.load("Game Resources/Resources/Stone/STONM_NN6.png"),
				Icon = Image.load("Game Resources/Icons/Resources/StoneIco.png"),
			},
			Gold = {
				Ty1 = Image.load("Game Resources/Resources/Gold/GOLDM_NN0.png"),
				Ty2 = Image.load("Game Resources/Resources/Gold/GOLDM_NN1.png"),
				Ty3 = Image.load("Game Resources/Resources/Gold/GOLDM_NN2.png"),
				Ty4 = Image.load("Game Resources/Resources/Gold/GOLDM_NN3.png"),
				Ty5 = Image.load("Game Resources/Resources/Gold/GOLDM_NN4.png"),
				Ty6 = Image.load("Game Resources/Resources/Gold/GOLDM_NN5.png"),
				Ty7 = Image.load("Game Resources/Resources/Gold/GOLDM_NN6.png"),
				Icon = Image.load("Game Resources/Icons/Resources/GoldIco.png"),
			},
			Artifact = {
				Ty1 = nil,
				Ty2 = nil,
			},
		},
		
		
		
		assets = {
			MiniMap = Image.load("Game Resources/Backgrounds/MiniMap/OldGrass_MiniMap.png"),
			Background = Image.load("Game Resources/Backgrounds/Ground/BGERROR.png"),
			GamePanel = Image.load("Game Resources/Panel/BritonsPanel.png"),
			ico = {
				Food = Image.load("Game Resources/Icons/Resources/Food.png"),
				Wood = Image.load("Game Resources/Icons/Resources/Wood.png"),
				Gold = Image.load("Game Resources/Icons/Resources/Gold.png"),
				Stone = Image.load("Game Resources/Icons/Resources/Stone.png"),
			},
			Tile = {
				Grass1 = Image.load("Game Resources/Backgrounds/Ground/GrassTile.png"),
			},
			Cursor = {
				Default = Image.load("Game Resources/Cursors/CursorDEF.png"),
				Resources = Image.load("Game Resources/Cursors/CursorRES.png"),
				Attack = Image.load("Game Resources/Cursors/CursorATT.png"),
			},
		},
	}
elseif Param == "Delete" then
	spr = nil
elseif Param == "ColorLoad" then
	spr.uni.VillagerMale = nil
	spr.uni.VillagerFemale = nil
	spr.uni.Militia = nil
	spr.build.TC = nil
	spr.build.House = nil
	
	
	spr.uni.VillagerMale.Down = Image.load("Game Resources/Units/Villager/"..Global.Player.Color.."/Male/VMBAS_FN1.png")
	spr.uni.VillagerMale.Right = Image.load("Game Resources/Units/Villager/"..Global.Player.Color.."/Male/VMBAS_FN6.png")
	spr.uni.VillagerMale.Left = Image.load("Game Resources/Units/Villager/"..Global.Player.Color.."/Male/VMBAS_FN3.png")
	spr.uni.VillagerMale.Up = Image.load("Game Resources/Units/Villager/"..Global.Player.Color.."/Male/VMBAS_FN5.png")
	spr.uni.VillagerMale.UpLeft = Image.load("Game Resources/Units/Villager/"..Global.Player.Color.."/Male/VMBAS_FN4.png")
	spr.uni.VillagerMale.UpRight = Image.load("Game Resources/Units/Villager/"..Global.Player.Color.."/Male/VMBAS_FN6.png")
	spr.uni.VillagerMale.DownLeft = Image.load("Game Resources/Units/Villager/"..Global.Player.Color.."/Male/VMBAS_FN2.png")
	spr.uni.VillagerMale.DownRight = Image.load("Game Resources/Units/Villager/"..Global.Player.Color.."/Male/VMBAS_FN7.png")
	
	spr.uni.VillagerMale.Icon = Image.load("Game Resources/Icons/Units/"..Global.Player.Color.."/VillagerMaleIcon.jpg")
	
	spr.uni.VillagerFemale.Down = Image.load("Game Resources/Units/Villager/"..Global.Player.Color.."/Female/VFBAS_FN1.png")
	spr.uni.VillagerFemale.Right = Image.load("Game Resources/Units/Villager/"..Global.Player.Color.."/Female/VFBAS_FN6.png")
	spr.uni.VillagerFemale.Left = Image.load("Game Resources/Units/Villager/"..Global.Player.Color.."/Female/VFBAS_FN3.png")
	spr.uni.VillagerFemale.Up = Image.load("Game Resources/Units/Villager/"..Global.Player.Color.."/Female/VFBAS_FN5.png")
	spr.uni.VillagerFemale.UpLeft = Image.load("Game Resources/Units/Villager/"..Global.Player.Color.."/Female/VFBAS_FN4.png")
	spr.uni.VillagerFemale.UpRight = Image.load("Game Resources/Units/Villager/"..Global.Player.Color.."/Female/VFBAS_FN6.png")
	spr.uni.VillagerFemale.DownLeft = Image.load("Game Resources/Units/Villager/"..Global.Player.Color.."/Female/VFBAS_FN2.png")
	spr.uni.VillagerFemale.DownRight = Image.load("Game Resources/Units/Villager/"..Global.Player.Color.."/Female/VFBAS_FN7.png")
	
	spr.uni.VillagerFemale.Icon = Image.load("Game Resources/Icons/Units/"..Global.Player.Color.."/VillagerMaleIcon.jpg")
	
	spr.uni.Militia.Down = Image.load("Game Resources/Units/Militia/"..Global.Player.Color.."/SPRMN_FN.png")
	spr.uni.Militia.Right = Image.load("Game Resources/Units/Militia/"..Global.Player.Color.."/SPRMN_FN7.png")
	spr.uni.Militia.Left = Image.load("Game Resources/Units/Militia/"..Global.Player.Color.."/SPRMN_FN2.png")
	spr.uni.Militia.Up = Image.load("Game Resources/Units/Militia/"..Global.Player.Color.."/SPRMN_FN4.png")
	spr.uni.Militia.UpLeft = Image.load("Game Resources/Units/Militia/"..Global.Player.Color.."/SPRMN_FN3.png")
	spr.uni.Militia.UpRight = Image.load("Game Resources/Units/Militia/"..Global.Player.Color.."/SPRMN_FN6.png")
	spr.uni.Militia.DownLeft = Image.load("Game Resources/Units/Militia/"..Global.Player.Color.."/SPRMN_FN1.png")
	spr.uni.Militia.DownRight = Image.load("Game Resources/Units/Militia/"..Global.Player.Color.."/SPRMN_FN8.png")
	
	spr.uni.Militia.Icon = Image.load("Game Resources/Icons/Units/"..Global.Player.Color.."/MilitiaIcon.jpg")
	
	spr.build.TC.Dark = Image.load("Game Resources/Buildings/Town Center/"..Global.Player.Color.."/TownCenter.png")
	spr.build.House.DarkTy1 = Image.load("Game Resources/Buildings/House/"..Global.Player.Color.."/House1.png")
	spr.build.House.DarkTy2 = Image.load("Game Resources/Buildings/House/"..Global.Player.Color.."/House2.png")
	spr.build.House.DarkTy3 = Image.load("Game Resources/Buildings/House/"..Global.Player.Color.."/House3.png")
	
end

end



function Fade(Speed)
	FadeBG = Image.createEmpty(480,272)
	Alpha = 0
	FadeColor = Color.new(0,0,0,Alpha)
	
	FadeBG:clear(FadeColor)
	while true do
		screen:blit(0,0,FadeBG)
		if Alpha < 255 then
			Alpha = Alpha + Speed
		else
			break
		end
		FadeColor = Color.new(0,0,0,Alpha)
		FadeBG:clear(FadeColor)
		
		screen.waitVblankStart()
		screen.flip()
	end
	screen.flip()
end

-- Endless Screenshot Save System
function Screenshot()
	
	ScreenCFG = io.open("Game Resources/ScreenCount.cfg", "r")
	ScreenCount = tonumber(ScreenCFG:read())
	ScreenCFG:close()
	
	--System.getDate()
	screen:save("Screenshots/screenshot"..ScreenCount..".png")
	ScreenCount = ScreenCount + 1
	
	ScreenCFG = io.open("Game Resources/ScreenCount.cfg", "w")
	ScreenCFG:write(ScreenCount)
	ScreenCFG:close()
	
end

--Draws a rectangle outline
function drawrect(x1,x2,y1,y2,COLOR)
	screen:drawLine(x1,y1,x2,y1,COLOR)
	screen:drawLine(x1,y1,x1,y2,COLOR)
	screen:drawLine(x1,y2,x2,y2,COLOR)
	screen:drawLine(x2,y1,x2,y2,COLOR)
end

--Short screen:fillRect()
function drawfilledRect(sx,sy,w,h,COLOR)
	screen:fillRect(sx,sy,w,h,COLOR)
end

function SaveGame(Name, DT1, DT2, DT3, MapGenre, Diff, Version, Update, Pref, Place, Slot, Delete)
	
	local what = ""
	
	if Place == "Saved Game Save" then
		if Slot == 1 then
			SavedGameCFG = io.open("Configuration/Map1.cfg", "w")
		elseif Slot == 2 then
			SavedGameCFG = io.open("Configuration/Map2.cfg", "w")
		elseif Slot == 3 then
			SavedGameCFG = io.open("Configuration/Map3.cfg", "w")
		end
		what = "Map"
	elseif Place == "Scenario Save" then
		if Slot == 1 then
			SavedGameCFG = io.open("Scenario/CustomMap1.scn2psp", "w")
		elseif Slot == 2 then
			SavedGameCFG = io.open("Scenario/CustomMap2.scn2psp", "w")
		elseif Slot == 3 then
			SavedGameCFG = io.open("Scenario/CustomMap3.scn2psp", "w")
		elseif Slot == 4 then
			SavedGameCFG = io.open("Scenario/CustomMap4.scn2psp", "w")
		elseif Slot == 5 then
			SavedGameCFG = io.open("Scenario/CustomMap5.scn2psp", "w")
		elseif Slot == 6 then
			SavedGameCFG = io.open("Scenario/CustomMap6.scn2psp", "w")
		end
		what = "SCN"
	end
	
	if Delete == true then
		
		TempGlobals()
		Global.Player.Color = "Blue"
		
		Textures("Delete")
		TempObjects(0)
		
		Global.World.Theme = "Grass"
		Global.Player.Civ = "Britons"
		
		for i = 1, Max.Unit.Villager do
			Villager[i].TarX = 0
			Villager[i].TarY = 0
			Villager[i].Exists = false
			Villager[i].X = 0
			Villager[i].Y = 0
			Villager[i].Type = 1
			Villager[i].IMG = spr.uni.VillagerMale.Down
		end
		for i = 1, Max.Unit.Militia do
			Militia[i].TarX = 0
			Militia[i].TarY = 0
			Militia[i].Exists = false
			Militia[i].X = 0
			Militia[i].Y = 0
		end
		for i = 1, Max.Building.TownCenter do
			TownCenter[i].Builded = false
			TownCenter[i].X = 0
			TownCenter[i].Y = 0
		end
		for i = 1, Max.Building.House do
			House[i].Builded = false
			House[i].X = 0
			House[i].Y = 0
		end
		for i = 1, Max.Other.Berry do
			Berry[i].Exists = false
			Berry[i].X = 0
			Berry[i].Y = 0
		end
		for i = 1, Max.Other.Tree do
			Tree[i].Exists = false
			Tree[i].IMG = spr.res.Tree.Oak1
			Tree[i].X = 0
			Tree[i].Y = 0
		end
		for i = 1, Max.Other.Gold do
			Gold[i].Exists = false
			Gold[i].X = 0
			Gold[i].Y = 0
		end
		for i = 1, Max.Other.Stone do
			Stone[i].Exists = false
			Stone[i].X = 0
			Stone[i].Y = 0
		end
	end
	
	
	SavedGameCFG:write("--[[\n")
	SavedGameCFG:write("*					AOE II by MasterMen in 2019\n")
	if what == "SCN" then
		SavedGameCFG:write("*			   an Age Of Empires 2 PSP Scenario file\n")
	elseif what == "Map" then
		SavedGameCFG:write("*			   an Age Of Empires 2 PSP Saved Map file\n")
	end
	SavedGameCFG:write("*				\n")
	SavedGameCFG:write("*						 Scenario\n")
	SavedGameCFG:write("*					  \n")
	SavedGameCFG:write("--]]\n\n")
	
	SavedGameCFG:write("Scenario = {\n")
	SavedGameCFG:write("	Name = "..string.format('%q',Name)..",\n")
	SavedGameCFG:write("	DT1 = "..string.format('%q',DT1)..",\n")
	SavedGameCFG:write("	DT2 = "..string.format('%q',DT2)..",\n")
	SavedGameCFG:write("	DT3 = "..string.format('%q',DT3)..",\n")
	SavedGameCFG:write("	MapGenre = "..string.format('%q',MapGenre)..",\n")
	SavedGameCFG:write("	Difficult = "..string.format('%q',Diff)..",\n")
	SavedGameCFG:write("	Version = "..Version..",\n")
	SavedGameCFG:write("	Update = "..Update..",\n")
	SavedGameCFG:write("	Prefix = "..string.format('%q',Prefix)..",\n")
	SavedGameCFG:write("}\n\n")
	
	SavedGameCFG:write("Global = {\n\n")
	SavedGameCFG:write("	World = {\n")
	SavedGameCFG:write("		Pop = 0,\n")
	SavedGameCFG:write("		Theme = "..string.format('%q',Global.World.Theme)..",\n")
	SavedGameCFG:write("	},\n\n")
	SavedGameCFG:write("	Player = {\n")
	SavedGameCFG:write("		Wood = "..Global.Player.Wood..",\n")
	SavedGameCFG:write("		Food = "..Global.Player.Food..",\n")
	SavedGameCFG:write("		Stone = "..Global.Player.Stone..",\n")
	SavedGameCFG:write("		Gold = "..Global.Player.Gold..",\n")
	SavedGameCFG:write("		Pop = "..Global.Player.Pop..",\n")
	SavedGameCFG:write("		MaxPop = "..Global.Player.MaxPop..",\n")
	SavedGameCFG:write("		Color = "..string.format('%q',Global.Player.Color)..",\n")
	SavedGameCFG:write("		NickCol = nil,\n")
	SavedGameCFG:write("		Nick = "..string.format('%q',Global.Player.Nick)..",\n")
	SavedGameCFG:write("		Civ = "..string.format('%q',Global.Player.Civ)..",\n")
	SavedGameCFG:write("		Age = "..string.format('%q',Global.Player.Age)..",\n")
	SavedGameCFG:write("		Score = "..Global.Player.Score..",\n")
	SavedGameCFG:write("		TeamScore = "..Global.Player.TeamScore..",\n\n")
	SavedGameCFG:write("		TC = {\n")
	SavedGameCFG:write("			Cost = {\n")
	SavedGameCFG:write("				Wood = "..Global.Player.TC.Cost.Wood..",\n")
	SavedGameCFG:write("				Food = "..Global.Player.TC.Cost.Food..",\n")
	SavedGameCFG:write("				Gold = "..Global.Player.TC.Cost.Gold..",\n")
	SavedGameCFG:write("				Stone = "..Global.Player.TC.Cost.Stone..",\n")
	SavedGameCFG:write("			},\n")
	SavedGameCFG:write("			MaxHP = "..Global.Player.TC.MaxHP..",\n")
	SavedGameCFG:write("			Att = "..Global.Player.TC.Att..",\n")
	SavedGameCFG:write("			Pop = "..Global.Player.TC.Pop..",\n")
	SavedGameCFG:write("		},\n")
	SavedGameCFG:write("		House = {\n")
	SavedGameCFG:write("			Cost = {\n")
	SavedGameCFG:write("				Wood = "..Global.Player.House.Cost.Wood..",\n")
	SavedGameCFG:write("				Food = "..Global.Player.House.Cost.Food..",\n")
	SavedGameCFG:write("				Gold = "..Global.Player.House.Cost.Gold..",\n")
	SavedGameCFG:write("				Stone = "..Global.Player.House.Cost.Stone..",\n")
	SavedGameCFG:write("			},\n")
	SavedGameCFG:write("			MaxHP = "..Global.Player.House.MaxHP..",\n")
	SavedGameCFG:write("			Pop = "..Global.Player.House.Pop..",\n")
	SavedGameCFG:write("		},\n")
	SavedGameCFG:write("		Villager = {\n")
	SavedGameCFG:write("			Cost = {\n")
	SavedGameCFG:write("				Wood = "..Global.Player.Villager.Cost.Wood..",\n")
	SavedGameCFG:write("				Food = "..Global.Player.Villager.Cost.Food..",\n")
	SavedGameCFG:write("				Gold = "..Global.Player.Villager.Cost.Gold..",\n")
	SavedGameCFG:write("				Stone = "..Global.Player.Villager.Cost.Stone..",\n")
	SavedGameCFG:write("			},\n")
	SavedGameCFG:write("			MaxHP = "..Global.Player.Villager.MaxHP..",\n")
	SavedGameCFG:write("			MaxInv = "..Global.Player.Villager.MaxInv..",\n")
	SavedGameCFG:write("			Att = "..Global.Player.Villager.Att..",\n")
	SavedGameCFG:write("			Speed = "..Global.Player.Villager.Speed..",\n")
	SavedGameCFG:write("		},\n")
	SavedGameCFG:write("		Militia = {\n")
	SavedGameCFG:write("			Cost = {\n")
	SavedGameCFG:write("				Wood = "..Global.Player.Militia.Cost.Wood..",\n")
	SavedGameCFG:write("				Food = "..Global.Player.Militia.Cost.Food..",\n")
	SavedGameCFG:write("				Gold = "..Global.Player.Militia.Cost.Gold..",\n")
	SavedGameCFG:write("				Stone = "..Global.Player.Militia.Cost.Stone..",\n")
	SavedGameCFG:write("			},\n")
	SavedGameCFG:write("			MaxHP = "..Global.Player.Militia.MaxHP..",\n")
	SavedGameCFG:write("			Att = "..Global.Player.Militia.Att..",\n")
	SavedGameCFG:write("			Speed = "..Global.Player.Militia.Speed..",\n")
	SavedGameCFG:write("		},\n")
	SavedGameCFG:write("	},\n")
	SavedGameCFG:write("}\n\n")
	
	SavedGameCFG:write("function LoadObj()\n")
	
	-- Villager
	SavedGameCFG:write("\nVillager = {}\n")
	for i = 1, Max.Unit.Villager do
		SavedGameCFG:write("Villager["..i.."] = {MaxHP = Global.Player.Villager.MaxHP, HP = "..Villager[i].HP..", Attack = Global.Player.Villager.Att, Speed = Global.Player.Villager.Speed, ")
		if Villager[i].Target ~= nil then
			SavedGameCFG:write("Target = "..Villager[i].Target..", ")
		else
			SavedGameCFG:write("Target = nil, ")
		end
		
		if Villager[i].LastTarget ~= nil then
			SavedGameCFG:write("LastTarget = "..Villager[i].LastTarget..", ")
		else
			SavedGameCFG:write("LastTarget = nil, ")
		end
		
		SavedGameCFG:write("TarX = "..Villager[i].TarX..", TarY = "..Villager[i].TarY..", ")
		if Villager[i].Follow == true then
			SavedGameCFG:write("Follow = true, ")
		elseif Villager[i].Follow == false then
			SavedGameCFG:write("Follow = false, ")
		end
		SavedGameCFG:write("Wood = "..Villager[i].Wood..", Gold = "..Villager[i].Gold..", Stone = "..Villager[i].Stone..", Food = "..Villager[i].Food..", ")
		if Villager[i].Exists == true then
			SavedGameCFG:write("Exists = true, ")
		elseif Villager[i].Exists == false then
			SavedGameCFG:write("Exists = false, ")
		end
		if Villager[i].Selected == true then
			SavedGameCFG:write("Selected = true, ")
		elseif Villager[i].Selected == false then
			SavedGameCFG:write("Selected = false, ")
		end
		SavedGameCFG:write("Type = "..Villager[i].Type..", ")
		if Villager[i].Type == 1 then
			SavedGameCFG:write("IMG = spr.uni.VillagerMale.Down")
		elseif Villager[i].Type == 2 then
			SavedGameCFG:write("IMG = spr.uni.VillagerFemale.Down")
		end
		SavedGameCFG:write(", X = "..Villager[i].X..", Y = "..Villager[i].Y.."}\n")
	end
	
	
	
	-- Militia
	SavedGameCFG:write("\nMilitia = {}\n")
	for i = 1, Max.Unit.Militia do
		SavedGameCFG:write("Militia["..i.."] = {MaxHP = Global.Player.Militia.MaxHP, HP = "..Militia[i].HP..", Attack = Global.Player.Militia.Att, Speed = Global.Player.Militia.Speed, ")
		if Militia[i].Target ~= nil then
		SavedGameCFG:write("Target = "..Militia[i].Target..", ")
		else
			SavedGameCFG:write("Target = nil, ")
		end
		
		if Militia[i].LastTarget ~= nil then
			SavedGameCFG:write("LastTarget = "..Militia[i].LastTarget..", ")
		else
			SavedGameCFG:write("LastTarget = nil, ")
		end
		SavedGameCFG:write("TarX = "..Militia[i].TarX..", ")
		SavedGameCFG:write("TarY = "..Militia[i].TarY..", ")
		if Militia[i].Follow == true then
			SavedGameCFG:write("Follow = true, ")
		elseif Militia[i].Follow == false then
			SavedGameCFG:write("Follow = false, ")
		end
		if Militia[i].Exists == true then
			SavedGameCFG:write("Exists = true, ")
		elseif Militia[i].Exists == false then
			SavedGameCFG:write("Exists = false, ")
		end
		if Militia[i].Selected == true then
			SavedGameCFG:write("Selected = true, ")
		elseif Militia[i].Selected == false then
			SavedGameCFG:write("Selected = false, ")
		end
		SavedGameCFG:write("IMG = spr.uni.Militia.Down, X = "..Militia[i].X..", Y = "..Militia[i].Y.."}\n")
	end
	
	
	-- Town Center
	SavedGameCFG:write("\nTownCenter = {}\n")
	for i = 1, Max.Building.TownCenter do
		SavedGameCFG:write("TownCenter["..i.."] = {MaxHP = "..Global.Player.TC.MaxHP..", HP = "..TownCenter[i].HP..", ")
		if TownCenter[i].Builded == true then
			SavedGameCFG:write("Builded = true, ")
		elseif TownCenter[i].Builded == false then
			SavedGameCFG:write("Builded = false, ")
		end
		if TownCenter[i].Selected == true then
			SavedGameCFG:write("Selected = true, ")
		elseif TownCenter[i].Selected == false then
			SavedGameCFG:write("Selected = false, ")
		end
		if Global.Player.Age == "Dark Age" then
			SavedGameCFG:write("IMG = spr.build.TC.Dark, ")
		end
		SavedGameCFG:write("X = "..TownCenter[i].X..", Y = "..TownCenter[i].Y.."}\n")
	end
	
	
	
	-- House
	SavedGameCFG:write("\nHouse = {}\n")
	for i = 1, Max.Building.House do
		SavedGameCFG:write("House["..i.."] = {MaxHP = Global.Player.House.MaxHP, HP = "..House[i].HP..", ")
		if House[i].Builded == true then
			SavedGameCFG:write("Builded = true, ")
		elseif House[i].Builded == false then
			SavedGameCFG:write("Builded = false, ")
		end
		if House[i].Selected == true then
			SavedGameCFG:write("Selected = true, ")
		elseif House[i].Selected == false then
			SavedGameCFG:write("Selected = false, ")
		end
		if House[i].IMG == spr.build.House.DarkTy1 then
			SavedGameCFG:write("IMG = spr.build.House.DarkTy1, ")
		elseif House[i].IMG == spr.build.House.DarkTy2 then
			SavedGameCFG:write("IMG = spr.build.House.DarkTy2, ")
		elseif House[i].IMG == spr.build.House.DarkTy3 then
			SavedGameCFG:write("IMG = spr.build.House.DarkTy3, ")
		end
		SavedGameCFG:write("X = "..House[i].X..", Y = "..House[i].Y.."}\n")
	end
	
	-- Mineral
	SavedGameCFG:write("\nMineral = {}\n")
	SavedGameCFG:write("Mineral[1] = {MaxGold = "..Mineral[1].MaxGold..", Gold = "..Mineral[1].Gold..", ")
	if Mineral[1].Exists == true then
		SavedGameCFG:write("Exists = true, ")
	elseif Mineral[1].Exists == false then
		SavedGameCFG:write("Exists = false, ")
	end
	if Mineral[1].Selected == true then
		SavedGameCFG:write("Selected = true, ")
	elseif Mineral[1].Selected == false then
		SavedGameCFG:write("Selected = false, ")
	end
	SavedGameCFG:write("IMG = spr.res.Crystal.Ty1, ")
	SavedGameCFG:write("X = "..Mineral[1].X..", Y = "..Mineral[1].Y.."}\n")
	
	-- Tree
	SavedGameCFG:write("\nTree = {}\n")
	for i = 1, Max.Other.Tree do
		SavedGameCFG:write("Tree["..i.."] = {MaxWood = "..Tree[i].MaxWood..", Wood = "..Tree[i].Wood..", ")
		if Tree[i].Exists == true then
			SavedGameCFG:write("Exists = true, ")
		elseif Tree[i].Exists == false then
			SavedGameCFG:write("Exists = false, ")
		end
		if Tree[i].Selected == true then
			SavedGameCFG:write("Selected = true, ")
		elseif Tree[i].Selected == false then
			SavedGameCFG:write("Selected = false, ")
		end
		if Tree[i].IMG == spr.res.Tree.Oak1 then
			SavedGameCFG:write("IMG = spr.res.Tree.Oak1, ")
		elseif Tree[i].IMG == spr.res.Tree.Oak2 then
			SavedGameCFG:write("IMG = spr.res.Tree.Oak2, ")
		elseif Tree[i].IMG == spr.res.Tree.Oak3 then
			SavedGameCFG:write("IMG = spr.res.Tree.Oak3, ")
		elseif Tree[i].IMG == spr.res.Tree.Oak4 then
			SavedGameCFG:write("IMG = spr.res.Tree.Oak4, ")
		elseif Tree[i].IMG == spr.res.Tree.Oak5 then
			SavedGameCFG:write("IMG = spr.res.Tree.Oak5, ")
		end
		SavedGameCFG:write("X = "..Tree[i].X..", Y = "..Tree[i].Y.."}\n")
	end
	
	
	
	-- Berry
	SavedGameCFG:write("\nBerry = {}\n")
	for i = 1, Max.Other.Berry do
		SavedGameCFG:write("Berry["..i.."] = {MaxFood = "..Berry[i].MaxFood..", Food = "..Berry[i].Food..", ")
		if Berry[i].Exists == true then
			SavedGameCFG:write("Exists = true, ")
		elseif Berry[i].Exists == false then
			SavedGameCFG:write("Exists = false, ")
		end
		if Berry[i].Selected == true then
			SavedGameCFG:write("Selected = true, ")
		elseif Berry[i].Selected == false then
			SavedGameCFG:write("Selected = false, ")
		end
		if Berry[i].IMG == spr.res.Food.Ty1 then
			SavedGameCFG:write("IMG = spr.res.Food.Ty1, ")
		elseif Berry[i].IMG == spr.res.Food.Ty2 then
			SavedGameCFG:write("IMG = spr.res.Food.Ty2, ")
		elseif Berry[i].IMG == spr.res.Food.Ty3 then
			SavedGameCFG:write("IMG = spr.res.Food.Ty3, ")
		end
		SavedGameCFG:write("X = "..Berry[i].X..", Y = "..Berry[i].Y.."}\n")
	end
	
	
	
	-- Gold
	SavedGameCFG:write("\nGold = {}\n")
	for i = 1, Max.Other.Gold do
		SavedGameCFG:write("Gold["..i.."] = {MaxGold = "..Gold[i].MaxGold..", Gold = "..Gold[i].Gold..", ")
		if Gold[i].Exists == true then
			SavedGameCFG:write("Exists = true, ")
		elseif Gold[i].Exists == false then
			SavedGameCFG:write("Exists = false, ")
		end
		if Gold[i].Selected == true then
			SavedGameCFG:write("Selected = true, ")
		elseif Gold[i].Selected == false then
			SavedGameCFG:write("Selected = false, ")
		end
		
		if Gold[i].IMG == spr.res.Gold.Ty1 then
			SavedGameCFG:write("IMG = spr.res.Gold.Ty1, ")
		elseif Gold[i].IMG == spr.res.Gold.Ty2	then
			SavedGameCFG:write("IMG = spr.res.Gold.Ty2, ")
		elseif Gold[i].IMG == spr.res.Gold.Ty3	then
			SavedGameCFG:write("IMG = spr.res.Gold.Ty3, ")
		elseif Gold[i].IMG == spr.res.Gold.Ty4	then
			SavedGameCFG:write("IMG = spr.res.Gold.Ty4, ")
		elseif Gold[i].IMG == spr.res.Gold.Ty5	then
			SavedGameCFG:write("IMG = spr.res.Gold.Ty5, ")
		elseif Gold[i].IMG == spr.res.Gold.Ty6	then
			SavedGameCFG:write("IMG = spr.res.Gold.Ty6, ")
		elseif Gold[i].IMG == spr.res.Gold.Ty7	then
			SavedGameCFG:write("IMG = spr.res.Gold.Ty7, ")
		end
		
		SavedGameCFG:write("X = "..Gold[i].X..", Y = "..Gold[i].Y.."}\n")
	end
	
	
	
	-- Stone
	SavedGameCFG:write("\nStone = {}\n")
	for i = 1, Max.Other.Stone do
		SavedGameCFG:write("Stone["..i.."] = {MaxStone = "..Stone[i].MaxStone..", Stone = "..Stone[i].Stone..", ")
		if Stone[i].Exists == true then
			SavedGameCFG:write("Exists = true, ")
		elseif Stone[i].Exists == false then
			SavedGameCFG:write("Exists = false, ")
		end
		if Stone[i].Selected == true then
			SavedGameCFG:write("Selected = true, ")
		elseif Stone[i].Selected == false then
			SavedGameCFG:write("Selected = false, ")
		end
		
		if Stone[i].IMG == spr.res.Stone.Ty1 then
			SavedGameCFG:write("IMG = spr.res.Stone.Ty1, ")
		elseif Stone[i].IMG == spr.res.Stone.Ty2 then
			SavedGameCFG:write("IMG = spr.res.Stone.Ty2, ")
		elseif Stone[i].IMG == spr.res.Stone.Ty3 then
			SavedGameCFG:write("IMG = spr.res.Stone.Ty3, ")
		elseif Stone[i].IMG == spr.res.Stone.Ty4 then
			SavedGameCFG:write("IMG = spr.res.Stone.Ty4, ")
		elseif Stone[i].IMG == spr.res.Stone.Ty5 then
			SavedGameCFG:write("IMG = spr.res.Stone.Ty5, ")
		elseif Stone[i].IMG == spr.res.Stone.Ty6 then
			SavedGameCFG:write("IMG = spr.res.Stone.Ty6, ")
		elseif Stone[i].IMG == spr.res.Stone.Ty7 then
			SavedGameCFG:write("IMG = spr.res.Stone.Ty7, ")
		end
		
		SavedGameCFG:write("X = "..Stone[i].X..", Y = "..Stone[i].Y.."}\n")
	end
	SavedGameCFG:write("\nend")
	SavedGameCFG:close()
end

function TempGlobals()
	Global = {
		
		World = {
			Pop = 0,
			Theme = "",
		},
		
		Player = {
			
			Wood = 0,
			Food = 0,
			Stone = 0,
			Gold = 0,
			Pop = 0,
			MaxPop = 20,
			Color = Color.new(0,0,0),
			Nick = "",
			Civ = "",
			Age = "Dark Age",
			-- Dark Age, Feudal Age, Castle Age, Imperial Age
			Score = 0,
			TeamScore = 0,
			
			TC = {
				Cost = {
					Food = 0,
					Wood = 0,
					Stone = 0,
					Gold = 0,
				},
				MaxHP = 2400,
				Att = 5,
				Pop = 1,
			},
			House = {
				Cost = {
					Food = 0,
					Wood = 0,
					Stone = 0,
					Gold = 0,
				},
				MaxHP = 500,
				Pop = 1,
			},
			Villager = {
				Cost = {
					Food = 0,
					Wood = 0,
					Stone = 0,
					Gold = 0,
				},
				MaxInv = 10,
				MaxHP = 50,
				Att = 3,
				Speed = 2,
			},
			Militia = {
				Cost = {
					Food = 0,
					Wood = 0,
					Stone = 0,
					Gold = 0,
				},
				MaxHP = 50,
				Att = 3,
				Speed = 3,
			},
		},
		
		
		
		
		Bot1 = {
			
		},
	}
end

function TempObjects(GenWorld)
	Textures("Load")
		
		Villager = {}
		for i = 1, Max.Unit.Villager do
			Villager[i] = {MaxHP = Global.Player.Villager.MaxHP, HP = 50, Attack = Global.Player.Villager.Att, Speed = Global.Player.Villager.Speed, Target = nil, LastTarget = nil, TarX = 0, TarY = 0,  Follow = false, Wood = 0, Gold = 0, Stone = 0, Food = 0, Exists = false, Selected = false, Type = 1, IMG = spr.uni.VillagerMale.Down, X = 0, Y = 0}
		end

		Militia = {}
		for i = 1, Max.Unit.Militia do
			Militia[i] = {MaxHP = Global.Player.Militia.MaxHP, HP = 50, Attack = Global.Player.Militia.Att, Speed = Global.Player.Militia.Speed, Target = nil, LastTarget = nil, TarX = 0, TarY = 0, Follow = false, Exists = false, Selected = false, IMG = spr.uni.Militia.Down, X = 0, Y = 0}
		end

		TownCenter = {}
		for i = 1, Max.Building.TownCenter do
			TownCenter[i] = {MaxHP = Global.Player.TC.MaxHP, HP = 2400, Builded = false, Selected = false, IMG = spr.build.TC.Dark, X = 0, Y = 0}
		end

		House = {}
		for i = 1, Max.Building.House do
			House[i] = {MaxHP = Global.Player.House.MaxHP, HP = 500, Builded = false, Selected = false, IMG = spr.build.House.DarkTy1, X = 0, Y = 0}
		end

		Mineral = {}
		Mineral[1] = {MaxGold = 1250, Gold = 1250, Exists = false, Selected = false, IMG = spr.res.Crystal.Ty1, X = 0, Y = 0}

		Tree = {}
		for i = 1, Max.Other.Tree do
			Tree[i] = {MaxWood = 450, Wood = 450, Exists = false, Selected = false, IMG = spr.res.Tree.Oak1, X = 0, Y = 0}
		end

		Berry = {}
		for i = 1, Max.Other.Berry do
			Berry[i] = {MaxFood = 450, Food = 450, Exists = false, Selected = false, IMG = spr.res.Food.Ty1, X = 0, Y = 0}
		end

		Gold = {}
		for i = 1, Max.Other.Gold do
			Gold[i] = {MaxGold = 500, Gold = 500, Exists = false, Selected = false, IMG = spr.res.Gold.Ty1, X = 0, Y = 0}
		end

		Stone = {}
		for i = 1, Max.Other.Stone do
			Stone[i] = {MaxStone = 500, Stone = 500, Exists = false, Selected = false, IMG = spr.res.Stone.Ty1, X = 0, Y = 0}
		end
	if GenWorld == 0 then
		
		-- Nothing
		
	elseif GenWorld == 1 then
	
	-- Map
	Villager[1] = {MaxHP = Global.Player.Villager.MaxHP, HP = 50, Attack = Global.Player.Villager.Att, Speed = Global.Player.Villager.Speed, Target = nil, LastTarget = nil, TarX = -48, TarY = 28, Follow = false, Wood = 0, Gold = 0, Stone = 0, Food = 0, Exists = true, Selected = false, Type = 2, IMG = spr.uni.VillagerFemale.Down, X = 67, Y = 129}
	Villager[2] = {MaxHP = Global.Player.Villager.MaxHP, HP = 50, Attack = Global.Player.Villager.Att, Speed = Global.Player.Villager.Speed, Target = nil, LastTarget = nil, TarX = 60, TarY = 112, Follow = false, Wood = 0, Gold = 0, Stone = 0, Food = 0, Exists = true, Selected = false, Type = 1, IMG = spr.uni.VillagerMale.Down, X = 175, Y = 213}
	Villager[3] = {MaxHP = Global.Player.Villager.MaxHP, HP = 50, Attack = Global.Player.Villager.Att, Speed = Global.Player.Villager.Speed, Target = nil, LastTarget = nil, TarX = 228, TarY = 64, Follow = false, Wood = 0, Gold = 0, Stone = 0, Food = 0, Exists = true, Selected = false, Type = 1, IMG = spr.uni.VillagerMale.Down, X = 343, Y = 165}
	
	TownCenter[1] = {MaxHP = 2400, HP = 2400, Builded = true, Selected = false, IMG = spr.build.TC.Dark, X = 142, Y = 51}
	
	Tree[1] = {MaxWood = 450, Wood = 450, Exists = true, Selected = false, IMG = spr.res.Tree.Oak1, X = -160, Y = 4}
	Tree[2] = {MaxWood = 450, Wood = 450, Exists = true, Selected = false, IMG = spr.res.Tree.Oak5, X = -36, Y = 186}
	Tree[3] = {MaxWood = 450, Wood = 450, Exists = true, Selected = false, IMG = spr.res.Tree.Oak1, X = 239, Y = 462}
	Tree[4] = {MaxWood = 450, Wood = 450, Exists = true, Selected = false, IMG = spr.res.Tree.Oak1, X = 533, Y = 320}
	Tree[5] = {MaxWood = 450, Wood = 450, Exists = true, Selected = false, IMG = spr.res.Tree.Oak1, X = 533, Y = -27}
	Tree[6] = {MaxWood = 450, Wood = 450, Exists = true, Selected = false, IMG = spr.res.Tree.Oak4, X = 233, Y = -219}
	Tree[7] = {MaxWood = 450, Wood = 450, Exists = true, Selected = false, IMG = spr.res.Tree.Oak2, X = 329, Y = -135}
	Tree[8] = {MaxWood = 450, Wood = 450, Exists = true, Selected = false, IMG = spr.res.Tree.Oak2, X = 653, Y = 8}
	Tree[9] = {MaxWood = 450, Wood = 450, Exists = true, Selected = false, IMG = spr.res.Tree.Oak2, X = 341, Y = 488}
	Tree[10] = {MaxWood = 450, Wood = 450, Exists = true, Selected = false, IMG = spr.res.Tree.Oak2, X = 185, Y = 512}
	Tree[11] = {MaxWood = 450, Wood = 450, Exists = true, Selected = false, IMG = spr.res.Tree.Oak2, X = -126, Y = 260}
	Tree[12] = {MaxWood = 450, Wood = 450, Exists = true, Selected = false, IMG = spr.res.Tree.Oak2, X = -354, Y = 32}
	Tree[13] = {MaxWood = 450, Wood = 450, Exists = true, Selected = false, IMG = spr.res.Tree.Oak5, X = -294, Y = 116}
	Tree[14] = {MaxWood = 450, Wood = 450, Exists = true, Selected = false, IMG = spr.res.Tree.Oak2, X = -198, Y = -279}
	Tree[15] = {MaxWood = 450, Wood = 450, Exists = true, Selected = false, IMG = spr.res.Tree.Oak2, X = 65, Y = -303}
	Tree[16] = {MaxWood = 450, Wood = 450, Exists = true, Selected = false, IMG = spr.res.Tree.Oak3, X = -30, Y = -327}
	Tree[17] = {MaxWood = 450, Wood = 450, Exists = true, Selected = false, IMG = spr.res.Tree.Oak3, X = -318, Y = -123}
	Tree[18] = {MaxWood = 450, Wood = 450, Exists = true, Selected = false, IMG = spr.res.Tree.Oak4, X = -246, Y = 20}
	Tree[19] = {MaxWood = 450, Wood = 450, Exists = true, Selected = false, IMG = spr.res.Tree.Oak3, X = -114, Y = 488}
	Tree[20] = {MaxWood = 450, Wood = 450, Exists = true, Selected = false, IMG = spr.res.Tree.Oak3, X = 449, Y = 536}
	Tree[21] = {MaxWood = 450, Wood = 450, Exists = true, Selected = false, IMG = spr.res.Tree.Oak3, X = 581, Y = 56}
	Tree[22] = {MaxWood = 450, Wood = 450, Exists = true, Selected = false, IMG = spr.res.Tree.Oak3, X = 461, Y = -123}
	Tree[23] = {MaxWood = 450, Wood = 450, Exists = true, Selected = false, IMG = spr.res.Tree.Oak5, X = 629, Y = 272}
	Tree[24] = {MaxWood = 450, Wood = 450, Exists = true, Selected = false, IMG = spr.res.Tree.Oak1, X = -138, Y = -327}
	
	Berry[1] = {MaxFood = 450, Food = 450, Exists = true, Selected = false, IMG = spr.res.Food.Ty1, X = 6, Y = 381}
	Berry[2] = {MaxFood = 450, Food = 450, Exists = true, Selected = false, IMG = spr.res.Food.Ty2, X = 48, Y = 400}
	Berry[3] = {MaxFood = 450, Food = 450, Exists = true, Selected = false, IMG = spr.res.Food.Ty3, X = -3, Y = 431}
	Berry[4] = {MaxFood = 450, Food = 450, Exists = true, Selected = false, IMG = spr.res.Food.Ty1, X = -24, Y = 398}
	Berry[5] = {MaxFood = 450, Food = 450, Exists = true, Selected = false, IMG = spr.res.Food.Ty1, X = -67, Y = -206}
	Berry[6] = {MaxFood = 450, Food = 450, Exists = true, Selected = false, IMG = spr.res.Food.Ty1, X = -28, Y = -185}
	Berry[7] = {MaxFood = 450, Food = 450, Exists = true, Selected = false, IMG = spr.res.Food.Ty1, X = -76, Y = -178}
	
	Gold[1] = {MaxGold = 500, Gold = 500, Exists = true, Selected = false, IMG = spr.res.Gold.Ty1, X = 425, Y = -315}
	Gold[2] = {MaxGold = 500, Gold = 500, Exists = true, Selected = false, IMG = spr.res.Gold.Ty1, X = 461, Y = -291}
	Gold[3] = {MaxGold = 500, Gold = 500, Exists = true, Selected = false, IMG = spr.res.Gold.Ty1, X = 413, Y = -279}
	Gold[4] = {MaxGold = 500, Gold = 500, Exists = true, Selected = false, IMG = spr.res.Gold.Ty1, X = 281, Y = 572}
	Gold[5] = {MaxGold = 500, Gold = 500, Exists = true, Selected = false, IMG = spr.res.Gold.Ty1, X = 269, Y = 608}
	Gold[6] = {MaxGold = 500, Gold = 500, Exists = true, Selected = false, IMG = spr.res.Gold.Ty1, X = 341, Y = 608}

	Stone[1] = {MaxStone = 500, Stone = 500, Exists = true, Selected = false, IMG = spr.res.Stone.Ty1, X = -294, Y = 272}
	Stone[2] = {MaxStone = 500, Stone = 500, Exists = true, Selected = false, IMG = spr.res.Stone.Ty2, X = -246, Y = 248}
	Stone[3] = {MaxStone = 500, Stone = 500, Exists = true, Selected = false, IMG = spr.res.Stone.Ty1, X = -318, Y = 224}
	Stone[4] = {MaxStone = 500, Stone = 500, Exists = true, Selected = false, IMG = spr.res.Stone.Ty1, X = -366, Y = 236}
	Stone[5] = {MaxStone = 500, Stone = 500, Exists = true, Selected = false, IMG = spr.res.Stone.Ty1, X = 629, Y = -63}
	Stone[6] = {MaxStone = 500, Stone = 500, Exists = true, Selected = false, IMG = spr.res.Stone.Ty1, X = 665, Y = -27}
	Stone[7] = {MaxStone = 500, Stone = 500, Exists = true, Selected = false, IMG = spr.res.Stone.Ty1, X = 857, Y = 128}
	Stone[8] = {MaxStone = 500, Stone = 500, Exists = true, Selected = false, IMG = spr.res.Stone.Ty1, X = 893, Y = 176}
	Stone[9] = {MaxStone = 500, Stone = 500, Exists = true, Selected = false, IMG = spr.res.Stone.Ty1, X = 821, Y = 164}
	
	elseif GenNumber == 2 then
	
	Villager[1] = {MaxHP = Global.Player.Villager.MaxHP, HP = 50, Attack = Global.Player.Villager.Att, Speed = Global.Player.Villager.Speed, Target = nil, LastTarget = nil, TarX = 24, TarY = 48, Follow = false, Wood = 0, Gold = 0, Stone = 0, Food = 0, Exists = true, Selected = false, Type = 1, IMG = spr.uni.VillagerMale.Down, X = 232, Y = 178}
	Villager[2] = {MaxHP = Global.Player.Villager.MaxHP, HP = 50, Attack = Global.Player.Villager.Att, Speed = Global.Player.Villager.Speed, Target = nil, LastTarget = nil, TarX = 24, TarY = 48, Follow = false, Wood = 0, Gold = 0, Stone = 0, Food = 0, Exists = true, Selected = false, Type = 2, IMG = spr.uni.VillagerFemale.Down, X = 364, Y = 112}
	Villager[3] = {MaxHP = Global.Player.Villager.MaxHP, HP = 50, Attack = Global.Player.Villager.Att, Speed = Global.Player.Villager.Speed, Target = nil, LastTarget = nil, TarX = 24, TarY = -48, Follow = false, Wood = 0, Gold = 0, Stone = 0, Food = 0, Exists = true, Selected = false, Type = 2, IMG = spr.uni.VillagerFemale.Down, X = 185, Y = 33}
	
	TownCenter[1] = {MaxHP = 2400, HP = 2400, Builded = true, Selected = false, IMG = spr.build.TC.Dark, X = 169, Y = 59}
	
	Tree[1] = {MaxWood = 450, Wood = 450, Exists = true, Selected = false, IMG = spr.res.Tree.Oak1, X = 535, Y = 185}
	Tree[2] = {MaxWood = 450, Wood = 450, Exists = true, Selected = false, IMG = spr.res.Tree.Oak1, X = 578, Y = 291}
	Tree[3] = {MaxWood = 450, Wood = 450, Exists = true, Selected = false, IMG = spr.res.Tree.Oak1, X = 330, Y = 475.6}
	Tree[4] = {MaxWood = 450, Wood = 450, Exists = true, Selected = false, IMG = spr.res.Tree.Oak1, X = 210, Y = 463.6}
	Tree[5] = {MaxWood = 450, Wood = 450, Exists = true, Selected = false, IMG = spr.res.Tree.Oak1, X = -173, Y = 655.6}
	Tree[6] = {MaxWood = 450, Wood = 450, Exists = true, Selected = false, IMG = spr.res.Tree.Oak1, X = -281, Y = 619.6}
	Tree[7] = {MaxWood = 450, Wood = 450, Exists = true, Selected = false, IMG = spr.res.Tree.Oak1, X = -425, Y = 43.6}
	Tree[8] = {MaxWood = 450, Wood = 450, Exists = true, Selected = false, IMG = spr.res.Tree.Oak1, X = -293, Y = -16.4}
	Tree[9] = {MaxWood = 450, Wood = 450, Exists = true, Selected = false, IMG = spr.res.Tree.Oak1, X = 30, Y = -280.4}
	Tree[10] = {MaxWood = 450, Wood = 450, Exists = true, Selected = false, IMG = spr.res.Tree.Oak1, X = 126, Y = -232.4}
	Tree[11] = {MaxWood = 450, Wood = 450, Exists = true, Selected = false, IMG = spr.res.Tree.Oak2, X = 42, Y = -196.4}
	Tree[12] = {MaxWood = 450, Wood = 450, Exists = true, Selected = false, IMG = spr.res.Tree.Oak2, X = -17, Y = -256.4}
	Tree[13] = {MaxWood = 450, Wood = 450, Exists = true, Selected = false, IMG = spr.res.Tree.Oak2, X = -341, Y = -16.4}
	Tree[14] = {MaxWood = 450, Wood = 450, Exists = true, Selected = false, IMG = spr.res.Tree.Oak2, X = 6, Y = 595}
	Tree[15] = {MaxWood = 450, Wood = 450, Exists = true, Selected = false, IMG = spr.res.Tree.Oak2, X = 498, Y = 379}
	Tree[16] = {MaxWood = 450, Wood = 450, Exists = true, Selected = false, IMG = spr.res.Tree.Oak3, X = 546, Y = 331}
	Tree[17] = {MaxWood = 450, Wood = 450, Exists = true, Selected = false, IMG = spr.res.Tree.Oak3, X = 102, Y = 523}
	Tree[18] = {MaxWood = 450, Wood = 450, Exists = true, Selected = false, IMG = spr.res.Tree.Oak3, X = -89, Y = 235}
	Tree[19] = {MaxWood = 450, Wood = 450, Exists = true, Selected = false, IMG = spr.res.Tree.Oak3, X = 426, Y = -208}
	Tree[20] = {MaxWood = 450, Wood = 450, Exists = true, Selected = false, IMG = spr.res.Tree.Oak4, X = 618, Y = -112}
	Tree[21] = {MaxWood = 450, Wood = 450, Exists = true, Selected = false, IMG = spr.res.Tree.Oak4, X = -425, Y = 331}
	Tree[22] = {MaxWood = 450, Wood = 450, Exists = true, Selected = false, IMG = spr.res.Tree.Oak4, X = -305, Y = -232}
	Tree[23] = {MaxWood = 450, Wood = 450, Exists = true, Selected = false, IMG = spr.res.Tree.Oak5, X = -185, Y = -280}
	Tree[24] = {MaxWood = 450, Wood = 450, Exists = true, Selected = false, IMG = spr.res.Tree.Oak5, X = 738, Y = -64}
	
	Berry[1] = {MaxFood = 450, Food = 450, Exists = true, Selected = false, IMG = spr.res.Food.Ty1, X = 348, Y = 305}
	Berry[2] = {MaxFood = 450, Food = 450, Exists = true, Selected = false, IMG = spr.res.Food.Ty2, X = 407, Y = 291}
	Berry[3] = {MaxFood = 450, Food = 450, Exists = true, Selected = false, IMG = spr.res.Food.Ty3, X = 384, Y = 333}
	Berry[4] = {MaxFood = 450, Food = 450, Exists = true, Selected = false, IMG = spr.res.Food.Ty2, X = 311, Y = 279}
	Berry[5] = {MaxFood = 450, Food = 450, Exists = true, Selected = false, IMG = spr.res.Food.Ty2, X = 313, Y = 325}
	Berry[6] = {MaxFood = 450, Food = 450, Exists = true, Selected = false, IMG = spr.res.Food.Ty1, X = 369, Y = 269}
	
	Gold[1] = {MaxGold = 500, Gold = 500, Exists = true, Selected = false, IMG = spr.res.Gold.Ty3, X = 312, Y = -301}
	Gold[2] = {MaxGold = 500, Gold = 500, Exists = true, Selected = false, IMG = spr.res.Gold.Ty4, X = 245, Y = -330}
	Gold[3] = {MaxGold = 500, Gold = 500, Exists = true, Selected = false, IMG = spr.res.Gold.Ty5, X = 245, Y = -286}
	
	Stone[1] = {MaxStone = 500, Stone = 500, Exists = true, Selected = false, IMG = spr.res.Stone.Ty1, X = 131, Y = 745}
	Stone[2] = {MaxStone = 500, Stone = 500, Exists = true, Selected = false, IMG = spr.res.Stone.Ty2, X = 193, Y = 735}
	Stone[3] = {MaxStone = 500, Stone = 500, Exists = true, Selected = false, IMG = spr.res.Stone.Ty2, X = 162, Y = 790}
	Stone[4] = {MaxStone = 500, Stone = 500, Exists = true, Selected = false, IMG = spr.res.Stone.Ty3, X = 91, Y = 776}
	Stone[5] = {MaxStone = 500, Stone = 500, Exists = true, Selected = false, IMG = spr.res.Stone.Ty6, X = 122, Y = 824}
	Stone[6] = {MaxStone = 500, Stone = 500, Exists = true, Selected = false, IMG = spr.res.Stone.Ty6, X = -489, Y = -111}
	Stone[7] = {MaxStone = 500, Stone = 500, Exists = true, Selected = false, IMG = spr.res.Stone.Ty7, X = -489, Y = -63}
	Stone[8] = {MaxStone = 500, Stone = 500, Exists = true, Selected = false, IMG = spr.res.Stone.Ty5, X = -564, Y = -95}
	Stone[9] = {MaxStone = 500, Stone = 500, Exists = true, Selected = false, IMG = spr.res.Stone.Ty3, X = -561, Y = -53}
	Stone[10] = {MaxStone = 500, Stone = 500, Exists = true, Selected = false, IMG = spr.res.Stone.Ty3, X = 700, Y = -274}
	Stone[11] = {MaxStone = 500, Stone = 500, Exists = true, Selected = false, IMG = spr.res.Stone.Ty1, X = 724, Y = -226}
	Stone[12] = {MaxStone = 500, Stone = 500, Exists = true, Selected = false, IMG = spr.res.Stone.Ty1, X = 784, Y = -274}
	Stone[13] = {MaxStone = 500, Stone = 500, Exists = true, Selected = false, IMG = spr.res.Stone.Ty2, X = 796, Y = -238}
	
	elseif GenNumber == 3 then
	
	Villager[1] = {MaxHP = Global.Player.Villager.MaxHP, HP = 50, Attack = Global.Player.Villager.Att, Speed = Global.Player.Villager.Speed, Target = nil, LastTarget = nil, TarX = -24, TarY = 24, Follow = false, Wood = 0, Gold = 0, Stone = 0, Food = 0, Exists = true, Selected = false, Type = 1, IMG = spr.uni.VillagerMale.Down, X = 83.35, Y = 138.85}
	Villager[2] = {MaxHP = Global.Player.Villager.MaxHP, HP = 50, Attack = Global.Player.Villager.Att, Speed = Global.Player.Villager.Speed, Target = nil, LastTarget = nil, TarX = -24, TarY = -12, Follow = false, Wood = 0, Gold = 0, Stone = 0, Food = 0, Exists = true, Selected = false, Type = 1, IMG = spr.uni.VillagerMale.Down, X = 295.85, Y = 30.25}
	Villager[3] = {MaxHP = Global.Player.Villager.MaxHP, HP = 50, Attack = Global.Player.Villager.Att, Speed = Global.Player.Villager.Speed, Target = nil, LastTarget = nil, TarX = -24, TarY = -12, Follow = false, Wood = 0, Gold = 0, Stone = 0, Food = 0, Exists = true, Selected = false, Type = 2, IMG = spr.uni.VillagerFemale.Down, X = 295.85, Y = 167.05}
	
	TownCenter[1] = {MaxHP = 2400, HP = 2400, Builded = true, Selected = false, IMG = spr.build.TC.Dark, X = 137.4, Y = 66.7}
	
	Tree[1] = {MaxWood = 450, Wood = 450, Exists = true, Selected = false, IMG = spr.res.Tree.Oak1, X = 127.35, Y = -91.25}
	Tree[2] = {MaxWood = 450, Wood = 450, Exists = true, Selected = false, IMG = spr.res.Tree.Oak1, X = 57.349999999999, Y = -145.15}
	Tree[3] = {MaxWood = 450, Wood = 450, Exists = true, Selected = false, IMG = spr.res.Tree.Oak1, X = -194.65, Y = -61.15}
	Tree[4] = {MaxWood = 450, Wood = 450, Exists = true, Selected = false, IMG = spr.res.Tree.Oak1, X = -230.65, Y = 10.85}
	Tree[5] = {MaxWood = 450, Wood = 450, Exists = true, Selected = false, IMG = spr.res.Tree.Oak1, X = -86.650000000001, Y = 406.85}
	Tree[6] = {MaxWood = 450, Wood = 450, Exists = true, Selected = false, IMG = spr.res.Tree.Oak1, X = -38.650000000001, Y = 478.85}
	Tree[7] = {MaxWood = 450, Wood = 450, Exists = true, Selected = false, IMG = spr.res.Tree.Oak1, X = 429.35, Y = 334.85}
	Tree[8] = {MaxWood = 450, Wood = 450, Exists = true, Selected = false, IMG = spr.res.Tree.Oak1, X = 561.35, Y = 238.85}
	Tree[9] = {MaxWood = 450, Wood = 450, Exists = true, Selected = false, IMG = spr.res.Tree.Oak1, X = 657.35, Y = -169.15}
	Tree[10] = {MaxWood = 450, Wood = 450, Exists = true, Selected = false, IMG = spr.res.Tree.Oak2, X = 201.35, Y = -181.15}
	Tree[11] = {MaxWood = 450, Wood = 450, Exists = true, Selected = false, IMG = spr.res.Tree.Oak2, X = -2.6500000000007, Y = -97.15}
	Tree[12] = {MaxWood = 450, Wood = 450, Exists = true, Selected = false, IMG = spr.res.Tree.Oak2, X = -194.65, Y = 94.85}
	Tree[13] = {MaxWood = 450, Wood = 450, Exists = true, Selected = false, IMG = spr.res.Tree.Oak2, X = -302.65, Y = 358.85}
	Tree[14] = {MaxWood = 450, Wood = 450, Exists = true, Selected = false, IMG = spr.res.Tree.Oak2, X = 215.75, Y = 658.85}
	Tree[15] = {MaxWood = 450, Wood = 450, Exists = true, Selected = false, IMG = spr.res.Tree.Oak2, X = 455.75, Y = 478.85}
	Tree[16] = {MaxWood = 450, Wood = 450, Exists = true, Selected = false, IMG = spr.res.Tree.Oak2, X = 635.75, Y = 346.85}
	Tree[17] = {MaxWood = 450, Wood = 450, Exists = true, Selected = false, IMG = spr.res.Tree.Oak2, X = 659.75, Y = -37.15}
	Tree[18] = {MaxWood = 450, Wood = 450, Exists = true, Selected = false, IMG = spr.res.Tree.Oak3, X = 359.75, Y = -349.15}
	Tree[19] = {MaxWood = 450, Wood = 450, Exists = true, Selected = false, IMG = spr.res.Tree.Oak3, X = 503.75, Y = -157.15}
	Tree[20] = {MaxWood = 450, Wood = 450, Exists = true, Selected = false, IMG = spr.res.Tree.Oak3, X = 491.75, Y = 238.85}
	Tree[21] = {MaxWood = 450, Wood = 450, Exists = true, Selected = false, IMG = spr.res.Tree.Oak3, X = 143.75, Y = 526.85}
	Tree[22] = {MaxWood = 450, Wood = 450, Exists = true, Selected = false, IMG = spr.res.Tree.Oak4, X = -132.25, Y = 262.85}
	Tree[23] = {MaxWood = 450, Wood = 450, Exists = true, Selected = false, IMG = spr.res.Tree.Oak4, X = 407.75, Y = -205.15}
	Tree[24] = {MaxWood = 450, Wood = 450, Exists = true, Selected = false, IMG = spr.res.Tree.Oak5, X = 707.75, Y = 58.85}
	
	Gold[1] = {MaxGold = 500, Gold = 500, Exists = true, Selected = false, IMG = spr.res.Gold.Ty1, X = 719.75, Y = 226.85}
	Gold[2] = {MaxGold = 500, Gold = 500, Exists = true, Selected = false, IMG = spr.res.Gold.Ty2, X = 743.75, Y = 262.85}
	Gold[3] = {MaxGold = 500, Gold = 500, Exists = true, Selected = false, IMG = spr.res.Gold.Ty2, X = 683.75, Y = 250.85}
	Gold[4] = {MaxGold = 500, Gold = 500, Exists = true, Selected = false, IMG = spr.res.Gold.Ty2, X = 323.75, Y = 598.85}
	Gold[5] = {MaxGold = 500, Gold = 500, Exists = true, Selected = false, IMG = spr.res.Gold.Ty3, X = 287.75, Y = 622.85}
	Gold[6] = {MaxGold = 500, Gold = 500, Exists = true, Selected = false, IMG = spr.res.Gold.Ty4, X = 359.75, Y = 646.85}
	
	Stone[1] = {MaxStone = 500, Stone = 500, Exists = true, Selected = false, IMG = spr.res.Stone.Ty2, X = -348.25, Y = -121.15}
	Stone[2] = {MaxStone = 500, Stone = 500, Exists = true, Selected = false, IMG = spr.res.Stone.Ty3, X = -420.25, Y = -97.15}
	Stone[3] = {MaxStone = 500, Stone = 500, Exists = true, Selected = false, IMG = spr.res.Stone.Ty4, X = -360.25, Y = -73.15}
	
	end
	
end


