Mercurial > wow > reagentmaker
diff ReagentMaker.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 | 60871b43531d |
children | 9cf4ca2145a3 |
line wrap: on
line diff
--- a/ReagentMaker.lua Sat May 14 16:56:17 2011 +0200 +++ b/ReagentMaker.lua Sat May 14 20:19:22 2011 +0200 @@ -126,7 +126,7 @@ if not reagentID or not A.data[reagentID] then return end -- If only one recipe is known for the reagent, use it - if #(A.data[reagentID]) == 1 and not A.data[reagentID].spell then + if #(A.data[reagentID]) == 1 and not A.data[reagentID][1].macro then local numMakable, reagentIndex = A.numMakable(reagentID) if not numMakable then A.Error(L["The recipe to make the reagent seems to be hidden, it is not makable."]) @@ -139,7 +139,7 @@ -- If we can make the item needed to make the reagent, open a window to make it -- one step recursion, enables to mill to create an ink - if (not A.data[reagentID].manyReagents) and A.data[A.data[reagentID][1][1]] then + if (not A.data[reagentID][1].manyReagents) and A.data[A.data[reagentID][1][1]] then A.externalCraftWindow(A.data[reagentID][1][1],reagentID) else A.Error(L["You do not have enough reagents to craft [%s]"]:format(GetItemInfo(reagentID) or "item #"..reagentID)) @@ -214,17 +214,28 @@ btn.textureHighlight:Show() + -- Check if the item is made by only one recipe. If not, return + if #A.data[reagentID]>1 then + local spellLink + for _,v in ipairs(A.data[reagentID]) do + if not spellLink then + spellLink = v.spellLink + else + if v.spellLink ~= spellLink then + return + end + end + end + end + -- Tooltips - local link = A.data[reagentID].spellLink + local link = A.data[reagentID][1].spellLink if link then A.tooltipRecipe:SetOwner(btn) A.tooltipRecipe:SetHyperlink(link) A.tooltipRecipe:Show() A.tooltipRecipe:ClearAllPoints() A.tooltipRecipe:SetPoint("BOTTOMLEFT",GameTooltip,"BOTTOMRIGHT") - else - -- Shouldn't happend, but just in case... - A.Error(L["Recipe link not found for %s"]:format(reagentID)) end end @@ -240,7 +251,11 @@ -- Do not manage guild tradeskill if IsTradeSkillGuild() or IsTradeSkillLinked() then for reagentRecipeIndex = 1,GetTradeSkillNumReagents(recipeIndex) do - _G["TradeSkillReagent"..reagentRecipeIndex].label:Hide() + -- If the normal tradeskill hasn't been opened yet, the field 'label' doesn't exists yet + local label = _G["TradeSkillReagent"..reagentRecipeIndex].label + if label then + label:Hide() + end end return end @@ -252,19 +267,24 @@ local reagentID = A.link2ID(reagentLink) local label = _G["TradeSkillReagent"..reagentRecipeIndex].label - if not label then return end + if not label then break end -- Shouldn't happen... -- Continue only if the reagent is known - if not reagentID or not A.data[reagentID] or #(A.data[reagentID]) ~= 1 or A.data[reagentID].spell then + if not reagentID or not A.data[reagentID] then label:Hide() else -- Count and show local numMakable = A.numMakable(reagentID) - label:SetText(numMakable or "?") - if not numMakable or numMakable==0 then - label:SetTextColor(1, 0, 0, 1) + if not numMakable or #(A.data[reagentID]) ~= 1 or A.data[reagentID][1].macro then + label:SetText("?") + label:SetTextColor(0, 0.5, 1, 1) -- blue else - label:SetTextColor(0, 5, 0, 1) + label:SetText(numMakable) + if numMakable==0 then + label:SetTextColor(1, 0, 0, 1) -- red + else + label:SetTextColor(0, 1, 0, 1) -- green + end end -- if label:Show() end -- if