I tried to add an autobind feature to my autoloot addon, but I can't seem to get the information about the looted gear via EVENT_INVENTORY_SINGLE_SLOT_UPDATE when LootItemById. This is a bit strange, is there something I'm doing wrong?
A simplified version of my code looks like this. I have tried leaving the print statement inside _onInventorySlotUpdate, but it doesn't look like this function is being called
Code:
function MyAddon:LootSetItem(link, lootId, isUnresearched, isOrnate, isIntricate, isSetItem, isUncollected)
local function _onInventorySlotUpdate(eventCode, bagId, slotIndex, isNewItem, itemSoundCategory, updateReason, stackCountChange)
d('_onInventorySlotUpdate is called')
if (db.autoBind) then
BindItem(bagId, slotIndex)
end
end
EVENT_MANAGER:RegisterForEvent("SLOT_UPDATE", EVENT_INVENTORY_SINGLE_SLOT_UPDATE, _onInventorySlotUpdate)
LootItemById(lootId)
EVENT_MANAGER:UnregisterForEvent("SLOT_UPDATE", EVENT_INVENTORY_SINGLE_SLOT_UPDATE)
end