Mercurial > wow > reagentmaker
changeset 15:cc56799582f2
Use local references to global functions to speed up scanning
author | contrebasse |
---|---|
date | Wed, 06 Apr 2011 00:28:13 +0200 |
parents | 5c8fcfdd1e24 |
children | 250d01156e21 |
files | ReagentMaker.lua data.lua |
diffstat | 2 files changed, 85 insertions(+), 65 deletions(-) [+] |
line wrap: on
line diff
--- a/ReagentMaker.lua Tue Apr 05 21:59:01 2011 +0200 +++ b/ReagentMaker.lua Wed Apr 06 00:28:13 2011 +0200 @@ -205,27 +205,30 @@ end -- Tooltips - A.tooltipRecipe:SetOwner(btn) - if A.data[reagentID].spell then - A.tooltipRecipe:SetHyperlink(GetSpellLink(A.data[reagentID].spellID)) - else - A.tooltipRecipe:SetHyperlink(GetTradeSkillRecipeLink(A.findSkillIndex(reagentID))) + local reagentIndex = A.findSkillIndex(reagentID) + if reagentIndex then + A.tooltipRecipe:SetOwner(btn) + if A.data[reagentID].spell then + A.tooltipRecipe:SetHyperlink(GetSpellLink(A.data[reagentID].spellID)) + else + A.tooltipRecipe:SetHyperlink(GetTradeSkillRecipeLink(reagentIndex)) + end + A.tooltipRecipe:Show() + A.tooltipRecipe:ClearAllPoints() + --A.tooltipRecipe:SetPoint("TOPLEFT",btn,"TOPRIGHT") + A.tooltipRecipe:SetPoint("BOTTOMLEFT",GameTooltip,"BOTTOMRIGHT") + + --[[ + if #(A.data[reagentID]) == 1 then + A.tooltipReagent:SetOwner(A.tooltipRecipe) + local name, link, quality, iLevel, reqLevel, class, subclass, maxStack, equipSlot, texture, vendorPrice = GetItemInfo(A.data[reagentID][1][1]) + A.tooltipReagent:SetHyperlink(link) + A.tooltipReagent:Show() + A.tooltipReagent:ClearAllPoints() + A.tooltipReagent:SetPoint("BOTTOMLEFT",A.tooltipRecipe,"BOTTOMRIGHT") + end + --]] end - A.tooltipRecipe:Show() - A.tooltipRecipe:ClearAllPoints() - --A.tooltipRecipe:SetPoint("TOPLEFT",btn,"TOPRIGHT") - A.tooltipRecipe:SetPoint("BOTTOMLEFT",GameTooltip,"BOTTOMRIGHT") - - --[[ - if #(A.data[reagentID]) == 1 then - A.tooltipReagent:SetOwner(A.tooltipRecipe) - local name, link, quality, iLevel, reqLevel, class, subclass, maxStack, equipSlot, texture, vendorPrice = GetItemInfo(A.data[reagentID][1][1]) - A.tooltipReagent:SetHyperlink(link) - A.tooltipReagent:Show() - A.tooltipReagent:ClearAllPoints() - A.tooltipReagent:SetPoint("BOTTOMLEFT",A.tooltipRecipe,"BOTTOMRIGHT") - end - --]] end function A.btnLeft(btn)
--- a/data.lua Tue Apr 05 21:59:01 2011 +0200 +++ b/data.lua Wed Apr 06 00:28:13 2011 +0200 @@ -1,9 +1,9 @@ local addonName, A = ... -MillID = 51005 -macroMill = "/cast "..GetSpellInfo(MillID).."\n/use " -ProspectID = 31252 -macroProspect = "/cast "..GetSpellInfo(ProspectID).."\n/use " +local MillID = 51005 +local macroMill = "/cast "..GetSpellInfo(MillID).."\n/use " +local ProspectID = 31252 +local macroProspect = "/cast "..GetSpellInfo(ProspectID).."\n/use " A.data = { -- Mill -- Normal pigments @@ -240,51 +240,68 @@ -- @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 -function A:ScanSimpleRecipes() - for i = 1,GetNumTradeSkills() do - 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)) +do + -- lua functions + local print = print + local ipairs = ipairs + local tinsert = tinsert - -- reagent ID - local reagentID = A.link2ID(GetTradeSkillReagentItemLink(i, 1)) + -- Wow functions + local GetNumTradeSkills = GetNumTradeSkills + local GetTradeSkillInfo = GetTradeSkillInfo + local GetTradeSkillNumReagents = GetTradeSkillNumReagents + local GetTradeSkillItemLink = GetTradeSkillItemLink + local GetTradeSkillReagentItemLink = GetTradeSkillReagentItemLink + local GetTradeSkillReagentInfo = GetTradeSkillReagentInfo + local GetTradeSkillNumMade = GetTradeSkillNumMade - -- reagent number needed - local reagentName, reagentTexture, reagentCount, playerReagentCount = GetTradeSkillReagentInfo(i, 1) + -- the function who scans the tradeskill + function A:ScanSimpleRecipes() + for i = 1,GetNumTradeSkills() do + 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)) - -- number of reagent created by the recipe - local minMade, maxMade = GetTradeSkillNumMade(i) + -- reagent ID + local reagentID = A.link2ID(GetTradeSkillReagentItemLink(i, 1)) - -- error checking - if not reagentID or not reagentCount or not skillName or not itemID or not minMade or not maxMade then - print("Erreur de scan :",itemID,skillName,reagentID,reagentCount,minMade,maxMade) - end + -- reagent number needed + local reagentName, reagentTexture, reagentCount, playerReagentCount = GetTradeSkillReagentInfo(i, 1) - -- remove unneeded minMade/maxMade - if maxMade==minMade then - maxMade = nil - if minMade==1 then - minMade = nil - end - end + -- number of reagent created by the recipe + local minMade, maxMade = GetTradeSkillNumMade(i) - -- skillName or...??? - if not A.data[itemID] then - A.data[itemID] = {} - end - local newSpell = true - for _,v in ipairs(A.data[itemID]) do - if v.spellName==skillName then - newSpell = nil - break - end - end - if newSpell then - tinsert(A.data[itemID],{reagentID,reagentCount,minMade,maxMade,spellName=skillName}) - end + -- error checking + if not reagentID or not reagentCount or not skillName or not itemID or not minMade or not maxMade then + print("Erreur de scan :",itemID,skillName,reagentID,reagentCount,minMade,maxMade) + end -- if + + -- remove unneeded minMade/maxMade + if maxMade==minMade then + maxMade = nil + if minMade==1 then + minMade = nil + end -- if + end -- if + + -- skillName or...??? + if not A.data[itemID] then + A.data[itemID] = {} + end -- if + local newSpell = true + for _,v in ipairs(A.data[itemID]) do + if v.spellName==skillName then + newSpell = nil + break + end -- if + end -- for + if newSpell then + tinsert(A.data[itemID],{reagentID,reagentCount,minMade,maxMade,spellName=skillName}) + end -- if + end -- if end -- if - end -- if - end -- for -end + end -- for + end -- function +end -- do