Thread Tools Display Modes
11-29-14, 02:56 PM   #1
saxitoxin
A Theradrim Guardian
 
saxitoxin's Avatar
AddOn Author - Click to view addons
Join Date: May 2009
Posts: 60
active battlepet

is there a way to get info about my active battlepet?

thanks

Edit: figured it out
Code:
local summonedPet = 0
for i=1,GetNumCompanions("CRITTER") do
	local creatureID, creatureName, creatureSpellID, icon, issummoned = GetCompanionInfo("CRITTER", i)
	print(creatureID, creatureName, issummoned)
	if (issummoned) then
		summonedPet = creatureName
	end
end	
print("creature name: "..summonedPet)
Edit2: It seems like GetCompanionInfo("CRITTER", i) only count the pets the character has "learned" not all in the pet journal, any way around this?

Last edited by saxitoxin : 11-29-14 at 07:47 PM.
  Reply With Quote
11-29-14, 10:43 PM   #2
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Those companion API functions are deprecated and should no longer be used. Use the actual pet journal API instead.

Code:
local summonedPetGUID = C_PetJournal.GetSummonedPetGUID()
local speciesID, customName, level, xp, maxXp, displayID, isFavorite, name, icon,
    petType, creatureID, sourceText, description, isWild, canBattle, tradable, unique,
    obtainable = C_PetJournal.GetPetInfoByPetID(summonedPetGUID)
print("Summoned pet:", name, customName)
More info:
http://wowpedia.org/World_of_Warcraf...rnal_Functions
__________________
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
11-29-14, 11:17 PM   #3
saxitoxin
A Theradrim Guardian
 
saxitoxin's Avatar
AddOn Author - Click to view addons
Join Date: May 2009
Posts: 60
Originally Posted by Phanx View Post
Those companion API functions are deprecated and should no longer be used. Use the actual pet journal API instead.

Code:
local summonedPetGUID = C_PetJournal.GetSummonedPetGUID()
local speciesID, customName, level, xp, maxXp, displayID, isFavorite, name, icon,
    petType, creatureID, sourceText, description, isWild, canBattle, tradable, unique,
    obtainable = C_PetJournal.GetPetInfoByPetID(summonedPetGUID)
print("Summoned pet:", name, customName)
More info:
http://wowpedia.org/World_of_Warcraf...rnal_Functions
Thank you once again Phanx
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » active battlepet

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