Mercurial > wow > reagentmaker
comparison utils.lua @ 116:7ce304c296b0
Display then number of makable items instead of the number of times the recipe is craftable
| author | contrebasse |
|---|---|
| date | Wed, 15 Jun 2011 01:14:00 +0200 |
| parents | af23986010ef |
| children | c32d6bf6cfc1 |
comparison
equal
deleted
inserted
replaced
| 115:5a3fb8fea026 | 116:7ce304c296b0 |
|---|---|
| 67 end | 67 end |
| 68 return m | 68 return m |
| 69 end -- if | 69 end -- if |
| 70 end | 70 end |
| 71 | 71 |
| 72 -- Gives the total number of craftable objects | 72 -- Gives the total number of craftable items |
| 73 function A.numMakable(reagentID) | 73 function A.numMakable(reagentID) |
| 74 -- No recipe | 74 -- No recipe |
| 75 if not A.data[reagentID] then return 0 end | 75 if not A.data[reagentID] then return 0 end |
| 76 | 76 |
| 77 -- Many recipes | 77 -- Many recipes |
| 78 local n = 0 | 78 local n1 = 0 |
| 79 local itemCount | 79 local n2 = 0 |
| 80 local m | |
| 81 local approx = nil | |
| 80 for _,recipe in pairs(A.data[reagentID]) do | 82 for _,recipe in pairs(A.data[reagentID]) do |
| 81 n = n + A.numRecipeMakable(recipe[1],recipe[2]) | 83 -- number of times the recipe is makable |
| 84 m = A.numRecipeMakable(recipe[1],recipe[2]) | |
| 85 if not m then return end | |
| 86 | |
| 87 -- number of items it gives | |
| 88 if not recipe[3] or recipe[3]==1 then | |
| 89 n1 = n1 + m | |
| 90 n2 = n2 + m | |
| 91 elseif recipe[3]<1 then | |
| 92 approx = approx or m>0 -- 0 is not approx | |
| 93 n1 = n1 + m*recipe[3] | |
| 94 n2 = n2 + m*recipe[3] | |
| 95 elseif recipe[4] then | |
| 96 n1 = n1 + m*recipe[3] | |
| 97 n2 = n2 + m*recipe[4] | |
| 98 else | |
| 99 n1 = n1 + m*recipe[3] | |
| 100 n2 = n2 + m*recipe[3] | |
| 101 end | |
| 82 end -- for | 102 end -- for |
| 83 return n | 103 return n1,n2,approx |
| 84 end -- function | 104 end -- function |
| 85 | 105 |
| 86 -- Find the first tradeskill index of the recipe to make an item | 106 -- Find the first tradeskill index of the recipe to make an item |
| 87 function A.findSkillIndex(itemID) | 107 function A.findSkillIndex(itemID) |
| 88 if not itemID then return end | 108 if not itemID then return end |
