View Single Post
10-15-20, 11:44 AM   #7
KrS14
A Murloc Raider
Join Date: Oct 2020
Posts: 4
Originally Posted by SDPhantom View Post
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);
While not directly my solution SDPhantom, you completely made me realize I was going about the execution of everything in the wrong order.

I was sticking almost ALL my main work in PLAYER_LEVEL_UP, when it should have been in TIME_PLAYED_MSG that was my natural delay I needed

Thank you so much for your input, I'm about 4 days into learning LUA in any capacity lol so there's definitely some tricks to learn

All is working as intended now.

Last edited by KrS14 : 10-15-20 at 05:05 PM.
  Reply With Quote