View Single Post
10/21/21, 05:25 AM   #1
Askedal
Join Date: Aug 2017
Posts: 9
Performance Problem with EVENT_LOOT_UPDATED

Hello,

I'm currently working on an update to the SmarterAutoLoot Addon. The Addon currently works like this:

During initialization it is registering for EVENT_LOOT_UPDATED:

Lua Code:
  1. self.control:RegisterForEvent(EVENT_LOOT_UPDATED, function( _, ... ) self:OnLootUpdated( ... )  end)

In the OnLootUpdated function it checks with several rules and options if the item in the loot window should be looted or not.
This all works quite nicely so far, when all the items should be looted. Then this function OnLootUpdated is called only once. But if there are items in the list that should not be looted (e.g. trash or some configured not wanted items) the function is called multiple times, as many times as items were in the initial list. So if the initial list contained e.g. 5 items, with 2 unwanted ones, the function will be called 5 times.
I think that the removal of the wanted ones triggers a call of the event EVENT_LOOT_UPDATED again and the function is called again. When all items were looted in the first place the nect call of the function bails out as the loot list is empty.

I tried to unregister from the event at the beginning of the function and register at the end again, but with no luck.

Lua Code:
  1. self.control:UnregisterForEvent( EVENT_LOOT_UPDATED )
  2. ...
  3. self.control:RegisterForEvent(EVENT_LOOT_UPDATED, function( _, ... ) self:OnLootUpdated( ... )  end)
Is there a way to stop the event from firing, while I process the loot list ?

Many thanks for any suggestion

Askedal
  Reply With Quote