view data.lua @ 47:08dfba564a6e v1.0beta1

Hide the tradeskill not found error
author contrebasse
date Sat, 30 Apr 2011 01:32:15 +0200
parents d74613eb5f72
children 4d0ec5b598d0
line wrap: on
line source
local addonName, A = ...

-- @todo: complete jewelcrafting items

local MillID = 51005
local macroMill = "/cast "..GetSpellInfo(MillID).."\n/use "
local MillLink = GetSpellLink(MillID)
MillID = nil
local ProspectID = 31252
local macroProspect = "/cast "..GetSpellInfo(ProspectID).."\n/use "
local ProspectLink = GetSpellLink(ProspectID)
ProspectID = nil
A.data = {
	-- Mill
	-- Normal pigments
	[39151] = { -- Alabaster Pigment
		spell = macroMill,
		spellLink = MillLink,
		{2447,5,2,3}, -- Peacebloom
		{ 765,5,2,3},  -- Silverleaf
		{2449,5,2,4}}, -- Earthroot
	[39334] = { -- Dusky Pigment
		spell = macroMill,
		spellLink = MillLink,
		{ 785,5,2,3}, -- Mageroyal
		{2450,5,2,3}, -- Briarthorn
		{2452,5,2,3}, -- Swiftthistle
		{2453,5,2,4}, -- Bruiseweed
		{3820,5,2,4}}, -- Stranglekelp
	[39338] = { -- Golden Pigment
		spell = macroMill,
		spellLink = MillLink,
		{3369,5,2,3}, -- Grave Moss
		{3355,5,2,3}, -- Wild Steelbloom
		{3356,5,2,4}, -- Kingsblood
		{3357,5,2,4}}, -- Liferoot
	[39339] = { -- Emerald Pigment
		spell = macroMill,
		spellLink = MillLink,
		{3818,5,2,3}, -- Fadeleaf
		{3821,5,2,3}, -- Goldthorn
		{3358,5,3,4}, -- Khadgar's Whisker
		{3819,5,3,4}}, -- Dragon's Teeth
	[39340] = { -- Violet Pigment
		spell = macroMill,
		spellLink = MillLink,
		{4625,5,2,3}, -- Firebloom
		{8831,5,2,3}, -- Purple Lotus
		{8836,5,2,3}, -- Arthas' Tears
		{8838,5,2,3}, -- Sungrass
		{8839,5,2,4}, -- Blindweed
		{8845,5,2,4}, -- Ghost Mushroom
		{8846,5,2,4}}, -- Gromsblood
	[39341] = { -- Silvery Pigment
		spell = macroMill,
		spellLink = MillLink,
		{13464,5,2,3}, -- Golden Sansam
		{13463,5,2,3}, -- Dreamfoil
		{13465,5,2,4}, -- Mountain Silversage
		{13466,5,2,4}, -- Sorrowmoss
		{13467,5,2,4}}, -- Icecap
	[39342] = { -- Nether Pigment
		spell = macroMill,
		spellLink = MillLink,
		{22786,5,2,3}, -- Dreaming Glory
		{22785,5,2,3}, -- Felweed
		{22789,5,2,3}, -- Terocone
		{22787,5,2,3}, -- Ragveil
		{22790,5,2,4}, -- Ancient Lichen
		{22793,5,2,4}, -- Mana Thistle
		{22791,5,2,4}, -- Netherbloom
		{22792,5,2,4}}, -- Nightmare Vine
	[39343] = { -- Azure Pigment
		spellLink = MillLink,
		spell = macroMill,
		{37921,5,2,3}, -- Deadnettle
		{36901,5,2,3}, -- Goldclover
		{36907,5,2,3}, -- Talandra's Rose
		{36904,5,2,3}, -- Tiger Lily
		{39970,5,2,3}, -- Fire Leaf
		{39969,5,2.3,3}, -- Fire Seed (2:33%/3:67%)
		{36903,5,2,4}, -- Adder's Tongue
		{36906,5,2,4}, -- Icethorn
		{36905,5,2,4}}, -- Lichbloom
	[61979] = { -- Ashen Pigment
		spell = macroMill,
		spellLink = MillLink,
		{52983,5,2,3}, -- Cinderbloom
		{52985,5,2,3}, -- Azshara's Veil
		{52984,5,2,3}, -- Stormvine
		{52986,5,2,3}, -- Heartblossom
		{52988,5,2,4}, -- Whiptail
		{52987,5,2,4}}, -- Twilight Jasmine
	-- Rare pigments
	[43103] = { -- Verdant Pigment
		spell = macroMill,
		spellLink = MillLink,
		{785,5,0.25},  -- Mageroyal
		{2450,5,0.25}, -- Briarthorn
		{2452,5,0.25}, -- Swiftthistle
		{2453,5,0.5}, -- Bruiseweed
		{3820,5,0.5}}, -- Stranglekelp
	[43104] = { -- Burnt Pigment
		spell = macroMill,
		spellLink = MillLink,
		{3369,5,0.25}, -- Grave Moss
		{3355,5,0.25}, -- Wild Steelbloom
		{3356,5,0.5}, -- Kingsblood
		{3357,5,0.5}}, -- Liferoot
	[43105] = { -- Indigo Pigment
		spell = macroMill,
		spellLink = MillLink,
		{3818,5,0.25}, -- Fadeleaf
		{3821,5,0.25}, -- Goldthorn
		{3358,5,0.5}, -- Khadgar's Whisker
		{3819,5,0.5}}, -- Dragon's Teeth
	[43106] = { -- Ruby Pigment
		spell = macroMill,
		spellLink = MillLink,
		{4625,5,0.25}, -- Firebloom
		{8831,5,0.25}, -- Purple Lotus
		{8836,5,0.25}, -- Arthas' Tears
		{8838,5,0.25}, -- Sungrass
		{8839,5,0.5}, -- Blindweed
		{8845,5,0.5}, -- Ghost Mushroom
		{8846,5,0.5}}, -- Gromsblood
	[43107] = { -- Sapphire Pigment
		spell = macroMill,
		spellLink = MillLink,
		{13464,5,0.25}, -- Golden Sansam
		{13463,5,0.25}, -- Dreamfoil
		{13465,5,0.5}, -- Mountain Silversage
		{13466,5,0.5}, -- Sorrowmoss
		{13467,5,0.5}}, -- Icecap
	[43108] = { -- Ebon Pigment
		spell = macroMill,
		spellLink = MillLink,
		{22786,5,0.25}, -- Dreaming Glory
		{22785,5,0.25}, -- Felweed
		{22789,5,0.25}, -- Terocone
		{22787,5,0.25}, -- Ragveil
		{22790,5,0.5}, -- Ancient Lichen
		{22793,5,0.5}, -- Mana Thistle
		{22791,5,0.5}, -- Netherbloom
		{22792,5,0.5}}, -- Nightmare Vine
	[43109] = { -- Icy Pigment
		spellLink = MillLink,
		spell = macroMill,
		{37921,5,0.25}, -- Deadnettle
		{36901,5,0.25}, -- Goldclover
		{36907,5,0.25}, -- Talandra's Rose
		{36904,5,0.25}, -- Tiger Lily
		{39970,5,0.25}, -- Fire Leaf
		{39969,5,0.25}, -- Fire Seed
		{36903,5,0.5}, -- Adder's Tongue
		{36906,5,0.5}, -- Icethorn
		{36905,5,0.5}}, -- Lichbloom
	[61980] = { -- Burning Embers
		spell = macroMill,
		spellLink = MillLink,
		{52983,5,0.25}, -- Cinderbloom
		{52985,5,0.25}, -- Azshara's Veil
		{52984,5,0.25}, -- Stormvine
		{52986,5,0.25}, -- Heartblossom
		{52988,5,0.5}, -- Whiptail
		{52987,5,0.5}}, -- Twilight Jasmine

	-- Prospect
	[774] = { -- Malachite
		spell = macroProspect,
		spellLink = ProspectLink,
		{2770,5,0.5}}, -- Copper Ore
	[818] = { -- Tigerseye
		spell = macroProspect,
		spellLink = ProspectLink,
		{2770,5,0.5}}, -- Copper Ore
	[1210] = { -- Shadowgem
		spell = macroProspect,
		spellLink = ProspectLink,
		{2771,50,0.38}, -- Tin Ore
		{2770,5,0.1}}, -- Copper Ore
	[1705] = { -- Lesser Moonstone
		spell = macroProspect,
		spellLink = ProspectLink,
		{2771,5,0.38}, -- Tin Ore
		{2772,5,0.35}}, -- Iron Ore
	[1206] = { -- Moss Agate
		spell = macroProspect,
		spellLink = ProspectLink,
		{2771,5,0.37}}, -- Tin Ore
	[1529] = { -- Jade
		spell = macroProspect,
		spellLink = ProspectLink,
		{2772,5,0.35}, -- Iron Ore
		{2771,5,0.03}}, -- Tin Ore
	[7909] = { -- Aquamarine
		spell = macroProspect,
		spellLink = ProspectLink,
		{3858,5,0.35}, -- Mithril Ore
		{2772,5,0.05}, -- Iron Ore
		{2771,5,0.03}}, -- Tin Ore
	[3864] = { -- Citrine
		spell = macroProspect,
		spellLink = ProspectLink,
		{2772,5,0.36}, -- Iron Ore
		{3858,5,0.35}, -- Mithril Ore
		{2771,5,0.03}}, -- Tin Ore
	[7910] = { -- Star Ruby
		spell = macroProspect,
		spellLink = ProspectLink,
		{3858,5,0.36}, -- Mithril Ore
		{10620,5,0.15}, -- Thorium Ore
		{2772,5,0.05}}, -- Iron Ore
	[12799] = { -- Large Opal
		spell = macroProspect,
		spellLink = ProspectLink,
		{10620,5,0.31}, -- Thorium Ore
		{3858,5,0.03}}, -- Mithril Ore
	[12361] = { -- Blue Sapphire
		spell = macroProspect,
		spellLink = ProspectLink,
		{10620,5,0.31}, -- Thorium Ore
		{3858,5,0.02}}, -- Mithril Ore
	[12800] = { -- Azerothian Diamond
		spell = macroProspect,
		spellLink = ProspectLink,
		{10620,5,0.31}, -- Thorium Ore
		{3858,5,0.02}}, -- Mithril Ore
	[12364] = { -- Huge Emerald
		spell = macroProspect,
		spellLink = ProspectLink,
		{10620,5,0.31}, -- Thorium Ore
		{3858,5,0.02}}, -- Mithril Ore
	[23112] = { -- Golden Draenite
		spell = macroProspect,
		spellLink = ProspectLink,
		{23424,5,0.19}, -- Fel Iron Ore
		{23425,5,0.18}}, -- Adamantite Ore
	-- To be continued...


	-- To add : enchants, elementals, prospecting
}

