Stuck on TIME_PLAYED_MSG delay
Hi peeps,
I have the following in an addon I'm creating: --Register /played event to unique frame frame:RegisterEvent("TIME_PLAYED_MSG") frame:SetScript("OnEvent", function(self, event, ...) if (event == "TIME_PLAYED_MSG") then TotalPlayed, PlayedThisLevel = ... print("TotalPlayed, PlayedThisLevel "..TotalPlayed, PlayedThisLevel) end end) -- Register Level up hook to unique frame lvlup = CreateFrame("Frame", UIParent) lvlup:RegisterEvent("PLAYER_LEVEL_UP") lvlup:SetScript("OnEvent", function(self, event, ...) if(event == "PLAYER_LEVEL_UP") then print("Level up hook started") newlevel = ... print("NewLevel is: "..newlevel) RequestTimePlayed() inum = (#KLTcharstats+1) print("inum and inslvl = "..inum) newindex(inum) if (inum == 1 and KLTcharstats[inum].clevel == 1) then print("Running if, that is inum = 1 and clevel = 1 --- TotalPlayed = "..TotalPlayed) KLTcharstats[inum].TTP = TotalPlayed KLTcharstats[inum].TFL = TotalPlayed end After all this has run there are the correct results in my default chat for time played and level time played, from the event handler BUT i only ever get 1 in the if at the end. Do i have table init that runs before all this so no issues with the creation of the table or variables. I've been banging my head against this for hours, what do I have wrong? Or is the time return just laggy as sin and I can't do what I need to? Thanks for the input!! |
There's always a delay between running RequestTimePlayed() and when TIME_PLAYED_MSG fires because it has to get this info from the server.
|
Would using something like Ace be the only route to add a pause after levelup till i run functions?
|
Quote:
|
Quote:
|
Here's what I would do.
Lua Code:
|
Quote:
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. |
All times are GMT -6. The time now is 08:48 PM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI