Thread Tools Display Modes
Prev Previous Post   Next Post Next
12-15-16, 12:53 AM   #1
gmarco
An Onyxian Warder
 
gmarco's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 362
HasArtifactEquipped() not trigger on PLAYER_ENTERING_WORLD

Hi all,

I have coded to show in a LDB the artifact power instead the max level to accomplish this:
http://www.wowinterface.com/download....html#comments

Lua Code:
  1. local frame = CreateFrame("Frame")
  2. frame:RegisterEvent("PLAYER_ENTERING_WORLD")
  3. frame:RegisterEvent("PLAYER_XP_UPDATE")
  4. frame:RegisterEvent("ARTIFACT_XP_UPDATE")
  5. -- frame:RegisterEvent("PLAYER_EQUIPMENT_CHANGED")
  6.  
  7. frame:SetScript("OnEvent", function(self, event, ...)
  8.  
  9.     if UnitLevel("player") == GetMaxPlayerLevel() then
  10.    
  11.         if HasArtifactEquipped() then
  12.        
  13.             local ArtPower, ArtPointsSpent= select(5,C_ArtifactUI.GetEquippedArtifactInfo());
  14.             dataobj.text = string_format("A:%s %.1f%%", ArtPointsSpent, ArtPower/C_ArtifactUI.GetCostForPointAtRank(ArtPointsSpent)*100)
  15.    
  16.         else
  17.            
  18.             dataobj.text = "L: " .. UnitLevel("player")    
  19.  
  20.         end
  21.    
  22.     else   
  23.    
  24.         dataobj.text = string_format("L:%s %.1f%%", UnitLevel("player"), UnitXP("player")/UnitXPMax("player")*100)
  25.    
  26.     end
  27.    
  28. end)

The problem is that if I don't use the:

Lua Code:
  1. frame:RegisterEvent("PLAYER_EQUIPMENT_CHANGED")

on the first login it doesn't trigger

Lua Code:
  1. HasArtifactEquipped()

and so show only the level 110 info.

If I do /reload everything is fine ...

If I register also PLAYER_EQUIPMENT_CHANGED it works but I like to not add unnecessary events.

So the question is ...
Is possible that on PLAYER_ENTERING_WORLD I don't have yet the information about the equipped items ?
Is there a more specific event than PLAYER_EQUIPMENT_CHANGED that I can register to check this ?

Thanks to you all for the always precious help.
__________________
This is Unix-Land. In quiet nights, you can hear the Windows machines reboot.
  Reply With Quote
 

WoWInterface » Developer Discussions » Lua/XML Help » HasArtifactEquipped() not trigger on PLAYER_ENTERING_WORLD


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