ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   AddOn Help/Support (https://www.esoui.com/forums/forumdisplay.php?f=164)
-   -   how does EVENT_INVENTORY_SINGLE_SLOT_UPDATE exactly work? (https://www.esoui.com/forums/showthread.php?t=8668)

cOOLsp0T 07/27/19 06:54 AM

how does EVENT_INVENTORY_SINGLE_SLOT_UPDATE exactly work?
 
Hi Folks, its me again. :)

I have a problem with an Event Handler wrapped around my function. The function itself loots all items, checks if the user whished to loot that item and destroys all left overs. My problem is, that the Event wouldnt fire. I register it right before the loot actions starts and unregister it when the looting action ends.

Code:

function LootManager.Lootinit()
        if Config.GeneralSettings.ClearNodes == true then
                EVENT_MANAGER:RegisterForEvent(LootManager.Name, EVENT_INVENTORY_SINGLE_SLOT_UPDATE, function(...) LootManager.GarbageHandler(...) end)
                LootManager.Debugger(1)
        end
        LootMoney()
        local num = GetNumLootItems()
        for itemnumber = 1, num, 1 do       
                lootitem = LootManager.ItemFilter(itemnumber,nil,nil)
                LootManager.Debugger(0,num,itemnumber,lootitem)
                _,_,_,_,_,_,LootManager.isQuest,_ = GetLootItemInfo(itemnumber)
                if Config.GeneralSettings.Debug ~= true then
                        if Config.GeneralSettings.ClearNodes == true then LootItemById(itemID) end
                        if Config.GeneralSettings.ClearNodes == false and lootitem == true then LootItemById(itemID) end
                end
        end

        if Config.GeneralSettings.BlindLoot == true then EndLooting() end
        if Config.GeneralSettings.ClearNodes == true then
                EVENT_MANAGER:UnregisterForEvent(LootManager.Name, EVENT_INVENTORY_SINGLE_SLOT_UPDATE)
                LootManager.Debugger(2)
        end
end


votan 07/27/19 08:13 AM

Quote:

Originally Posted by cOOLsp0T (Post 38735)
Hi Folks, its me again. :)

I have a problem with an Event Handler wrapped around my function. The function itself loots all items, checks if the user whished to loot that item and destroys all left overs. My problem is, that the Event wouldnt fire. I register it right before the loot actions starts and unregister it when the looting action ends.

Code:

function LootManager.Lootinit()
        if Config.GeneralSettings.ClearNodes == true then
                EVENT_MANAGER:RegisterForEvent(LootManager.Name, EVENT_INVENTORY_SINGLE_SLOT_UPDATE, function(...) LootManager.GarbageHandler(...) end)
                LootManager.Debugger(1)
        end
        LootMoney()
        local num = GetNumLootItems()
        for itemnumber = 1, num, 1 do       
                lootitem = LootManager.ItemFilter(itemnumber,nil,nil)
                LootManager.Debugger(0,num,itemnumber,lootitem)
                _,_,_,_,_,_,LootManager.isQuest,_ = GetLootItemInfo(itemnumber)
                if Config.GeneralSettings.Debug ~= true then
                        if Config.GeneralSettings.ClearNodes == true then LootItemById(itemID) end
                        if Config.GeneralSettings.ClearNodes == false and lootitem == true then LootItemById(itemID) end
                end
        end

        if Config.GeneralSettings.BlindLoot == true then EndLooting() end
        if Config.GeneralSettings.ClearNodes == true then
                EVENT_MANAGER:UnregisterForEvent(LootManager.Name, EVENT_INVENTORY_SINGLE_SLOT_UPDATE)
                LootManager.Debugger(2)
        end
end


It is worth taking a look to built-in SHARED_INVENTORY and it's callbacks.
https://www.esoui.com/downloads/info...ourcecode.html

Baertram 07/27/19 08:49 AM

For me it seems you are registering the event callback function for that event as the Loot starts in function LootInit.
But you also unregister it there again in the following lines if a setting in your addon is set to true.
So maybe check if the register and unregister are both done within half a second and move the unregister somewhere else then after the loot has finished.

cOOLsp0T 07/27/19 10:19 AM

Thx guys. I have found my fail. Beartram was right. The position from the unregister function was wrong.


All times are GMT -6. The time now is 06:14 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI