comparison data.lua @ 82:cf1da2654dc6 v1.0beta3

Expand headers when needed. Not heavily tested, could fail on a slow computer...
author contrebasse
date Sun, 15 May 2011 09:23:15 +0200
parents e837f5681fbb
children 10a6078e132f
comparison
equal deleted inserted replaced
81:32c398de6812 82:cf1da2654dc6
26 -- Wow objects 26 -- Wow objects
27 local GetTradeSkillLine = GetTradeSkillLine 27 local GetTradeSkillLine = GetTradeSkillLine
28 28
29 -- the function who scans the tradeskill 29 -- the function who scans the tradeskill
30 function A:ScanSimpleRecipes() 30 function A:ScanSimpleRecipes()
31 -- Do not scan while we modify the tradeskill display
32 if A.blockScan then return end
33
34
31 -- Check if the tradeskill is loaded 35 -- Check if the tradeskill is loaded
32 -- Has to have recipes and begin with a header 36 -- Has to have recipes and begin with a header
33 local NRecipes = GetNumTradeSkills() 37 local NRecipes = GetNumTradeSkills()
34 if NRecipes==0 or select(2,GetTradeSkillInfo(1))~="header" then 38 if NRecipes==0 or select(2,GetTradeSkillInfo(1))~="header" then
35 return 39 return
52 end 56 end
53 A.MillingDataLoaded = true 57 A.MillingDataLoaded = true
54 end 58 end
55 end 59 end
56 60
57 for i = 2,NRecipes do -- The first one is a header 61 local lastHeader
62 for i = 1,NRecipes do
58 -- skillName, skillType, numAvailable, isExpanded, serviceType, numSkillUps = GetTradeSkillInfo(index) 63 -- skillName, skillType, numAvailable, isExpanded, serviceType, numSkillUps = GetTradeSkillInfo(index)
59 -- serviceType is nil if the recipe creates an item 64 -- serviceType is nil if the recipe creates an item
60 local _, skillType, _, _, serviceType = GetTradeSkillInfo(i) 65 local skillName, skillType, _, _, serviceType = GetTradeSkillInfo(i)
61 if skillType and skillType ~= "header" and serviceType==nil then 66 if skillType and skillType == "header" then
67 lastHeader = skillName
68
69 elseif skillType and skillType ~= "header" and serviceType==nil then
62 -- item ID 70 -- item ID
63 local itemID = A.link2ID(GetTradeSkillItemLink(i)) 71 local itemID = A.link2ID(GetTradeSkillItemLink(i))
64 72
65 -- reagent ID, valid only if there's only one reagent as we take only the first one 73 -- reagent ID, valid only if there's only one reagent as we take only the first one
66 local reagentID = A.link2ID(GetTradeSkillReagentItemLink(i, 1)) 74 local reagentID = A.link2ID(GetTradeSkillReagentItemLink(i, 1))
100 -- Cache the data 108 -- Cache the data
101 if addSpell then 109 if addSpell then
102 local spell = {reagentID,reagentCount,minMade,maxMade} 110 local spell = {reagentID,reagentCount,minMade,maxMade}
103 spell.spellID = tradeskillID 111 spell.spellID = tradeskillID
104 spell.spellLink = recipeLink 112 spell.spellLink = recipeLink
113 spell.header = lastHeader
105 spell.manyReagents = GetTradeSkillNumReagents(i)>1 114 spell.manyReagents = GetTradeSkillNumReagents(i)>1
106 tinsert(A.data[itemID],spell) 115 tinsert(A.data[itemID],spell)
107 end 116 end
108 117
109 else -- Zap incomplete recipes, they will be scanned later 118 else -- Zap incomplete recipes, they will be scanned later