Thread Tools Display Modes
09-04-12, 02:39 PM   #1
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
PLAYER_LOGIN event does not fire on first character login in module

I got an wierd issue.

On first login of a character the Visibility function does not get called. But on every /reload it will.

I have a module. The Enable looks like

lua Code:
  1. local Enable = function(self, unit)
  2.   local element = self.DemonicFury
  3.   if(element and unit == 'player') then
  4.     element.__owner = self
  5.     element.ForceUpdate = ForceUpdate
  6.  
  7.     self:RegisterEvent('UNIT_POWER', Path, true)
  8.     self:RegisterEvent('UNIT_DISPLAYPOWER', Path, true)
  9.     self:RegisterEvent('PLAYER_TALENT_UPDATE', Visibility, true)
  10.     self:RegisterEvent("SPELLS_CHANGED", Visibility, true)
  11.     self:RegisterEvent("UPDATE_OVERRIDE_ACTIONBAR", Visibility, true)
  12.  
  13.     local helper = CreateFrame("Frame") --this is needed...adding player_login to the visivility events doesn't do anything
  14.     helper:RegisterEvent("PLAYER_LOGIN")
  15.     helper:SetScript("OnEvent", function() Visibility(self) end)
  16.  
  17.     return true
  18.   end
  19. end

If I add
Code:
    self:RegisterEvent("PLAYER_LOGIN", Visibility, true)
and remove the helper on the first login of a character on the MoP beta servers the Visibility function is not being called at all.

But on every /reload it does work as expected.

Thus I added the helper and with that it works like intended.

What could cause this?
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)
  Reply With Quote
09-04-12, 03:43 PM   #2
Torhal
A Pyroguard Emberseer
 
Torhal's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 1,196
I'm betting your Enable is called after the point where PLAYER_LOGIN fires. Try registering it in the main chunk.
__________________
Whenever someone says "pls" because it's shorter than "please", I say "no" because it's shorter than "yes".

Author of NPCScan and many other AddOns.
  Reply With Quote
09-04-12, 03:52 PM   #3
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
PLAYER_LOGIN has already fired by the time elements are getting Enabled on a fresh login. Anything you need to do when an element is enabled, you should just do it directly inside the Enable function.

You can also check IsLoggedIn() if you need to make sure.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
09-04-12, 04:02 PM   #4
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
Thank you.
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)
  Reply With Quote

WoWInterface » Featured Projects » oUF (Otravi Unit Frames) » PLAYER_LOGIN event does not fire on first character login in module


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