From what I see of your code, it's much more complicated than it needs to be for what you describe. Essentially, too much class-style programming is going to end up bogging down the addon with tons of indexing operations. The example I'm going to show is written from scratch.
Lua Code:
local HistoryData={};-- Stores data by index
local HistoryLookup={};-- Links indexed data by timestamp
local function OnUpdate(self)-- This will be used to update any shown info
-- Make whatever calls you need here
self:SetScript("OnUpdate",nil);-- Unregister this handler since we'll no longer need it for now
end
local EventFrame=CreateFrame("Frame");
EventFrame:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED");-- This event that isn't affected by filter settings
EventFrame:SetScript("OnEvent",function(self,event,timestamp,subevent,_,sourceguid,sourcename,_,_,destguid,destname,_,_,spellid,_,_,amount,over,absorb,crit,multi)
if subevent=="SPELL_HEAL" and spellid==1064 and sourceguid==UnitGUID("player") then
local hops=HistoryLookup[timestamp];-- Pull cast data from lookup table
if not hops then-- If we didn't get any data, make a new entry
hops={};-- New hop table
table.insert(HistoryData,hops);-- Add to data collection
HistoryLookup[timestamp]=hops;-- Assign a link to the same table to our lookup so we can grab it next time
end
table.insert(hops,{-- Add hop to hops table
timestamp=timestamp;
guid=destguid;
name=destname;
amount=amount;
overheal=over;
absorbed=absorb;
critical=crit;
multistrike=multi;
});
self:SetScript("OnUpdate",OnUpdate);-- Register our OnUpdate handler to run after all of the events are done firing (unregisters itself when done)
end
end);
This will end up populating the
HistoryData table with instances of every single cast of Chain Heal. Every entry will contain a list of every hop the spell did between targets, including who those targets were, how much they were healed, crits, and multistrikes. I also added a little code to reliably run after the events all fire.
Originally Posted by jeruku
|
That would run the callback function multiple times per cast (once for every hop recorded).