Thread Tools Display Modes
07/27/19, 06:54 AM   #1
cOOLsp0T
 
cOOLsp0T's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2019
Posts: 17
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
  Reply With Quote
07/27/19, 08:13 AM   #2
votan
 
votan's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2014
Posts: 577
Originally Posted by cOOLsp0T View Post
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
  Reply With Quote
07/27/19, 08:49 AM   #3
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,912
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.
  Reply With Quote
07/27/19, 10:19 AM   #4
cOOLsp0T
 
cOOLsp0T's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2019
Posts: 17
Thx guys. I have found my fail. Beartram was right. The position from the unregister function was wrong.

Last edited by cOOLsp0T : 07/27/19 at 10:20 AM. Reason: gramar etc
  Reply With Quote

ESOUI » AddOns » AddOn Help/Support » how does EVENT_INVENTORY_SINGLE_SLOT_UPDATE exactly work?

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