# HG changeset patch # User Zerotorescue # Date 1294868905 -3600 # Node ID 3bbad0429d8704af9ef1092331f40859a6cdeb0e # Parent 3688fdd14feff772b4a0f6b9c1461412dc83872b Now only giving the ?bags are full? message once per item rather then for every queued move. Neater coding for the container functions and prepared mailbox support (although this is not currently planned to be further developed for the moment). Updated todo list to include mailbox support. diff -r 3688fdd14fef -r 3bbad0429d87 Modules/Mover.lua --- a/Modules/Mover.lua Wed Jan 12 20:09:11 2011 +0100 +++ b/Modules/Mover.lua Wed Jan 12 22:48:25 2011 +0100 @@ -145,6 +145,13 @@ addon:Print(("Bags are full. Skipping %s."):format(IdToItemLink(outgoingMove.itemId)), addon.Colors.Orange); outgoingMove.itemId = nil; -- remove this record from the outgoingMoves-table + + -- Not a single item with this item id can be moved, since we only want the bags are full announcement once, we remove all other moves with this item id + for _, otherMove in pairs(outgoingMoves) do + if otherMove.itemId and otherMove.itemId == outgoingMove.itemId then + otherMove.itemId = nil; + end + end else table.insert(combinedMoves, { itemId = outgoingMove.itemId, @@ -266,6 +273,41 @@ onFinish(); end +local ContainerFunctions = { + [addon.Locations.Bag] = { + GetItemId = GetContainerItemID, + PickupItem = SplitContainerItem, + IsLocked = function(sourceContainer, sourceSlot) + return select(3, GetContainerItemInfo(sourceContainer, sourceSlot); + end, + }, + [addon.Locations.Bank] = { + GetItemId = GetContainerItemID, + PickupItem = SplitContainerItem, + IsLocked = function(sourceContainer, sourceSlot) + return select(3, GetContainerItemInfo(sourceContainer, sourceSlot); + end, + }, + [addon.Locations.Guild] = { + GetItemId = function(tabId, slotId) + return addon:GetItemId(GetGuildBankItemLink(tabId, slotId)); + end, + PickupItem = SplitGuildBankItem, + IsLocked = function(sourceContainer, sourceSlot) + return select(3, GetGuildBankItemInfo(sourceContainer, sourceSlot); + end, + }, + --[[ Even though support is possible, it will require a little more work than just this and there are currently higher priorities + [addon.Locations.Mailbox] = { + GetItemId = function(mailIndex, attachmentId) + return addon:GetItemId(GetInboxItemLink(mailIndex, attachmentId)); + end, + PickupItem = TakeInboxItem, + IsLocked = function() return false; end, + DoNotDrop = true, + },]] +}; + function mod:ProcessMove() addon:Debug("ProcessMove"); @@ -291,40 +333,27 @@ local sourceLocationsLocked = {}; local targetLocationsLocked = {}; - local _GetContainerItemId = GetContainerItemID; - if movesSource == addon.Locations.Guild then - _GetContainerItemId = function(tabId, slotId) return addon:GetItemId(GetGuildBankItemLink(tabId, slotId)); end; - end - local _GetContainerItemInfo = GetContainerItemInfo; - if movesSource == addon.Locations.Guild then - _GetContainerItemInfo = GetGuildBankItemInfo; - end - local combinedMovesOriginalLength = #combinedMoves; local numCurrentMove = combinedMovesOriginalLength; while numCurrentMove ~= 0 do local move = combinedMoves[numCurrentMove]; - local isSourceLocked = ((sourceLocationsLocked[move.sourceContainer] and sourceLocationsLocked[move.sourceContainer][move.sourceSlot]) or select(3, _GetContainerItemInfo(move.sourceContainer, move.sourceSlot))); - local isTargetLocked = ((targetLocationsLocked[move.targetContainer] and targetLocationsLocked[move.targetContainer][move.targetSlot]) or select(3, GetContainerItemInfo(move.targetContainer, move.targetSlot))); + local isSourceLocked = ((sourceLocationsLocked[move.sourceContainer] and sourceLocationsLocked[move.sourceContainer][move.sourceSlot]) or ContainerFunctions[movesSource].IsLocked(move.sourceContainer, move.sourceSlot)); + -- Target are always the local bags + local isTargetLocked = ((targetLocationsLocked[move.targetContainer] and targetLocationsLocked[move.targetContainer][move.targetSlot]) or ContainerFunctions[addon.Locations.Bag].IsLocked(move.targetContainer, move.targetSlot)); if move and not isSourceLocked and not isTargetLocked then - addon:Print(("Moving %dx%s."):format(move.num, IdToItemLink(move.itemId))); addon:Debug("Moving %dx%s from (%d,%d) to (%d,%d)", move.num, IdToItemLink(move.itemId), move.sourceContainer, move.sourceSlot, move.targetContainer, move.targetSlot); - if _GetContainerItemId(move.sourceContainer, move.sourceSlot) ~= move.itemId then + if ContainerFunctions[movesSource].GetItemId(move.sourceContainer, move.sourceSlot) ~= move.itemId then self:Abort("source changed", "Source (" .. move.sourceContainer .. "," .. move.sourceSlot .. ") is not " .. IdToItemLink(move.itemId)); return; end -- Pickup stack - if movesSource == addon.Locations.Bank then - SplitContainerItem(move.sourceContainer, move.sourceSlot, move.num); - elseif movesSource == addon.Locations.Guild then - SplitGuildBankItem(move.sourceContainer, move.sourceSlot, move.num); - end + ContainerFunctions[movesSource].PickupItem(move.sourceContainer, move.sourceSlot, move.num); -- Remember we picked this item up and thus it is now locked if not sourceLocationsLocked[move.sourceContainer] then @@ -332,9 +361,9 @@ end sourceLocationsLocked[move.sourceContainer][move.sourceSlot] = true; - if movesSource == addon.Locations.Guild or CursorHasItem() then -- CursorHasItem is always false if source is a guild tab + if movesSource ~= addon.Locations.Bank or CursorHasItem() then -- CursorHasItem only works when moving outside of the bank -- We are moving into our local bags, so the below must check normal - local targetItemId = GetContainerItemID(move.targetContainer, move.targetSlot); + local targetItemId = ContainerFunctions[movesSource].get(move.targetContainer, move.targetSlot); if targetItemId and targetItemId ~= move.itemId then self:Abort("target changed", "Target (" .. move.targetContainer .. "," .. move.targetSlot .. ") is not " .. IdToItemLink(move.itemId) .. " nor empty"); return; diff -r 3688fdd14fef -r 3bbad0429d87 Modules/Scanner.lua --- a/Modules/Scanner.lua Wed Jan 12 20:09:11 2011 +0100 +++ b/Modules/Scanner.lua Wed Jan 12 22:48:25 2011 +0100 @@ -5,6 +5,7 @@ Bag = 0, Bank = 1, Guild = 2, + Mailbox = 3, }; local Mover, paused, currentLocation; diff -r 3688fdd14fef -r 3bbad0429d87 Todo.txt --- a/Todo.txt Wed Jan 12 20:09:11 2011 +0100 +++ b/Todo.txt Wed Jan 12 22:48:25 2011 +0100 @@ -8,4 +8,5 @@ Might also need an undo button - Advanced implementation: record queueing with exact time and date and show a nice linechart for each item. Probably would have to write a new lib for the symbols. (low) * Enchanting -> scroll self-learning (low) - * Remember position of the summary window. (low) \ No newline at end of file + * Remember position of the summary window. (low) + * Provide item refilling from mailbox support. (low)