Thread Tools Display Modes
03-19-19, 12:27 PM   #1
fakesaint41
A Murloc Raider
Join Date: Mar 2019
Posts: 7
Can Anyone Explain This Mystery?

I'm stumped... I've worked around it but I'd like to know why it happens. Calling C_PetJournal.GetNumPets() in the handler for the PLAYER_LOGIN or PLAYER_ENTERING_WORLD returns 0... but sticking the call at the beginning of the addon works just fine.


Code:
local numPets = C_PetJournal.GetNumPets()
print("File Start: "..numPets)

function AddonFrame:PlayerLoginHandler()
    local numPets = C_PetJournal.GetNumPets()
    print("Login: "..numPets
end

--   Output in Chat Window on Reload:
-- 
--   File Start: 1002
--   Login: 0


Subsequent calls after login are back to normal. I'm confused why it wouldn't work in the PLAYER_LOGIN handler, despite the API being available before.

I'll give 1 or 2 helpful geniuses here any of the new Raiding With Leashes Pets if you can solve this mystery!!
  Reply With Quote
03-19-19, 03:56 PM   #2
ArsenalLagspike
A Murloc Raider
Join Date: Mar 2019
Posts: 8
Need to see more code. I have a couple of assumptions, but without code I can't know for sure.

Is the AddomFrame handler that you defined being called from the XML template? Or somewhere else in Lua?

Last edited by ArsenalLagspike : 03-19-19 at 04:00 PM.
  Reply With Quote
03-19-19, 07:58 PM   #3
kurapica.igas
A Chromatic Dragonspawn
Join Date: Aug 2011
Posts: 152
You'd better try the PET_JOURNAL_LIST_UPDATE event to start using the pet data
  Reply With Quote
03-19-19, 11:16 PM   #4
elcius
A Cliff Giant
AddOn Author - Click to view addons
Join Date: Sep 2011
Posts: 75
most api functions that provide data about the character or account will return data from the previously logged in character if called before PLAYER_LOGIN.
If you close the game you'll probably find it returns 0 both times.
  Reply With Quote
03-20-19, 05:06 PM   #5
fakesaint41
A Murloc Raider
Join Date: Mar 2019
Posts: 7
Originally Posted by elcius View Post
most api functions that provide data about the character or account will return data from the previously logged in character if called before PLAYER_LOGIN.
If you close the game you'll probably find it returns 0 both times.
Mystery Solved!! That's exactly what was fooling me. If you like, PM me name/server and what pet you want!
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Can Anyone Explain This Mystery?

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