-- @todo improve scanning
-- @todo rescan when a new refipe appears (TRADESKILL_UPDATE ?)
-- @todo be sure that skillName is unique, or use something else
-- @todo add support for multi-reagents recipes
do
	-- lua functions
	local print = print
	local ipairs = ipairs
	local tinsert = tinsert

	-- Wow functions
	local GetNumTradeSkills = GetNumTradeSkills
	local GetTradeSkillInfo = GetTradeSkillInfo
	local GetTradeSkillNumReagents = GetTradeSkillNumReagents
	local GetTradeSkillItemLink = GetTradeSkillItemLink
	local GetTradeSkillReagentItemLink = GetTradeSkillReagentItemLink
	local GetTradeSkillReagentInfo = GetTradeSkillReagentInfo
	local GetTradeSkillNumMade = GetTradeSkillNumMade

	-- the function who scans the tradeskill
	function A:ScanSimpleRecipes()
		-- Check if the tradeskill is loaded
		-- Has to have recipes and begin with a header
		local NRecipes = GetNumTradeSkills()
		if NRecipes==0 or select(2,GetTradeSkillInfo(1))~="header" then
			return
		end
	
		for i = 2,NRecipes do -- The first one is a header
			local skillName, skillType, numAvailable, isExpanded, serviceType, numSkillUps = GetTradeSkillInfo(i)
			if skillType ~= "header" then
				--if GetTradeSkillNumReagents(i) == 1 then
					-- item ID
					local itemID = A.link2ID(GetTradeSkillItemLink(i))

					-- reagent ID
					local reagentID = A.link2ID(GetTradeSkillReagentItemLink(i, 1))

					-- reagent number needed
					local reagentName, reagentTexture, reagentCount, playerReagentCount = GetTradeSkillReagentInfo(i, 1)

					-- number of reagent created by the recipe
					local minMade, maxMade = GetTradeSkillNumMade(i)
					
					-- recipe link (for tooltips)
					local recipeLink = GetTradeSkillRecipeLink(i)

					-- error checking
					if not reagentID or not reagentCount or not skillName or not itemID or not minMade or not maxMade or not recipeLink then
						print("Erreur de scan :",itemID,skillName,reagentID,reagentCount,minMade,maxMade,recipeLink)
						
					else -- Zap incomplete recipes, they will be scanned later
						-- remove unneeded minMade/maxMade
						if maxMade==minMade then
							maxMade = nil
							if minMade==1 then
								minMade = nil
							end -- if
						end -- if

						-- skillName or...???
						-- There's still a problem when multiple recipes craft the same item
						if not A.data[itemID] then
							A.data[itemID] = {}
						end -- if
						local newSpell = true
						for _,v in ipairs(A.data[itemID]) do
							if v.spellName==skillName then
								newSpell = nil
								break
							end -- if
						end -- for
						if newSpell then
							A.data[itemID].spellLink = recipeLink
							A.data[itemID].manyReagents = A.data[itemID].manyReagents or GetTradeSkillNumReagents(i)>1
							tinsert(A.data[itemID],{reagentID,reagentCount,minMade,maxMade,spellName=skillName})
						end -- if
					end -- if
				--end -- if
			end -- if
		end -- for
		
		-- the scanning is complete
		return true
	end -- function
end -- do