<?xml version="1.0" encoding="utf-8"?>
<waypoints>
	<onLoad>
	local crafttable = {
	[15] = {name = "Iron Doll", 					GUID = 551637, 	items = {[1] = {id = 209724,num = 1},[2] = {id = 209725,num = 1}}},
	[25] = {name = "Delicate White Iron Kettle", 	GUID = 551638, 	items = {[1] = {id = 209724,num = 3},[2] = {id = 209725,num = 1}}},
	[35] = {name = "Unknown Iron Rune Disc", 		GUID = 551639, 	items = {[1] = {id = 209726,num = 2},[2] = {id = 209725,num = 1}}},
	[45] = {name = "Powerful Epic Swrod", 			GUID = 551640, 	items = {[1] = {id = 209726,num = 2},[2] = {id = 209727,num = 1},[3] = {id = 209725,num = 1}}},
	[55] = {name = "Thermos Bottle", 				GUID = 551966,	items = {[1] = {id = 209727,num = 2},[2] = {id = 241580,num = 1},[3] = {id = 209725,num = 1}}},
	[65] = {name = "Spice Couldron", 				GUID = 551967,	items = {[1] = {id = 209727,num = 2},[2] = {id = 241581,num = 1},[3] = {id = 209725,num = 1}}},
	}
	while(true) do
		player:updateCasting()
		if not player.Casting then
			local craft = {}
			local lvl = player:getCraftLevel("blacksmithing")
			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("Blacksmith")
				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>
