My favorites | Sign in
Project Logo
                
Search
for
Updated May 08, 2008 by ga.shredder
Labels: Featured
RCE  
Using RCE

Introduction

RegisterCombatEvent

Details

The point of this library is to instead of having one large COMBAT_LOG_EVENT_UNFILTERED function with if-else checks for the event type, you can "register" the event types and set a function for each one.

Where as before you might have:

local MyFrame = CreateFrame("Frame")
frame:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
frame:SetScript("OnEvent", CLEU)
function CLEU(...)
    if arg2 == "SPELL_AURA_APPLIED" then
        do stuff
    elseif arg2 == "SPELL_AURA_REMOVED" then
        do other stuff
    end
end

Now you can do:

local MyFrame = CreateFrame("Frame")
local rce = LibStub:GetLibrary("RCE")

rce:Embed(MyFrame)

function Applied(self, ...)
    do stuff
end

function Removed(self, ...)
    do other stuff
end

MyFrame:RegisterCombatEvent("SPELL_AURA_APPLIED", Applied)
MyFrame:RegisterCombatEvent("SPELL_AURA_REMOVED", Removed)

The self in the above functions will return as the frame registered with the combat event, in this case MyFrame.

There is also no need to register COMBAT_LOG_EVENT_UNFILTERED to your frame, as RegisterCombatEvent will do it for you.

It is important to note that the first 2 arguments normally returned by COMBAT_LOG_EVENT_UNFILTERED (timestamp and eventType) are NOT returned using RCE. In the above functions, ... will start at the 3rd argument (source name) and carry on from there.

API

RCE:Embed(frame)

:RegisterCombatEvent("event", function)

:RegisterCombatEvents("event1", "event2", "event3", function)

:IsCombatEventRegistered("event")

  • Returns true if "event" is registered to your frame, false otherwise


Sign in to add a comment
Hosted by Google Code