View Single Post
05-04-15, 08:20 PM   #7
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,323
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:
  1. local HistoryData={};--     Stores data by index
  2. local HistoryLookup={};--   Links indexed data by timestamp
  3.  
  4. local function OnUpdate(self)-- This will be used to update any shown info
  5.     -- Make whatever calls you need here
  6.  
  7.     self:SetScript("OnUpdate",nil);--   Unregister this handler since we'll no longer need it for now
  8. end
  9.  
  10. local EventFrame=CreateFrame("Frame");
  11. EventFrame:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED");--  This event that isn't affected by filter settings
  12. EventFrame:SetScript("OnEvent",function(self,event,timestamp,subevent,_,sourceguid,sourcename,_,_,destguid,destname,_,_,spellid,_,_,amount,over,absorb,crit,multi)
  13.     if subevent=="SPELL_HEAL" and spellid==1064 and sourceguid==UnitGUID("player") then
  14.         local hops=HistoryLookup[timestamp];--  Pull cast data from lookup table
  15.         if not hops then--  If we didn't get any data, make a new entry
  16.             hops={};--  New hop table
  17.             table.insert(HistoryData,hops);--   Add to data collection
  18.             HistoryLookup[timestamp]=hops;--    Assign a link to the same table to our lookup so we can grab it next time
  19.         end
  20.  
  21.         table.insert(hops,{--   Add hop to hops table
  22.             timestamp=timestamp;
  23.             guid=destguid;
  24.             name=destname;
  25.             amount=amount;
  26.             overheal=over;
  27.             absorbed=absorb;
  28.             critical=crit;
  29.             multistrike=multi;
  30.         });
  31.  
  32.         self:SetScript("OnUpdate",OnUpdate);--  Register our OnUpdate handler to run after all of the events are done firing (unregisters itself when done)
  33.     end
  34. 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 View Post
sirann has a good idea but instead of an OnUpdate you could try a C_Timer.NewTicker.
That would run the callback function multiple times per cast (once for every hop recorded).
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)
  Reply With Quote