# HG changeset patch # User Asa Ayers # Date 1281595703 25200 # Node ID 4ec8611d9466eb791b4f94c79a8ebee958e789fe # Parent 693f664aad2b07899cb17168df91de9bc4c095b1 Fixed Enchanting. I was not getting the ItemID correctly, so enchants could not be mapped to the scrolls they were to created Changed snatch to only add each item once and to only add a snatch for items you don't have API: Added haveMaterials to the item and need to the reagents that get passed to queue destinations. This is in preparation for building a shopping list module. diff -r 693f664aad2b -r 4ec8611d9466 CHANGELOG.txt --- a/CHANGELOG.txt Wed Aug 11 22:16:59 2010 -0700 +++ b/CHANGELOG.txt Wed Aug 11 23:48:23 2010 -0700 @@ -4,6 +4,9 @@ - Fixed a bug where postage was being counted more than once if you send mail and then open mail in the same session. - Added a warning when sending items with value to characters on other accounts. - Added '/ia snatch'. This new command works with your queue (/ia crafting) to replace your snatch list with the materials you need for crafting. NOTE: Auctioneer requires visiting the AH before you can modify the snatch list. +- Fixed Enchanting. I was not getting the ItemID correctly, so enchants could not be mapped to the scrolls they were to created +- Changed snatch to only add each item once and to only add a snatch for items you don't have +- API: Added haveMaterials to the item and need to the reagents that get passed to queue destinations. This is in preparation for building a shopping list module. 2010-08-10 Asa Ayers diff -r 693f664aad2b -r 4ec8611d9466 Modules/AuctionHouse.lua --- a/Modules/AuctionHouse.lua Wed Aug 11 22:16:59 2010 -0700 +++ b/Modules/AuctionHouse.lua Wed Aug 11 23:48:23 2010 -0700 @@ -105,10 +105,16 @@ end clearSnatch() + local snatchList = {} local function Export(data) - for id, reagent in pairs(data.reagents) do - ItemAuditor:Print("Adding %s for %s", reagent.link, Utils.FormatMoney(reagent.price)) - Snatch.AddSnatch(reagent.link, reagent.price) + if not data.haveMaterials then + for id, reagent in pairs(data.reagents) do + if reagent.need > 0 and not snatchList[reagent.link] then + snatchList[reagent.link] = true + ItemAuditor:Print("Adding %s for %s", reagent.link, Utils.FormatMoney(reagent.price)) + Snatch.AddSnatch(reagent.link, reagent.price) + end + end end end ItemAuditor:UpdateCraftingTable() diff -r 693f664aad2b -r 4ec8611d9466 Modules/Crafting.lua --- a/Modules/Crafting.lua Wed Aug 11 22:16:59 2010 -0700 +++ b/Modules/Crafting.lua Wed Aug 11 23:48:23 2010 -0700 @@ -389,6 +389,8 @@ name = reagentName, count = reagentCount, price = self:GetReagentCost(reagentLink, reagentCount), + need = 0, -- This will get populated after the decisions have been made. it can't + -- be done before that because highest profit items get priority on materials. } totalCost = totalCost + self:GetReagentCost(reagentLink, reagentCount) end @@ -420,6 +422,23 @@ end end table.sort(realData, function(a, b) return a.profit*a.queue > b.profit*b.queue end) + + local numOwned = {} + for key, data in pairs(realData) do + data.haveMaterials = true + for id, reagent in pairs(data.reagents) do + if not numOwned[reagent.link] then + numOwned[reagent.link] = ItemAuditor:GetItemCount(ItemAuditor:GetIDFromLink(reagent.link)) + end + numOwned[reagent.link] = numOwned[reagent.link] - reagent.count + + if numOwned[reagent.link] < 0 then + data.haveMaterials = false + reagent.need = min(reagent.count, abs(numOwned[reagent.link])) + end + end + end + if craftingTable then craftingTable:SetFilter(tableFilter) self:RefreshCraftingTable() diff -r 693f664aad2b -r 4ec8611d9466 Modules/Utils.lua --- a/Modules/Utils.lua Wed Aug 11 22:16:59 2010 -0700 +++ b/Modules/Utils.lua Wed Aug 11 23:48:23 2010 -0700 @@ -76,6 +76,9 @@ if itemLink ~= nil then local _, _, _, _, itemID = string.find(itemLink, "|?c?f?f?(%x*)|?H?([^:]*):?(%d+):?(%d*):?(%d*):?(%d*):?(%d*):?(%d*):?(%-?%d*):?(%-?%d*):?(%d*)|?h?%[?([^%[%]]*)%]?|?h?|?r?") tmp_item_cache[item] = tonumber(itemID) + else + local _, _, _, _, itemID = string.find(item, "|?c?f?f?(%x*)|?H?([^:]*):?(%d+):?(%d*):?(%d*):?(%d*):?(%d*):?(%d*):?(%-?%d*):?(%-?%d*):?(%d*)|?h?%[?([^%[%]]*)%]?|?h?|?r?") + tmp_item_cache[item] = tonumber(itemID) end end @@ -87,9 +90,7 @@ tmp_item_cache[item] = tonumber(itemID) end end - end - return tmp_item_cache[item] end