View Single Post
08-17-12, 12:17 PM   #3
semlar
A Pyroguard Emberseer
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 1,060
The CallCompanion function appears to throw the error "You do not have a pet" for critters, I don't know if this is just a bug or if you won't be able to use that function any more. In fact, it does the same thing if I try to summon it using /cast <Pet Name>.

I'm not sure exactly what you're trying to do, but I've written a function which will, for the moment, summon a pet by name on the beta. These functions seem like they might be subject to change.

Lua Code:
  1. function CallPetByName(petName)
  2.     local _,myPets = C_PetJournal.GetNumPets(false)
  3.     for i=1,myPets do
  4.         local petID, speciesID, isOwned, customName, level, favorite, isRevoked, name, icon, petType, creatureID, sourceText, description, isWildPet, canBattle, tradable, unique = C_PetJournal.GetPetInfoByIndex(i, false)
  5.         if name:lower() == petName:lower() then
  6.             return C_PetJournal.SummonPetByID(petID)
  7.         end
  8.     end
  9.     print('Pet "'..petName..'" not found')
  10. end

I've included what I believe to be an accurate list of the variables returned by GetPetInfoByIndex, even though you're only using 2 of them for this.