LibCombatLogEvent-1.0

This project is inactive and its default file will likely not work with the most recent version of World of Warcraft. The author may have abandoned it, or it may have outlived its usefulness.

Warning: This project is experimental. Its files will not synchronize across the CurseForge network.

LibCombatLogEvent-1.0 dispatchs combat log events using CallbackHandler-1.0, passing along a table with the event arguments. It integrates nicely with AceAddon-3.0 addons and use an efficient argument parsing.

AceAddon-3.0 integration

Quite simple, here is a basic sample:

local myAddon = LibStub('AceAddon-3.0'):NewAddon("foo", "LibCombatLogEvent-1.0")

function myAddon:OnEnable()
  self:RegisterCombatLogEvent("UNIT_DIED")
end

function myAddon:UNIT_DIED(event, eventArgs)
  print("Oh noes !", eventArgs.destName, "died !")
end

No need to unregister the event in OnDisable, the library takes care of it.

Callbacks

The library is based on CallbackHandler-1.0. The callback names are the COMBAT_LOG_EVENT_UNFILTERED (CLEU) event names.

:RegisterCombatLogEvent

myAddon:RegisterCombatLogEvent("eventName"[, methodNameOrFunc[, arg]])
library.RegisterCombatLogEvent(myTable, "eventName"[, methodNameOrFunc[, arg]])
library.RegisterCombatLogEvent("myAddonId", "eventName"[, func[, arg]])

Register a callback for the given myAddon/myTable/"myAddonId" and CLEU event.

The callback should have one of the following signatures:

function myAddon:method([arg, ]event, eventArgs)
function myTable:method([arg, ]event, eventArgs)
function func([arg, ]event, eventArgs)

:UnregisterCombatLogEvent

myAddon:UnregisterCombatLogEvent("eventName"[, methodNameOrFunc[, arg]])
library.UnregisterCombatLogEvent(myTable, "eventName"[, methodNameOrFunc[, arg]])
library.UnregisterCombatLogEvent("myAddonId", "eventName"[, func[, arg]])

Unregister the myAddon/myTable/"myAddonId" callback for the given event.

:UnregisterAllCombatLogEvents

myAddon:UnregisterAllCombatLogEvents()
library.UnregisterAllCombatLogEvents(myTable)
library.UnregisterAllCombatLogEvents("myAddonId")

Unregister all myAddon/myTable/"myAddonId" callbacks.

The eventArgs table

The event table is filled with the parameters of the COMBAT_LOG_EVENT_UNFILTERED event. For convenience, these positional parameters are mapped to named ones using this page: http://www.wowpedia.org/API_COMBAT_LOG_EVENT.

Important: the passed eventArgs is a table shared amongst all callbacks and reused on subsequent callbacks. Do not modifiy it or store a reference to it. If you absolutely need to modify it or keep the values, make a copy first.

For example, for the SPELL_MISS event, the table would be it was defined that way:

eventArgs  = {
  event = "SPELL_MISS",
  timestamp = ...,
  sourceGUID = ...,
  sourceName = ...,
  sourceFlags = ...,
  destGUID = ...,
  destName = ...,
  destFlags = ...,
  spellId = ...,
  spellName = ...,
  spellSchool = ...,
  missType = ...,
  amountMissed = ...
}

Comments

Posts Quoted:
Reply
Clear All Quotes

About This Project

  • Project ID
    29346
  • Created
    Mar 15, 2011
  • Last Released File
    Never
  • Total Downloads
    211
  • License

Categories

Members

Recent Files