WoWInterface - View Single Post - Stuck on TIME_PLAYED_MSG delay
View Single Post
10-14-20, 11:35 PM   #6
A Pyroguard Emberseer
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,034
Here's what I would do.
Lua Code:
  1. local LevelTimes={};--  For this example, we'll say this is loaded from SavedVar
  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);
ESOUI AddOns | 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