Mercurial > wow > reagentmaker
view data.lua @ 86:d571fa85e1b5
Added tag v1.0beta4 for changeset 996aaa818d04
author | contrebasse |
---|---|
date | Sun, 15 May 2011 12:46:22 +0200 |
parents | 996aaa818d04 |
children | c369a2e16ab6 |
line wrap: on
line source
local addonName, A = ... -- @todo: enchants, elementals, prospecting -- @todo improve scanning 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() -- Do not scan while we modify the tradeskill display if A.blockScan then return end -- 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 tradeskillName = GetTradeSkillLine() -- Check if the pseudo tradeskills have to be added if tradeskillName == GetSpellInfo(25229) then -- Jewelcrafting if not A.ProspectingDataLoaded then for itemID,data in pairs(A.ProspectingData) do A.data[itemID] = data end A.ProspectingDataLoaded = true end elseif tradeskillName == GetSpellInfo(45357) then -- Inscription if not A.MillingDataLoaded then for itemID,data in pairs(A.MillingData) do A.data[itemID] = data end A.MillingDataLoaded = true end end local lastHeader for i = 1,NRecipes do -- skillName, skillType, numAvailable, isExpanded, serviceType, numSkillUps = GetTradeSkillInfo(index) -- serviceType is nil if the recipe creates an item local skillName, skillType, _, _, serviceType = GetTradeSkillInfo(i) if skillType and skillType == "header" then lastHeader = skillName elseif skillType and skillType ~= "header" and serviceType==nil then -- item ID local itemID = A.link2ID(GetTradeSkillItemLink(i)) -- 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 _, _, reagentCount, _ = 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 itemID and reagentID and reagentCount and minMade and maxMade and recipeLink then -- remove unneeded minMade/maxMade if maxMade==minMade then maxMade = nil if minMade==1 then minMade = nil end -- if end -- if -- As we scan multiple times, check if this recipe is already stored local addSpell = true if not A.data[itemID] then A.data[itemID] = {} else for _,v in ipairs(A.data[itemID]) do if v.spellLink==recipeLink then addSpell = nil break end -- if end -- for end -- if -- Cache the data if addSpell then local spell = {reagentID,reagentCount,minMade,maxMade} spell.spellName = tradeskillName spell.spellLink = recipeLink spell.header = lastHeader spell.manyReagents = GetTradeSkillNumReagents(i)>1 tinsert(A.data[itemID],spell) end --else -- Zap incomplete recipes, they will be scanned later --@debug@ --print("Erreur de scan :",itemID,reagentID,reagentCount,minMade,maxMade,recipeLink) --@end-debug@ end -- if end -- if end -- for zzz = A.data -- the scanning is complete return true end -- function end -- do