View Single Post
04/30/23, 11:09 AM   #1
Lykeion
 
Lykeion's Avatar
AddOn Author - Click to view addons
Join Date: May 2022
Posts: 21
Does LootItemById() throws an EVENT_INVENTORY_SINGLE_SLOT_UPDATE?

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
  Reply With Quote