Share Pastebin
Guest
Public paste!

Untitled

By: a guest | Jun 15th, 2009 | Syntax: None | Size: 4.01 KB | Hits: 51 | Expires: Never
Copy text to clipboard
  1. Index: frameSupport/skillet_support.lua
  2. ===================================================================
  3. --- frameSupport/skillet_support.lua    (revision 72)
  4. +++ frameSupport/skillet_support.lua    (working copy)
  5.  -65,8 +65,25 @@
  6.         end
  7.  
  8.  
  9. +       local function SortItemCount(tradeskill, a, b)
  10. +               while a.subGroup and #a.subGroup.entries>0 do
  11. +               a = a.subGroup.entries[1]
  12. +               end
  13.  
  14. +               while b.subGroup and #b.subGroup.entries>0 do
  15. +                       b = b.subGroup.entries[1]
  16. +               end
  17.  
  18. +               local itemCountA = LSW:GetItemOwned(a.recipeID)
  19. +               local itemCountB = LSW:GetItemOwned(b.recipeID)
  20. +
  21. +               itemCountA = itemCountA or 0
  22. +               itemCountB = itemCountB or 0
  23. +
  24. +               if (itemCountA > itemCountB) then return true; end
  25. +                       return false;
  26. +               end
  27. +
  28.         local function SortCompareItemValue(tradeskill, a, b)
  29.                 while a.subGroup and #a.subGroup.entries>0 do
  30.                         a = a.subGroup.entries[1]
  31.  -213,6 +230,7 @@
  32.                         Skillet:AddRecipeSorter("LSW: Item Value", SortCompareItemValue)
  33.                         Skillet:AddRecipeSorter("LSW: Reagent Cost", SortCompareReagentCost)
  34.                         Skillet:AddRecipeSorter("LSW: Profit", SortCompareProfit)
  35. +                       Skillet:AddRecipeSorter("LSW: Item Count", SortItemCount)
  36.                 else
  37.                         Skillet:AddRecipeSorter("LSW: Item Value", SortCompareItemValue_OLD)
  38.                         Skillet:AddRecipeSorter("LSW: Reagent Cost", SortCompareReagentCost_OLD)
  39. Index: lilsparkysworkshop.lua
  40. ===================================================================
  41. --- lilsparkysworkshop.lua      (revision 72)
  42. +++ lilsparkysworkshop.lua      (working copy)
  43.  -319,6 +319,20 @@
  44.  
  45.         local periodicTable
  46.  
  47. +        local function _GetItemCount(itemID)
  48. +          if IsAddOnLoaded("Altoholic") then
  49. +           local count = Altoholic:GetItemCount(itemID)
  50. +           if count ~= 0 then
  51. +           end
  52. +           return count
  53. +          else
  54. +           return GetItemCount(itemID)
  55. +          end
  56. +        end
  57. +        
  58. +        function LSW:GetItemCount(itemID)
  59. +          return _GetItemCount(itemID)
  60. +        end
  61.  
  62.         local timerList = {}
  63.  
  64.  -905,7 +919,18 @@
  65.                 end
  66.         end
  67.  
  68. -
  69. +        local function UpdateItemOwned(itemID)
  70. +          local cache = itemCache[itemID]
  71. +          if cache then
  72. +            local _, itemLink = GetItemInfo(itemID)
  73. +            if cache.syncOwned ~= priceDataSync then
  74. +              cache.syncOwned = priceDataSync
  75. +              cache.owned = _GetItemCount(itemID)
  76. +            end
  77. +          end
  78. +          return cache.owned
  79. +        end
  80. +            
  81.         local function UpdateItemValue(itemID)
  82.                 local cache = itemCache[itemID]
  83.  
  84.  -1109,6 +1134,7 @@
  85.                                         for itemID in pairs(cache.craftResults) do
  86.                                                 UpdateItemCost(itemID)
  87.                                                 UpdateItemValue(itemID)
  88. +                                               UpdateItemOwned(itemID)
  89.                                         end
  90.                                 end
  91.  
  92.  -1277,7 +1303,19 @@
  93.                 return 0
  94.         end
  95.  
  96. -
  97. +        function LSW:GetItemOwned(recipeID)
  98. +          local rCache = recipeCache[recipeID]
  99. +          if not rCache then
  100. +            return
  101. +          end
  102. +          local total = 0
  103. +          for itemID,numMade in pairs(rCache.craftResults) do
  104. +            local cache = itemCache[itemID]
  105. +            total = total + (cache.owned or 0)
  106. +          end
  107. +          return total
  108. +        end
  109. +            
  110.         function LSW:GetSkillValue(recipeID, fate)
  111.                 if not fate then
  112.                         fate = globalFate
  113.  -1377,7 +1415,7 @@
  114.  
  115.                         if itemFate == "a" and alt then
  116.                                 local iCache = itemCache[itemID]
  117. -                               valueText = ((iCache and iCache.auctionValueCount) or 0).." ("..(GetItemCount(itemID) or 0)..")"
  118. +                               valueText = ((iCache and iCache.auctionValueCount) or 0).." ("..(_GetItemCount(itemID) or 0)..")"
  119.                         elseif itemFate == "a" and itemCache[itemID] and itemCache[itemID].BOP then
  120.                                 valueText = BOP_STRING
  121.                         elseif itemFate == "d" and itemCache[itemID] and not itemCache[itemID].disenchantValue then
  122.  -1665,7 +1703,11 @@
  123.                                                 itemLink = GetSpellLink(recipeID)
  124.                                         end
  125.  
  126. +                                       if not itemLink then
  127. +                                               return
  128. +                                       end
  129.  
  130. +
  131.                                         if LSWConfig.singleColumn then
  132.                                                 local totalCost = CostButton_OnEnter(button)
  133.                                                 LSWTooltip:AddLine(" ")