<?xml version="1.0" encoding="utf-8"?>
<waypoints>
	<onLoad>
	local crafttable = {
	[15] = {name = "15", 					GUID = 551645, 	items = {[1] = {id = 209742,num = 1},[2] = {id = 209743,num = 1}}},
	[25] = {name = "25", 					GUID = 551646, 	items = {[1] = {id = 209742,num = 3},[2] = {id = 209744,num = 1},[3] = {id = 209743,num = 1}}},
	[35] = {name = "35", 					GUID = 551647, 	items = {[1] = {id = 209742,num = 2},[2] = {id = 209725,num = 1}}},
	[45] = {name = "45", 					GUID = 551648, 	items = {[1] = {id = 209744,num = 1},[2] = {id = 209745,num = 2},[3] = {id = 209743,num = 1}}},
	[55] = {name = "55", 					GUID = 551970,	items = {[1] = {id = 209744,num = 3},[2] = {id = 241588,num = 1},[3] = {id = 209743,num = 1}}},
	[65] = {name = "65", 					GUID = 551971,	items = {[1] = {id = 209744,num = 3},[2] = {id = 241589,num = 1},[3] = {id = 209743,num = 1}}},
	}
	while(true) do
		player:updateCasting()
		if not player.Casting then
			local craft = {}
			local lvl = player:getCraftLevel("alchemy")
			print("Current Level: "..lvl)
			if lvl%20 == 0 then
				print("raising max lvl")
				repeat
					yrest(500)
				until player:target_NPC(112944)
				yrest(1000)
				ChoiceOptionByName(getTEXT("SKILLCRAFT_SKILLPROVE"))
				yrest(1000)
				ChoiceOptionByName("Alchemy")
				yrest(1000)
			end
			if lvl >= 15 then craft = crafttable[15] end
			if lvl >= 25 then craft = crafttable[25] end
			if lvl >= 35 then craft = crafttable[35] end
			if lvl >= 45 then craft = crafttable[45] end
			if lvl >= 55 then craft = crafttable[55] end
			if lvl >= 65 then craft = crafttable[65] end

			local __,__,cancraft = RoMScript("GetCraftItemInfo("..craft.GUID..")")
			if cancraft == 0 then
				-- buy items
				player:openStore(112944,3)
				for k,v in pairs(craft.items) do
					store:buyItem(v.id, v.num*50)
				end
				RoMScript("CloseAllWindows()")
			end
			yrest(2000)
			local __,__,cancraft = RoMScript("GetCraftItemInfo("..craft.GUID..")")
			print("Starting to craft "..cancraft.." "..craft.name)
			RoMScript("CreateCraftItem("..craft.GUID..","..cancraft..",1)")
		end
		yrest(5000)
	end

	</onLoad>
</waypoints>
