Originally Posted by v6o
So I was making something that requires knowing when talent information is available and that's PLAYER_LOGIN on login and basically any time after on /reload's or loading screens.
Now I don't want to save variables if it's not necessary but I'm not finding another way of doing this.
The only way I can think of is saving a variable to say we're logged in and talents are available when first logging in (first PLAYER_ALIVE.. does this fire on login to Ghost/Dead?) and then resetting it when logging out.
|
You could register PLAYER_LOGIN to capture the first login, and then when you handle that event you unregister PLAYER_LOGIN and register PLAYER_ENTERING_WORLD.
This will allow you to capture all login and reloadui scenarios without having to use saved variables. It will have the disadvantage of being called everytime you get the loading screen though (Hearth, portal, entering/leaving instances, etc.)
something like this:
Code:
local myFrame = CreateFrame('Frame')
myFrame:RegisterEvent('PLAYER_LOGIN')
myFrame:PLAYER_LOGIN(event)
-- handle first login
self:UnregisterEvent('PLAYER_LOGIN')
self:RegisterEvent('PLAYER_ENTERING_WORLD')
end
myFrame:PLAYER_ENTERING_WORLD(event)
-- handle reloadui and changing zones
end
myFrame:SetScript('OnEvent', function(self, event, ...)
self[event](self, event, ...)
end)