<?xml version="1.0" encoding="utf-8"?>
<waypoints>
	<onLoad>
	local crafttable = {
	[15] = {name = "15", 	GUID = 551641, 	items = {[1] = {id = 209734,num = 2},[2] = {id = 209735,num = 1}}},
	[25] = {name = "25", 	GUID = 551642, 	items = {[1] = {id = 209734,num = 3},[2] = {id = 209735,num = 1}}},
	[35] = {name = "35", 	GUID = 551643, 	items = {[1] = {id = 209734,num = 3},[2] = {id = 209736,num = 1},[3] = {id = 209735,num = 1}}},
	[45] = {name = "45", 	GUID = 551644, 	items = {[1] = {id = 209734,num = 4},[2] = {id = 209736,num = 1},[2] = {id = 209737,num = 1},[3] = {id = 209735,num = 1}}},
	[55] = {name = "55", 	GUID = 551968,	items = {[1] = {id = 209734,num = 5},[2] = {id = 241584,num = 1},[3] = {id = 209735,num = 1}}},
	[65] = {name = "65", 	GUID = 551969,	items = {[1] = {id = 209734,num = 5},[2] = {id = 241585,num = 1},[3] = {id = 209735,num = 1}}},
	}
	while(true) do
		player:updateCasting()
		if not player.Casting then
			local craft = {}
			local lvl = player:getCraftLevel("Tailoring")
			print("Current Level: "..lvl)
			if lvl%20 == 0 then
				print("raising max lvl")
				repeat
					yrest(500)
				until player:target_NPC(112945)
				yrest(1000)
				ChoiceOptionByName(getTEXT("SKILLCRAFT_SKILLPROVE"))
				yrest(1000)
				ChoiceOptionByName("Tailoring")
				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(112945,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>
