Mercurial > wow > reagentmaker
diff data.lua @ 70:32ec6417874a
Change the internal data format (not done yet for the external window)
author | contrebasse |
---|---|
date | Sat, 14 May 2011 20:19:22 +0200 |
parents | 0675410645de |
children | e837f5681fbb |
line wrap: on
line diff
--- a/data.lua Sat May 14 16:56:17 2011 +0200 +++ b/data.lua Sat May 14 20:19:22 2011 +0200 @@ -38,16 +38,18 @@ if NRecipes==0 or select(2,GetTradeSkillInfo(1))~="header" then return end + + tradeskillID = GetTradeSkillLine() -- Check if the pseudo tradeskills have to be added - if GetTradeSkillLine() == GetSpellInfo(25229) then -- Jewelcrafting + if tradeskillID == 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 GetTradeSkillLine() == GetSpellInfo(45357) then -- Inscription + elseif tradeskillID == GetSpellInfo(45357) then -- Inscription if not A.MillingDataLoaded then for itemID,data in pairs(A.MillingData) do A.data[itemID] = data @@ -57,61 +59,66 @@ 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)) + -- skillName, skillType, numAvailable, isExpanded, serviceType, numSkillUps = GetTradeSkillInfo(index) + -- serviceType is nil if the recipe creates an item + local _, skillType, _, _, serviceType = GetTradeSkillInfo(i) + if 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 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) + -- reagent number needed + local _, _, reagentCount, _ = GetTradeSkillReagentInfo(i, 1) - -- number of reagent created by the recipe - local minMade, maxMade = GetTradeSkillNumMade(i) + -- number of reagent created by the recipe + local minMade, maxMade = GetTradeSkillNumMade(i) - -- recipe link (for tooltips) - local recipeLink = GetTradeSkillRecipeLink(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 - --@debug@ - print("Erreur de scan :",itemID,skillName,reagentID,reagentCount,minMade,maxMade,recipeLink) - --@end-debug@ + -- 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 - 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 + -- 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.spellName==skillName then - newSpell = nil + if v.spellLink==recipeLink then + addSpell = 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 + + -- Cache the data + if addSpell then + local spell = {reagentID,reagentCount,minMade,maxMade} + spell.spellID = tradeskillID + spell.spellLink = recipeLink + 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