AddFilterForEvent

From ESOUI Wiki

Jump to: navigation, search

In Update 7 (Imperial City) combat related events were changed in order to give addons more information about what is going on in the world. This would result in a flood of information that would degrade the performance of many addons by sending events for things they are not even interested in. In order to prevent this, a new method AddFilterForEvent was added to the EVENT_MANAGER, which allows authors to reduce the amount of received data via predefined filters that run in the c-code part of the client. For the announcement of those changes see this thread.

EVENT_MANAGER:AddFilterForEvent(string eventNamespace, number eventId[, RegisterForEventFilterType filterType, varying parameter]+)

Multiple filters can be added in one call by repeatedly supplying a filter type followed by a parameter or in multiple calls by calling AddFilterForEvent for the same event. Filters cannot be removed once they were added without unregistering the event.

Filter Types

There are currently 15 filter types which all receive different arguments and can be used for different event types.

type events parameter description
REGISTER_FILTER_ABILITY_ID EVENT_ABILITY_COOLDOWN_UPDATED, EVENT_COMBAT_EVENT, EVENT_EFFECT_CHANGED number abilityId Filters for specific abilities
REGISTER_FILTER_BAG_ID EVENT_INVENTORY_SINGLE_SLOT_UPDATE, any other event with a bagId? Bag bagId Filters for specific inventory bag
REGISTER_FILTER_COMBAT_RESULT EVENT_COMBAT_EVENT, others? ActionResult actionResult Filters for combat action results
REGISTER_FILTER_INVALID Not used in the ui code. Seems to be a placeholder
REGISTER_FILTER_INVENTORY_UPDATE_REASON EVENT_INVENTORY_SINGLE_SLOT_UPDATE InventoryUpdateReason inventoryUpdateReason Filters for specific inventory update reason
REGISTER_FILTER_IS_ERROR EVENT_COMBAT_EVENT boolean isError Filters combat events for errors
REGISTER_FILTER_IS_IN_GAMEPAD_PREFERRED_MODE Any boolean showInGamepadPreferredMode Only handle event while gamepad mode is active
REGISTER_FILTER_IS_NEW_ITEM EVENT_INVENTORY_SINGLE_SLOT_UPDATE boolean isNewItem Filters for new items
REGISTER_FILTER_POWER_TYPE EVENT_COMBAT_EVENT, EVENT_POWER_UPDATE CombatMechanicType powerType Filter for a specific power type
REGISTER_FILTER_SETTING_SYSTEM_TYPE EVENT_INTERFACE_SETTING_CHANGED SettingSystemType settingType Filter for a specific power type
REGISTER_FILTER_SOURCE_COMBAT_UNIT_TYPE EVENT_COMBAT_EVENT CombatUnitType unitType Filter for the source unit type
REGISTER_FILTER_TARGET_COMBAT_UNIT_TYPE EVENT_COMBAT_EVENT CombatUnitType unitType Filter for the target unit type
REGISTER_FILTER_UNIT_TAG Any event with a unitTag argument string unitTag Filter for the exact unitTag
REGISTER_FILTER_UNIT_TAG_PREFIX Any event with a unitTag argument string unitTagPrefix Filter for a unitTag that has multiple instances (e.g. group, boss)
REGISTER_FILTER_VIBRATION_FILTER EVENT_COMBAT_EVENT number vibrationStrength(?) Filter for combat events that would cause a vibration on a gamepad (?)

Example

Filtering for combat events that are not errors:

local namespace = "MyAddonEventNamespace"
EVENT_MANAGER:RegisterForEvent(namespace, EVENT_COMBAT_EVENT, function(eventCode, result, isError, abilityName, abilityGraphic, abilityActionSlotType, sourceName, sourceType, targetName, targetType, hitValue, powerType, damageType, log)
  -- do something here
end)
EVENT_MANAGER:AddFilterForEvent(namespace, EVENT_COMBAT_EVENT, REGISTER_FILTER_IS_ERROR, false)
Personal tools
Namespaces
Variants
Actions
Menu
Wiki
Toolbox