Reply
 
Thread Tools Display Modes
Old 09-04-12, 11:04 AM   #1
Foxlit
A Warpwood Thunder Caller
 
Foxlit's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 91
Make PetJournal API easier to work with

(Updated to highlight functionality added in Patch 5.1.0 + Patch 5.2.0)

The PetJournal API as it appears in 5.0.4 is rather closely tailored to the Blizzard_PetJournal addon, and is not particularly nice to work with in other addons. Here are a couple of suggestions:


Add table = C_PetJournal.GetAllPetIDs([table])
Currently, the only way to figure out which pets are known to the player is to iterate using C_PetJournal.GetPetInfoByIndex, which is affected by four separate PetJournal filter types. One of these filter types takes enumerated flags -- if you decided to add a new one tomorrow, addons would require code updates to get the unfiltered information they need. Saving and restoring these four filters is painful, but necessary to keep the Blizzard_PetJournal in a sane state after an addon is done with GetPetInfoByIndex.

Add petID = C_PetJournal.GetPetIDBySpeciesID(speciesID)
This could be used to determine whether a player owns any pet of a particular species -- for instance, if an addon wants to display a button to summon a particular unique pet (e.g. Grunty).

Patch 5.1.0: Added C_PetJournal.GetNumCollectedInfo.

Expose pet cooldowns
Some pets, like the Guild Herald, are still subject to a cooldown. PetJournal does not expose this information, and GetSpellCooldown (with a correct spell ID that cannot currently be retrieved through the PetJournal API) can only be used if the player character already knew the pet before 5.0.4.

Patch 5.2.0: Added C_PetJournal.GetPetCooldownByGUID.


Fix /cast Battle Pet Name, or add /summonpet Battle Pet Name
Pre-5.0.4, companions could be summoned using /cast and /castsequence commands, which could be used in a macro by ordinary players. Currently, the /cast commands fail with a non-intuitive error ("You do not have a pet") if you knew the pet 5.0.4 or fail silently if you didn't, and the only way to summon a pet is using C_PetJournal.SummonPetByID(petID), which is non-trivial to use in a macro, as the petID is player-specific.

Patch 5.1.0: Added /summonpet Pet Name, /randompet, and /randomfavoritepet slash commands, backed by C_PetJournal.FindPetIDByName and C_PetJournal.SummonRandomPet API functions.


The API as a whole would be easier to work with if the filtering required by Blizzard_PetJournal was done in that addon's Lua code, rather than using C-side state that's shared between all addons, but it's probably too late to change that now.



Addon authors: End wrote LibPetJournal-2.0, a library that simplifies retrieving petIDs of known pets from the PetJournal, and provides a callback that fires when the available pets change, which may be useful if you're dealing with the PetJournal API in its present state.
__________________
... and you do get used to it, after a while.

Last edited by Foxlit : 01-03-13 at 03:53 AM.
Foxlit is offline   Reply With Quote
Old 09-04-12, 11:10 AM   #2
endx7
An Aku'mai Servant
 
endx7's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2005
Posts: 35
<3

Alternatively I think adding a flag to GetNumPets/GetPetInfoByIndex that caused those functions to completely ignore the currently set filters would help a bunch too.

Last edited by endx7 : 09-04-12 at 01:05 PM.
endx7 is offline   Reply With Quote
Reply

Go BackWoWInterface » Developer Discussions » Wish List » Make PetJournal API easier to work with

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