annotate Mover.lua @ 80:c0bf2ddb5288

Added initial item refilling from the bank/guild. Not yet fully functional.
author Zerotorescue
date Wed, 05 Jan 2011 13:05:15 +0100
parents
children 58617c7827fa
rev   line source
Zerotorescue@80 1 local addon = select(2, ...);
Zerotorescue@80 2 local mod = addon:NewModule("Mover", "AceEvent-3.0", "AceTimer-3.0");
Zerotorescue@80 3
Zerotorescue@80 4 local Scanner;
Zerotorescue@80 5 local queuedMoves = {}; -- table storing all queued moves before BeginMove is called
Zerotorescue@80 6 local combinedMoves = {}; -- table storing all combined moves (with source and target) that is to be processed by the actual mover in the order of the index (1 to #)
Zerotorescue@80 7
Zerotorescue@80 8 function mod:AddMove(itemId, amount)
Zerotorescue@80 9 table.insert(queuedMoves, {
Zerotorescue@80 10 id = itemId,
Zerotorescue@80 11 num = amount,
Zerotorescue@80 12 });
Zerotorescue@80 13 end
Zerotorescue@80 14
Zerotorescue@80 15 function mod:BeginMove(location, onFinish)
Zerotorescue@80 16
Zerotorescue@80 17 -- Find the outgoing moves
Zerotorescue@80 18 -- We need the source container and slot, find all the requires sources and put them in a list which we go through later to find matching targets
Zerotorescue@80 19
Zerotorescue@80 20 -- Get a list of items in the source container
Zerotorescue@80 21 local sourceContents = Scanner:CacheLocation(location, false);
Zerotorescue@80 22
Zerotorescue@80 23 local outgoingMoves = {};
Zerotorescue@80 24
Zerotorescue@80 25 for singleMove in pairs(queuedMoves) do
Zerotorescue@80 26 local sourceItem = sourceContents[singleMove.id];
Zerotorescue@80 27 if not sourceItem then
Zerotorescue@80 28 print("Can't move " .. IdToItemLink(singleMove.id) .. ", non-existant in source");
Zerotorescue@80 29 else
Zerotorescue@80 30 -- We want to move the smallest stacks first to keep stuff pretty
Zerotorescue@80 31 table.sort(sourceItem.locations, function(a, b)
Zerotorescue@80 32 return a.count > b.count;
Zerotorescue@80 33 end);
Zerotorescue@80 34
Zerotorescue@80 35 for itemLocation in pairs(sourceItem.locations) do
Zerotorescue@80 36 -- if this location has more items than we need, only move what we need, otherwise move everything in this stack
Zerotorescue@80 37 local movingNum = ((itemLocation.count > singleMove.num and singleMove.num) or itemLocation.count);
Zerotorescue@80 38
Zerotorescue@80 39 table.insert(outgoingMoves, {
Zerotorescue@80 40 itemId = singleMove.id,
Zerotorescue@80 41 container = itemLocation.container,
Zerotorescue@80 42 slot = itemLocation.slot,
Zerotorescue@80 43 count = movingNum,
Zerotorescue@80 44 });
Zerotorescue@80 45
Zerotorescue@80 46 singleMove.num = (singleMove.num - movingNum);
Zerotorescue@80 47
Zerotorescue@80 48 if singleMove.num == 0 then
Zerotorescue@80 49 -- If we have prepared everything we wanted, go to the next queued move
Zerotorescue@80 50 break;
Zerotorescue@80 51 end
Zerotorescue@80 52 end
Zerotorescue@80 53 end
Zerotorescue@80 54 end
Zerotorescue@80 55
Zerotorescue@80 56 -- No longer needed
Zerotorescue@80 57 table.wipe(queuedMoves);
Zerotorescue@80 58
Zerotorescue@80 59 -- Process every single outgoing move and find fitting targets
Zerotorescue@80 60
Zerotorescue@80 61 -- Get a list of items already in the target container
Zerotorescue@80 62 local targetContents = Scanner:CacheLocation(addon.Locations.Bag, false);
Zerotorescue@80 63
Zerotorescue@80 64 -- Find all empty slots
Zerotorescue@80 65
Zerotorescue@80 66 local emptySlots = {};
Zerotorescue@80 67
Zerotorescue@80 68 local start = 0;
Zerotorescue@80 69 local stop = NUM_BAG_SLOTS;
Zerotorescue@80 70
Zerotorescue@80 71 -- Go through all our bags, including the backpack
Zerotorescue@80 72 for bagId = start, stop do
Zerotorescue@80 73 -- Go through all our slots
Zerotorescue@80 74 for slotId = 1, GetContainerNumSlots(bagId) do
Zerotorescue@80 75 local itemId = GetContainerItemID(bagId, slotId);
Zerotorescue@80 76
Zerotorescue@80 77 if not itemId then
Zerotorescue@80 78 table.insert(emptySlots, {
Zerotorescue@80 79 container: bagId,
Zerotorescue@80 80 slot: slotId,
Zerotorescue@80 81 });
Zerotorescue@80 82 end
Zerotorescue@80 83 end
Zerotorescue@80 84 end
Zerotorescue@80 85
Zerotorescue@80 86 while #outgoingMoves ~= 0 do
Zerotorescue@80 87 -- A not equal-comparison should be quicker than a larger/smaller than-comparison
Zerotorescue@80 88
Zerotorescue@80 89 for outgoingMove in pairs(outgoingMoves) do
Zerotorescue@80 90 -- itemId will be set to nil when this outgoing move was processed - sanity check
Zerotorescue@80 91 if outgoingMove.itemId then
Zerotorescue@80 92 local targetItem = targetContents[outgoingMove.itemId];
Zerotorescue@80 93
Zerotorescue@80 94 if not targetItem then
Zerotorescue@80 95 -- grab an empty slot
Zerotorescue@80 96 -- make new instance of ItemMove
Zerotorescue@80 97 -- populate targetContents with it so future moves of this item can be put on top of it if this isn't a full stack
Zerotorescue@80 98
Zerotorescue@80 99 local firstAvailableSlot = emptySlots[1];
Zerotorescue@80 100
Zerotorescue@80 101 if not firstAvailableSlot then
Zerotorescue@80 102 print("Bags are full. Skipping " .. IdToItemLink(outgoingMove.itemId) .. ".");
Zerotorescue@80 103
Zerotorescue@80 104 outgoingMove.itemId = nil;
Zerotorescue@80 105 else
Zerotorescue@80 106 table.insert(combinedMoves, {
Zerotorescue@80 107 sourceContainer = outgoingMove.container,
Zerotorescue@80 108 sourceSlot = outgoingMove.slot,
Zerotorescue@80 109 targetContainer = firstAvailableSlot.container,
Zerotorescue@80 110 targetSlot = firstAvailableSlot.slot,
Zerotorescue@80 111 itemId = outgoingMove.itemId,
Zerotorescue@80 112 num = outgoingMove.count,
Zerotorescue@80 113 });
Zerotorescue@80 114
Zerotorescue@80 115 -- We filled an empty slot so the target contents now has one more item,
Zerotorescue@80 116 -- make a new instance of the ItemMove class so any additional items with this id can be stacked on top of it
Zerotorescue@80 117 local itemMove = addon.ItemMove:New();
Zerotorescue@80 118 itemMove.AddLocation(firstAvailableSlot.container, firstAvailableSlot.slot, outgoingMove.count);
Zerotorescue@80 119 targetContents[outgoingMove.itemId] = itemMove;
Zerotorescue@80 120
Zerotorescue@80 121 firstAvailableSlot = nil; -- no longer empty
Zerotorescue@80 122
Zerotorescue@80 123 outgoingMove.count = 0; -- nothing remaining - sanity check
Zerotorescue@80 124 outgoingMove.itemId = nil; -- remove this record from the outgoingMoves-table
Zerotorescue@80 125 end
Zerotorescue@80 126 else
Zerotorescue@80 127 -- Find the maximum stack size for this item
Zerotorescue@80 128 local itemStackCount = select(8, GetItemInfo(outgoingMove.itemId));
Zerotorescue@80 129
Zerotorescue@80 130 -- We want to move to the largest stacks first to keep stuff pretty
Zerotorescue@80 131 table.sort(targetItem.locations, function(a, b)
Zerotorescue@80 132 return a.count < b.count;
Zerotorescue@80 133 end);
Zerotorescue@80 134
Zerotorescue@80 135 for itemLocation in pairs(targetItem.locations) do
Zerotorescue@80 136 if itemLocation.count < itemStackCount and outgoingMove.count > 0 then
Zerotorescue@80 137 -- Check if this stack isn't already full (and we still need to move this item)
Zerotorescue@80 138
Zerotorescue@80 139 local remainingSpace = (itemStackCount - itemLocation.count);
Zerotorescue@80 140 if remainingSpace > outgoingMove.count then
Zerotorescue@80 141 -- Enough room to move this entire stack
Zerotorescue@80 142 -- Deposit this item and then forget this outgoing move as everything in it was processed
Zerotorescue@80 143
Zerotorescue@80 144 table.insert(combinedMoves, {
Zerotorescue@80 145 sourceContainer = outgoingMove.container,
Zerotorescue@80 146 sourceSlot = outgoingMove.slot,
Zerotorescue@80 147 targetContainer = itemLocation.container,
Zerotorescue@80 148 targetSlot = itemLocation.slot,
Zerotorescue@80 149 itemId = outgoingMove.itemId,
Zerotorescue@80 150 num = outgoingMove.count,
Zerotorescue@80 151 });
Zerotorescue@80 152
Zerotorescue@80 153 itemLocation.count = (itemLocation.count + outgoingMove.count);
Zerotorescue@80 154 outgoingMove.count = 0; -- nothing remaining
Zerotorescue@80 155 outgoingMove.itemId = nil; -- remove this record from the outgoingMoves-table
Zerotorescue@80 156 break; -- stop the locations-loop
Zerotorescue@80 157 else
Zerotorescue@80 158 -- Deposit this item but don't remove the outgoing move as there are some items left to move
Zerotorescue@80 159
Zerotorescue@80 160 table.insert(combinedMoves, {
Zerotorescue@80 161 sourceContainer = outgoingMove.container,
Zerotorescue@80 162 sourceSlot = outgoingMove.slot,
Zerotorescue@80 163 targetContainer = itemLocation.container,
Zerotorescue@80 164 targetSlot = itemLocation.slot,
Zerotorescue@80 165 itemId = outgoingMove.itemId,
Zerotorescue@80 166 num = outgoingMove.count,
Zerotorescue@80 167 });
Zerotorescue@80 168
Zerotorescue@80 169 -- The target will be full when we complete, but the source will still have remaining items left to be moved
Zerotorescue@80 170 itemLocation.count = itemStackCount;
Zerotorescue@80 171 outgoingMove.count = (outgoingMove.count - remainingSpace);
Zerotorescue@80 172 end
Zerotorescue@80 173 end
Zerotorescue@80 174 end
Zerotorescue@80 175
Zerotorescue@80 176 if outgoingMove.count > 0 then
Zerotorescue@80 177 -- We went through all matching items and checked their stack sizes if we could move this there, no room available
Zerotorescue@80 178 -- So forget about the target item (even though it may just have full locations, these are useless anyway) and the next loop move it onto an empty slot
Zerotorescue@80 179 targetItem = nil;
Zerotorescue@80 180 end
Zerotorescue@80 181 end
Zerotorescue@80 182 end
Zerotorescue@80 183 end
Zerotorescue@80 184
Zerotorescue@80 185 -- Loop through the array to find items that should be removed, start with the last element or the loop would break
Zerotorescue@80 186 local numOutgoingMoves = #outgoingMoves; -- since LUA-tables start at an index of 1, this is actually an existing index (outgoingMoves[#outgoingMoves] would return a value)
Zerotorescue@80 187 while numOutgoingMoves ~= 0 do
Zerotorescue@80 188 -- A not equal-comparison should be quicker than a larger/smaller than-comparison
Zerotorescue@80 189
Zerotorescue@80 190 -- Check if the item id is nil, this is set to nil when this outgoing move has been processed
Zerotorescue@80 191 if not outgoingMoves[numOutgoingMoves].itemId then
Zerotorescue@80 192 -- Remove this element from the array
Zerotorescue@80 193 table.remove(outgoingMoves, numOutgoingMoves);
Zerotorescue@80 194 end
Zerotorescue@80 195
Zerotorescue@80 196 -- Proceed with the next element (or previous considering we're going from last to first)
Zerotorescue@80 197 numOutgoingMoves = (numOutgoingMoves - 1);
Zerotorescue@80 198 end
Zerotorescue@80 199 end
Zerotorescue@80 200
Zerotorescue@80 201 -- No longer needed
Zerotorescue@80 202 table.wipe(emptySlots);
Zerotorescue@80 203
Zerotorescue@80 204 DoMoveNow();
Zerotorescue@80 205
Zerotorescue@80 206 --ProcessMove();
Zerotorescue@80 207
Zerotorescue@80 208 --mod:RegisterEvent("BAG_UPDATE", BAG_UPDATE);
Zerotorescue@80 209
Zerotorescue@80 210 --onFinish();
Zerotorescue@80 211 end
Zerotorescue@80 212
Zerotorescue@80 213 function DoMoveNow()
Zerotorescue@80 214 -- combinedMoves now has all moves in it (source -> target)
Zerotorescue@80 215 -- go through list, move everything inside it
Zerotorescue@80 216 -- add source and target to one single list
Zerotorescue@80 217 -- if either is already in this list, skip this move
Zerotorescue@80 218 -- repeat every 5 seconds until we're completely done
Zerotorescue@80 219
Zerotorescue@80 220 local sourceLocationsLocked = {};
Zerotorescue@80 221 local targetLocationsLocked = {};
Zerotorescue@80 222
Zerotorescue@80 223 local numCurrentMove = #combinedMoves;
Zerotorescue@80 224 while numCurrentMove ~= 0 do
Zerotorescue@80 225 local move = combinedMoves[numCurrentMove];
Zerotorescue@80 226
Zerotorescue@80 227 -- sourceContainer, sourceSlot, targetContainer, targetSlot, itemId, num
Zerotorescue@80 228 if (not sourceLocationsLocked[move.sourceContainer] or not sourceLocationsLocked[move.sourceContainer][move.sourceSlot]) and
Zerotorescue@80 229 (not targetLocationsLocked[move.targetContainer] or not targetLocationsLocked[move.targetContainer][move.targetSlot]) then
Zerotorescue@80 230
Zerotorescue@80 231 print("Moving " .. IdToItemLink(move.itemId));
Zerotorescue@80 232
Zerotorescue@80 233 -- Pickup stack
Zerotorescue@80 234 SplitGuildBankItem(move.sourceContainer, move.sourceSlot, move.num);
Zerotorescue@80 235
Zerotorescue@80 236 -- Remember we picked this item up and thus it is now locked
Zerotorescue@80 237 if not sourceLocationsLocked[move.sourceContainer] then
Zerotorescue@80 238 sourceLocationsLocked[move.sourceContainer] = {};
Zerotorescue@80 239 end
Zerotorescue@80 240 sourceLocationsLocked[move.sourceContainer][move.sourceSlot] = true;
Zerotorescue@80 241
Zerotorescue@80 242 if CursorHasItem() then
Zerotorescue@80 243 -- And drop it
Zerotorescue@80 244 PickupContainerItem(move.targetContainer, move.targetSlot);
Zerotorescue@80 245
Zerotorescue@80 246 -- Remember we dropped an item here and thus this is now locked
Zerotorescue@80 247 if not sourceLocationsLocked[move.targetContainer] then
Zerotorescue@80 248 sourceLocationsLocked[move.targetContainer] = {};
Zerotorescue@80 249 end
Zerotorescue@80 250 sourceLocationsLocked[move.targetContainer][move.targetSlot] = true;
Zerotorescue@80 251
Zerotorescue@80 252 -- This move was processed
Zerotorescue@80 253 table.remove(combinedMoves, numCurrentMove);
Zerotorescue@80 254 end
Zerotorescue@80 255 end
Zerotorescue@80 256
Zerotorescue@80 257 -- Proceed with the next element (or previous considering we're going from last to first)
Zerotorescue@80 258 numCurrentMove = (numCurrentMove - 1);
Zerotorescue@80 259 end
Zerotorescue@80 260 end
Zerotorescue@80 261
Zerotorescue@80 262 local tmrProcessNext;
Zerotorescue@80 263 function BAG_UPDATE()
Zerotorescue@80 264 mod:CancelTimer(tmrProcessNext, true); -- silent
Zerotorescue@80 265 tmrProcessNext = mod:ScheduleTimer(function()
Zerotorescue@80 266 ProcessMove();
Zerotorescue@80 267 end, 2);
Zerotorescue@80 268 end
Zerotorescue@80 269
Zerotorescue@80 270 function ProcessMove()
Zerotorescue@80 271 local currentMove = queuedMoves[1];
Zerotorescue@80 272
Zerotorescue@80 273 if currentMove then
Zerotorescue@80 274 addon:Debug("Moving " .. currentMove.num .. " of " .. IdToItemLink(currentMove.id));
Zerotorescue@80 275
Zerotorescue@80 276 local requestedMoves = currentMove.num;
Zerotorescue@80 277
Zerotorescue@80 278 if currentMove.src == addon.Locations.Bank then
Zerotorescue@80 279 MoveBankItem(currentMove);
Zerotorescue@80 280 elseif currentMove.src == addon.Locations.Guild then
Zerotorescue@80 281 MoveGuildItem(currentMove);
Zerotorescue@80 282 end
Zerotorescue@80 283
Zerotorescue@80 284 if requestedMoves == currentMove.num then
Zerotorescue@80 285 print("Skipping " .. IdToItemLink(move.id));
Zerotorescue@80 286 move.num = 0;
Zerotorescue@80 287 elseif currentMove.num > 0 then
Zerotorescue@80 288 -- bags are full
Zerotorescue@80 289 print("bags are full");
Zerotorescue@80 290 end
Zerotorescue@80 291
Zerotorescue@80 292 if currentMove.num == 0 then
Zerotorescue@80 293 table.remove(queuedMoves, 1);
Zerotorescue@80 294 end
Zerotorescue@80 295 end
Zerotorescue@80 296 end
Zerotorescue@80 297
Zerotorescue@80 298 function MoveGuildItem(move)
Zerotorescue@80 299 local tabId = GetCurrentGuildBankTab();
Zerotorescue@80 300 local slotId = (MAX_GUILDBANK_SLOTS_PER_TAB or 98); -- start by scanning the last slot
Zerotorescue@80 301
Zerotorescue@80 302 if tabId == nil or tabId < 1 then return; end
Zerotorescue@80 303
Zerotorescue@80 304 while slotId ~= 0 do
Zerotorescue@80 305 -- A not equal-comparison should be quicker than a larger than-comparison
Zerotorescue@80 306
Zerotorescue@80 307 local itemLink = GetGuildBankItemLink(tabId, slotId);
Zerotorescue@80 308 if itemLink then
Zerotorescue@80 309 -- If there is actually an item in this slot
Zerotorescue@80 310
Zerotorescue@80 311 local itemId = GetItemId(itemLink);
Zerotorescue@80 312
Zerotorescue@80 313 if itemId and move.id == itemId then
Zerotorescue@80 314 -- This is one of the items we're looking for
Zerotorescue@80 315
Zerotorescue@80 316 local itemCount = select(2, GetGuildBankItemInfo(tabId, slotId));
Zerotorescue@80 317
Zerotorescue@80 318 if itemCount and itemCount > 0 then
Zerotorescue@80 319 -- if the amount we still have to move is more than this stack, move the entire stack, otherwise move the still needed part of the stack
Zerotorescue@80 320 local moveable = (move.num > itemCount and itemCount) or move.num;
Zerotorescue@80 321
Zerotorescue@80 322 -- Pickup stack
Zerotorescue@80 323 SplitGuildBankItem(tabId, slotId, moveable);
Zerotorescue@80 324
Zerotorescue@80 325 -- Find an target slot and put it there
Zerotorescue@80 326 local reallyMoved = DropItem(itemId, moveable);
Zerotorescue@80 327 if reallyMoved then
Zerotorescue@80 328 -- Keep track of how many we have moved
Zerotorescue@80 329 moved = (moved + reallyMoved);
Zerotorescue@80 330
Zerotorescue@80 331 -- Update the required amount of items so it has the remaining num
Zerotorescue@80 332 move.num = (move.num - reallyMoved);
Zerotorescue@80 333
Zerotorescue@80 334 --if reallyMoved ~= moveable then
Zerotorescue@80 335 -- -- Scan this slot again because if we moved a 18 stack onto a 16 stack, we'd actually have moved only 4 items and still need to move the remaining 14 (we're capping stacks before using empty slots)
Zerotorescue@80 336 -- slotId = (slotId + 1);
Zerotorescue@80 337 --end
Zerotorescue@80 338
Zerotorescue@80 339 --if move.num == 0 then
Zerotorescue@80 340 -- if no required items are left to move, then stop and tell the caller function how many we moved
Zerotorescue@80 341 return moved;
Zerotorescue@80 342 --end
Zerotorescue@80 343 end
Zerotorescue@80 344 end
Zerotorescue@80 345 end
Zerotorescue@80 346 end
Zerotorescue@80 347
Zerotorescue@80 348 -- Continue scanning a different slot
Zerotorescue@80 349 slotId = (slotId - 1);
Zerotorescue@80 350 end
Zerotorescue@80 351 end
Zerotorescue@80 352
Zerotorescue@80 353 function MoveBankItem(move)
Zerotorescue@80 354 local start = 0;
Zerotorescue@80 355 local stop = NUM_BAG_SLOTS;
Zerotorescue@80 356
Zerotorescue@80 357 -- If we requested the bank then we don't want the bag info
Zerotorescue@80 358 start = ( NUM_BAG_SLOTS + 1 );
Zerotorescue@80 359 stop = ( NUM_BAG_SLOTS + NUM_BANKBAGSLOTS );
Zerotorescue@80 360
Zerotorescue@80 361 -- Scan the default 100 slots
Zerotorescue@80 362 move.num = (move.num - MoveFromContainter(BANK_CONTAINER, move));
Zerotorescue@80 363
Zerotorescue@80 364 -- Go through all our bags, including the backpack
Zerotorescue@80 365 for bagID = start, stop do
Zerotorescue@80 366 move.num = (move.num - MoveFromContainter(bagID, move));
Zerotorescue@80 367 end
Zerotorescue@80 368 end
Zerotorescue@80 369
Zerotorescue@80 370 -- Go through all slots of this bag and if a match was found, move the items
Zerotorescue@80 371 function MoveFromContainter(bagID, move)
Zerotorescue@80 372 -- Keep track of how many we have moved
Zerotorescue@80 373 local moved = 0;
Zerotorescue@80 374
Zerotorescue@80 375 -- Go through all slots of this bag
Zerotorescue@80 376 for slot = 1, GetContainerNumSlots(bagID) do
Zerotorescue@80 377 local itemId = GetContainerItemID(bagID, slot);
Zerotorescue@80 378
Zerotorescue@80 379 if itemId and move.id == itemId then
Zerotorescue@80 380 -- This is one of the items we're looking for
Zerotorescue@80 381
Zerotorescue@80 382 local itemCount = select(2, GetContainerItemInfo(bagID, slot));
Zerotorescue@80 383
Zerotorescue@80 384 if itemCount and itemCount > 0 then
Zerotorescue@80 385 -- if the amount we still have to move is more than this stack, move the entire stack, otherwise move the still needed part of the stack
Zerotorescue@80 386 local moveable = (move.num > itemCount and itemCount) or move.num;
Zerotorescue@80 387
Zerotorescue@80 388 -- Pickup stack
Zerotorescue@80 389 SplitContainerItem(bagID, slot, moveable);
Zerotorescue@80 390
Zerotorescue@80 391 addon:Debug("Picked " .. IdToItemLink(itemId) .. " up");
Zerotorescue@80 392
Zerotorescue@80 393 -- Find an target slot and put it there
Zerotorescue@80 394 if CursorHasItem() then
Zerotorescue@80 395 local reallyMoved = DropItem(itemId, moveable);
Zerotorescue@80 396
Zerotorescue@80 397 if reallyMoved then
Zerotorescue@80 398 addon:Debug("Dropped " .. reallyMoved .. " of " .. IdToItemLink(itemId));
Zerotorescue@80 399
Zerotorescue@80 400 -- Keep track of how many we have moved
Zerotorescue@80 401 moved = (moved + reallyMoved);
Zerotorescue@80 402
Zerotorescue@80 403 -- Update the required amount of items so it has the remaining num
Zerotorescue@80 404 move.num = (move.num - reallyMoved);
Zerotorescue@80 405
Zerotorescue@80 406 --if reallyMoved ~= moveable then
Zerotorescue@80 407 -- Scan this slot again because if we moved a 18 stack onto a 16 stack, we'd actually have moved only 4 items and still need to move the remaining 14 (we're capping stacks before using empty slots)
Zerotorescue@80 408 -- slot = (slot - 1);
Zerotorescue@80 409 --end
Zerotorescue@80 410
Zerotorescue@80 411 --if move.num == 0 then
Zerotorescue@80 412 -- if no required items are left to move, then stop and tell the caller function how many we moved
Zerotorescue@80 413 return moved;
Zerotorescue@80 414 --end
Zerotorescue@80 415 end
Zerotorescue@80 416 end
Zerotorescue@80 417 end
Zerotorescue@80 418 end
Zerotorescue@80 419 end
Zerotorescue@80 420
Zerotorescue@80 421 return moved;
Zerotorescue@80 422 end
Zerotorescue@80 423
Zerotorescue@80 424
Zerotorescue@80 425 -- This currently only uses empty slots, it will have to fill stacks in the future
Zerotorescue@80 426 function DropItem(itemId, amount)
Zerotorescue@80 427 local start = 0;
Zerotorescue@80 428 local stop = NUM_BAG_SLOTS;
Zerotorescue@80 429
Zerotorescue@80 430 -- Go through all our bags, including the backpack
Zerotorescue@80 431 for bagID = start, stop do
Zerotorescue@80 432 -- Go through all our slots
Zerotorescue@80 433 for slot = 1, GetContainerNumSlots(bagID) do
Zerotorescue@80 434 local itemId = GetContainerItemID(bagID, slot);
Zerotorescue@80 435
Zerotorescue@80 436 if not itemId then
Zerotorescue@80 437 -- If this slot is empty, put the item here
Zerotorescue@80 438 PickupContainerItem(bagID, slot);
Zerotorescue@80 439
Zerotorescue@80 440 return amount;
Zerotorescue@80 441 end
Zerotorescue@80 442 end
Zerotorescue@80 443 end
Zerotorescue@80 444
Zerotorescue@80 445 return;
Zerotorescue@80 446 end
Zerotorescue@80 447
Zerotorescue@80 448 function IdToItemLink(itemId)
Zerotorescue@80 449 return select(2, GetItemInfo(itemId));
Zerotorescue@80 450 end
Zerotorescue@80 451
Zerotorescue@80 452 function mod:OnEnable()
Zerotorescue@80 453 Scanner = addon:GetModule("Scanner");
Zerotorescue@80 454 end
Zerotorescue@80 455
Zerotorescue@80 456 function mod:OnDisable()
Zerotorescue@80 457 Scanner = nil;
Zerotorescue@80 458 end