Mercurial > wow > inventory
comparison Modules/Mover.lua @ 88:f1c035694545
Now trying to continue moving item 0.5 seconds after the last ITEM_LOCK_CHANGED-event, rather than 1 second after BAG_UPDATE.
Skipping items which are tagged locked by the client while not tagged as locked in our addon.
author | Zerotorescue |
---|---|
date | Fri, 07 Jan 2011 10:34:38 +0100 |
parents | 3bec0ea44607 |
children | a12d22ef3f39 |
comparison
equal
deleted
inserted
replaced
87:f0420f4ffe07 | 88:f1c035694545 |
---|---|
265 self:Abort(); | 265 self:Abort(); |
266 | 266 |
267 return; | 267 return; |
268 end | 268 end |
269 | 269 |
270 self:RegisterEvent("BAG_UPDATE"); | 270 --self:RegisterEvent("BAG_UPDATE"); |
271 self:RegisterEvent("ITEM_LOCK_CHANGED"); | |
271 self:RegisterEvent("UI_ERROR_MESSAGE"); | 272 self:RegisterEvent("UI_ERROR_MESSAGE"); |
272 | 273 |
273 -- combinedMoves now has all moves in it (source -> target) | 274 -- combinedMoves now has all moves in it (source -> target) |
274 -- go through list, move everything inside it | 275 -- go through list, move everything inside it |
275 -- add source and target to lists, if either is already in this list, skip the move | 276 -- add source and target to lists, if either is already in this list, skip the move |
286 local combinedMovesOriginalLength = #combinedMoves; | 287 local combinedMovesOriginalLength = #combinedMoves; |
287 local numCurrentMove = combinedMovesOriginalLength; | 288 local numCurrentMove = combinedMovesOriginalLength; |
288 while numCurrentMove ~= 0 do | 289 while numCurrentMove ~= 0 do |
289 local move = combinedMoves[numCurrentMove]; | 290 local move = combinedMoves[numCurrentMove]; |
290 | 291 |
292 local isSourceLocked = ((sourceLocationsLocked[move.sourceContainer] and sourceLocationsLocked[move.sourceContainer][move.sourceSlot]) or select(3, GetContainerItemInfo(move.sourceContainer, move.sourceSlot))); | |
293 local isTargetLocked = ((targetLocationsLocked[move.targetContainer] or targetLocationsLocked[move.targetContainer][move.targetSlot]) or select(3, GetContainerItemInfo(move.targetContainer, move.targetSlot))); | |
294 | |
291 -- sourceContainer, sourceSlot, targetContainer, targetSlot, itemId, num | 295 -- sourceContainer, sourceSlot, targetContainer, targetSlot, itemId, num |
292 if move and (not sourceLocationsLocked[move.sourceContainer] or not sourceLocationsLocked[move.sourceContainer][move.sourceSlot]) and | 296 if move and isSourceLocked and isTargetLocked then |
293 (not targetLocationsLocked[move.targetContainer] or not targetLocationsLocked[move.targetContainer][move.targetSlot]) then | |
294 | 297 |
295 print(("Moving %dx%s."):format(move.num, IdToItemLink(move.itemId))); | 298 print(("Moving %dx%s."):format(move.num, IdToItemLink(move.itemId))); |
296 | 299 |
297 addon:Debug(("Moving %dx%s from (%d,%d) to (%d,%d)"):format(move.num, IdToItemLink(move.itemId), move.sourceContainer, move.sourceSlot, move.targetContainer, move.targetSlot)); | 300 addon:Debug(("Moving %dx%s from (%d,%d) to (%d,%d)"):format(move.num, IdToItemLink(move.itemId), move.sourceContainer, move.sourceSlot, move.targetContainer, move.targetSlot)); |
298 | 301 |
353 return; | 356 return; |
354 end | 357 end |
355 end | 358 end |
356 | 359 |
357 local tmrProcessNext; | 360 local tmrProcessNext; |
358 function mod:BAG_UPDATE() | 361 function mod:ITEM_LOCK_CHANGED() |
359 self:CancelTimer(tmrProcessNext, true); -- silent | 362 self:CancelTimer(tmrProcessNext, true); -- silent |
360 tmrProcessNext = self:ScheduleTimer("ProcessMove", 1); | 363 tmrProcessNext = self:ScheduleTimer("ProcessMove", 0.5); |
361 end | 364 end |
362 | 365 |
363 function IdToItemLink(itemId) | 366 function IdToItemLink(itemId) |
364 local itemLink = select(2, GetItemInfo(itemId)); | 367 local itemLink = select(2, GetItemInfo(itemId)); |
365 itemLink = itemLink or "Unknown (" .. itemId .. ")"; | 368 itemLink = itemLink or "Unknown (" .. itemId .. ")"; |