View Single Post
10/28/20, 12:00 PM   #1
nightdreaming
Join Date: Feb 2018
Posts: 8
AddFilterForEvent - unable to UnregisterForEvent

I am having a problem de-registering an event for which I have added a filter. For example:

Code:
EVENT_MANAGER:RegisterForEvent("myEvent1", EVENT_COMBAT_EVENT, myEventHandler) 
EVENT_MANAGER:AddFilterForEvent("myEvent1", EVENT_COMBAT_EVENT, REGISTER_FILTER_TARGET_COMBAT_UNIT_TYPE, COMBAT_UNIT_TYPE_PLAYER)
The above works fine, if I switch my bar to one that has Crystal Fragments on it then I get an event saying ACTION_RESULT_EFFECT_GAINED "Crystal Fragments Passive", which is what I would expect (as the target of it is me). If I switch bar away from that I also get ACTION_RESULT_EFFECT_FADED "Crystal Fragments Passive" as I would expect.

The problem I am having is if I want to change what events I am getting, for example if I want all combat events instead of just those where I am the target (note this is a change without reloadui, so just a different section of my code). My code does this:

Code:
EVENT_MANAGER:UnregisterForEvent("myEvent1", EVENT_COMBAT_EVENT) 
EVENT_MANAGER:RegisterForEvent("myEvent1", EVENT_COMBAT_EVENT, myEventHandler) 
This should remove the old event registration and replace it. But it doesn't. I still get the same events triggered, for example when I switch bar. It seems as if unregistering the event doesn't actually unregister the filter.

Has anyone come across this, or have any thoughts?
  Reply With Quote