Thread Tools Display Modes
08/28/21, 08:25 AM   #1
ownedbynico
AddOn Author - Click to view addons
Join Date: Nov 2019
Posts: 9
Moving items and unequipping gear not reliable

Hey,
so I implemented a banking feature in my addon. But it's not really reliable since sometimes there are 1 or 2 items that appear to be stuck.
I added a 200ms delay between Item move requests. Is that too little or is my basic thought wrong?

This is my function to move items which Im calling in a loop.
Code:
function MoveItem(sourceBag, sourceSlot, destBag)
	if not DoesBagHaveSpaceFor(destBag, sourceBag, sourceSlot) then
		return false
	end
	local destSlot = FindFirstEmptySlotInBag(destBag)
	if not destSlot then
		return false
	end
	CallSecureProtected("RequestMoveItem", sourceBag, sourceSlot, destBag, destSlot, 1)
	return true
end

Thanks for any help in advance
  Reply With Quote
08/28/21, 11:30 AM   #2
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,962
Bank deposit/withdraw does not always take the same amount of time and just adding a delay wont help here as depening on where you are, what istance you are in, how many players are there, how buys the server is, the banking might take >200ms or less. And as it fails all following ones will fail as well!

Use a callback to EVENT_INVENTORY_SINGLE_SLOT_UPDATE to check if an item moved (it will fire with the bagId once the item will be removed from your BAG_BAGPACK e.g. and again with the bag=banking bag as it was deposited. And the slotIndex should be the same (hopefully!) as banked items do not stack automatically (afaik).
Be sure to use event filters on EVENT_INVENTORY_SINGLE_SLOT_UPDATE to speed up the event usage, and maybe ONLY register the event after EVENT_BANK_OPEN fired so that it does not fire for any other items you loot or get to your inventory, but wuld fire for nothing then.
And unregister after event_bank_closed (or similar) has fired.
  Reply With Quote

ESOUI » Developer Discussions » General Authoring Discussion » Moving items and unequipping gear not reliable

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off