Mercurial > wow > reagentmaker
view data.lua @ 77:cd36938d2a48
Add a button to put enchants directly on a scroll
author | contrebasse |
---|---|
date | Sat, 14 May 2011 23:54:02 +0200 |
parents | e837f5681fbb |
children | cf1da2654dc6 |
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() -- 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 tradeskillID = GetTradeSkillLine() -- Check if the pseudo tradeskills have to be added 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 tradeskillID == 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 for i = 2,NRecipes do -- The first one is a header -- 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 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.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 end -- do