diff data.lua @ 67:cd7e41015586

Separate Mill and Prospect, and load them only if needed
author contrebasse
date Sat, 14 May 2011 16:27:34 +0200
parents 2ca04183f5f9
children 42aac950bd67
line wrap: on
line diff
--- a/data.lua	Sat May 14 10:05:56 2011 +0200
+++ b/data.lua	Sat May 14 16:27:34 2011 +0200
@@ -1,265 +1,34 @@
 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,5,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: 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
+
+A.data = {}
+
 do
 	-- lua functions
 	local print = print
 	local ipairs = ipairs
 	local tinsert = tinsert
+	local select = select
 
 	-- Wow functions
 	local GetNumTradeSkills = GetNumTradeSkills
 	local GetTradeSkillInfo = GetTradeSkillInfo
 	local GetTradeSkillNumReagents = GetTradeSkillNumReagents
 	local GetTradeSkillItemLink = GetTradeSkillItemLink
+	local GetTradeSkillRecipeLink = GetTradeSkillRecipeLink
 	local GetTradeSkillReagentItemLink = GetTradeSkillReagentItemLink
 	local GetTradeSkillReagentInfo = GetTradeSkillReagentInfo
 	local GetTradeSkillNumMade = GetTradeSkillNumMade
+	local GetSpellInfo = GetSpellInfo
+
+	-- Wow objects
+	local GetTradeSkillLine = GetTradeSkillLine
 
 	-- the function who scans the tradeskill
 	function A:ScanSimpleRecipes()
@@ -270,6 +39,23 @@
 			return
 		end
 
+		-- Check if the pseudo tradeskills have to be added
+		if GetTradeSkillLine() == GetSpellInfo(25229) then -- Jewelcrafting
+			if not A.ProspectingDataLoaded then
+				for itemID,data in A.ProspectingData do
+					A.data[itemID] = data
+				end
+				A.ProspectingDataLoaded = true
+			end
+		elseif GetTradeSkillLine:GetText() == GetSpellInfo(45357) then -- Inscription
+			if not A.MillingDataLoaded then
+				for itemID,data in A.MillingData do
+					A.data[itemID] = data
+				end
+				A.MillingDataLoaded = true
+			end
+		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
@@ -277,11 +63,11 @@
 					-- item ID
 					local itemID = A.link2ID(GetTradeSkillItemLink(i))
 
-					-- reagent ID
+					-- reagent ID, valid only if there's only one reagent as we take only the first one
 					local reagentID = A.link2ID(GetTradeSkillReagentItemLink(i, 1))
 
 					-- reagent number needed
-					local reagentName, reagentTexture, reagentCount, playerReagentCount = GetTradeSkillReagentInfo(i, 1)
+					local _, _, reagentCount, _ = GetTradeSkillReagentInfo(i, 1)
 
 					-- number of reagent created by the recipe
 					local minMade, maxMade = GetTradeSkillNumMade(i)