PLAYER_LEVEL_UP event - WoWInterface
Thread Tools Display Modes
10-11-20, 03:09 AM   #1
An Aku'mai Servant
Join Date: Apr 2009
Posts: 37


Quick question

If i do something like this

local f = CreateFrame("Frame")
Shouldn't i get different prints? Because for some reason i get the same... Like there is some delay or something in updating new player xp cap... if i put timer in that function with 1-2 seconds i get new value of max xp.

Is that like normal behaviour?
  Reply With Quote
10-11-20, 03:42 AM   #2
nUI Maintainer
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,576
It might have a delay similar to the player level function UnitLevel. But at least with that the PLAYER_LEVEL_CHANGED shows the old and new levels ... but ... you could try that event to see if it triggers after PLAYER_LEVEL_UP and may be enough for the new functions to have access to the new values.
  Reply With Quote
10-11-20, 08:07 AM   #3
An Aku'mai Servant
Join Date: Apr 2009
Posts: 37

I found PLAYER_LEVEL_UP and just didnt think of searching for other event that fires when player levels up... (or levels can go down too?)

In any case thank you.
  Reply With Quote
10-11-20, 10:14 AM   #4
A Cyclonian
DahkCeles's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2020
Posts: 40
Although not applicable here since you found an event that works.... this is an alternative solution you could use when its necessary to defer an update:

Lua Code:
  1. local function doSomething()
  2.     -- do something
  3. end
  5. local f = CreateFrame("Frame")
  6. f:RegisterEvent("SOME_EVENT")
  7. f:HookScript("OnEvent", function()
  8.     C_Timer.After(0, doSomething)  -- wait until the next frame to do something
  9. end)
  Reply With Quote
10-11-20, 10:48 AM   #5
An Aku'mai Servant
Join Date: Apr 2009
Posts: 37
Oh never crossed my mind to try something after 0 seconds...

Ill remember that.

Thank you
  Reply With Quote
10-11-20, 01:52 PM   #6
Fishing Trainer
Seerah's Avatar
WoWInterface Super Mod
Join Date: Oct 2006
Posts: 10,815
Originally Posted by glupikreten View Post
(or levels can go down too?)
They will when Shadowlands launches.
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » PLAYER_LEVEL_UP event

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off