<?xml version="1.0" encoding="utf-8"?>
<waypoints>
	<onLoad>

	local crafttable = {
	[15] = {name = "Basic Wood Crafts Box", 	GUID = 551633, 	items = {[1] = {id = 209716,num = 1},[2] = {id = 209717,num = 1}}},
	[25] = {name = "Magic Wood Crafts Box", 	GUID = 551634, 	items = {[1] = {id = 209716,num = 3},[2] = {id = 209717,num = 1}}},
	[35] = {name = "Exquisite Sample Bow", 		GUID = 551635, 	items = {[1] = {id = 209718,num = 1},[2] = {id = 209717,num = 1}}},
	[45] = {name = "Powerful Epic Bow", 		GUID = 551636, 	items = {[1] = {id = 209718,num = 2},[2] = {id = 209719,num = 1},[3] = {id = 209717,num = 1}}},
	[55] = {name = "Special Ice Coal", 			GUID = 551964,	items = {[1] = {id = 209719,num = 2},[2] = {id = 241576,num = 1},[3] = {id = 209717,num = 1}}},
	[65] = {name = "Easy-to-Use Wand", 			GUID = 551965,	items = {[1] = {id = 209719,num = 3},[2] = {id = 241577,num = 1},[3] = {id = 209717,num = 1}}},
	}
	while(true) do
		player:updateCasting()
		if not player.Casting then
			local craft = {}
			local lvl = player:getCraftLevel("carpentry")
			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("Armorcrafting")
				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)
				yrest(1000)
				--inventory:useItem(209723)
				for k,v in pairs(craft.items) do
					store:buyItem(v.id, v.num*1000)
				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>
