View Single Post
10-14-20, 11:35 PM   #6
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,313
Here's what I would do.
Lua Code:
  1. local LevelTimes={};--  For this example, we'll say this is loaded from SavedVar
  2.  
  3. local EventFrame=CreateFrame("Frame");
  4. EventFrame:RegisterEvent("PLAYER_LEVEL_UP");
  5. EventFrame:RegisterEvent("TIME_PLAYED_MSG");
  6. EventFrame:SetScript("OnEvent",function(self,event,...)
  7.     if event=="PLAYER_LEVEL_UP" then
  8.         self.WaitingForPlayTime=true;-- Flag continuation
  9.         RequestTimePlayed();
  10.     elseif event=="TIME_PLAYED_MSG" and self.WaitingForPlayTime then
  11.         self.WaitingForPlayTime=false;--    Clear flag
  12.         LevelTimes[UnitLevel("player")-1]=...;--    Record time to complete level
  13.     end
  14. end);
__________________
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