Mercurial > wow > reagentmaker
diff data.lua @ 117:e6bb47c6d8d6
Hopefuly fixed ticket #1
author | contrebasse |
---|---|
date | Sun, 19 Jun 2011 13:04:37 +0200 |
parents | d60d6b4cab0c |
children | c32d6bf6cfc1 |
line wrap: on
line diff
--- a/data.lua Wed Jun 15 01:14:00 2011 +0200 +++ b/data.lua Sun Jun 19 13:04:37 2011 +0200 @@ -1,8 +1,5 @@ local addonName, A = ... --- @todo: enchants, elementals, prospecting --- @todo improve scanning - A.data = A.CommonData do @@ -32,7 +29,6 @@ -- 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() @@ -60,43 +56,65 @@ end local lastHeader + local isScanCorrect = true 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 not skillName then return end + + -- Save the name of the header if skillType and skillType == "header" then lastHeader = skillName + -- Analyse recipe elseif skillType and skillType ~= "header" and serviceType==nil then + local isRecipeCorrect = true + -- item ID local itemID = A.link2ID(GetTradeSkillItemLink(i)) + if not itemID then isRecipeCorrect = false; end local numReagents = GetTradeSkillNumReagents(i) + if not numReagents then isRecipeCorrect = false; end + local reagentID, reagentCount if numReagents==1 then -- reagent ID reagentID = A.link2ID(GetTradeSkillReagentItemLink(i, 1)) + if not reagentID then isRecipeCorrect = false; end -- reagent number needed reagentCount = select(3,GetTradeSkillReagentInfo(i, 1)) + if not reagentCount then isRecipeCorrect = false; end else - -- no reagentID + -- no reagentID (is already nil) + --reagentID = nil -- contains data for the whole reagents reagentCount = {} for j = 1,numReagents do - tinsert(reagentCount,{A.link2ID(GetTradeSkillReagentItemLink(i, j)), select(3,GetTradeSkillReagentInfo(i, j))}) + local id = A.link2ID(GetTradeSkillReagentItemLink(i, j)) + local num = select(3,GetTradeSkillReagentInfo(i, j)) + if not id or not num then isRecipeCorrect = false; break; end + tinsert(reagentCount,{id, num}) end end -- number of reagent created by the recipe local minMade, maxMade = GetTradeSkillNumMade(i) + if not minMade or not maxMade then isRecipeCorrect = false; end -- recipe link (for tooltips) local recipeLink = GetTradeSkillRecipeLink(i) + if not recipeLink then isRecipeCorrect = false; end + if not isRecipeCorrect then + print("Recette incorrecte") + isScanCorrect = false + end -- error checking - if itemID and (numReagents ~= 1 or (reagentID and reagentCount)) and minMade and maxMade and recipeLink then + if isRecipeCorrect then -- remove unneeded minMade/maxMade if maxMade==minMade then maxMade = nil @@ -131,6 +149,9 @@ end -- if end -- for -- the scanning is complete - return true + if not isScanCorrect then + print("Erreur dans le scan") + end + return isScanCorrect end -- function end -- do