LibPetJournal-2.0

Addons
51,239 Downloads Last Updated: Aug 5, 2018 Game Version: 8.0.1

API

Types


petID

petID is the identifier for a player's owned pet in the pet journal. This id persists and is appropriate for long term identification. It can be used with many functions such as C_PetJournal.GetPetInfoByPetID(), C_PetJournal.SummonPetByID(), C_PetJournal.PetIsSummonable() and many others.


speciesID

speciesID is the identifier for a particular pet species in the pet journal. The species of a pet determines the default name, the graphics model, the attacks, and type of a pet. Players are usually limited to three pets of a particular species. speciesID can be used with the C_PetJournal.GetPetInfoBySpeciesID() function.


creatureID

creatureID is how a pet may be identified as an NPC. In particular, the creatureID of an NPC can be determined from the UnitGUID function.


Main Library Methods


LibPetJournal:IteratePetIDs()

Get an iterator over the list of pet IDs of the pets the player owns in the format of:

idx
An index over the list, not for use with the C_PetJournal functions.
petID
The petID to be used with C_PetJournal.GetPetInfoByPetID

The specific order of pet ids returned should not be relied upon.

If you want to scan the pet list immediately after it has been updated, register the "PetListUpdated" callback.

Example

for _,petID in LibPetJournal:IteratePetIDs() do 
    local speciesID, customName, level, xp, maxXp, displayID, isFav, name, icon,
        petType, creatureID, sourceText, description, isWild, canBattle,
        tradable, unique = C_PetJournal.GetPetInfoByPetID(petID)
     -- do something with the pet information here
end


LibPetJournal:IterateSpeciesIDs()

Get an iterator over the list of all exposed species IDs in the format of:

idx
An index over the list, not for use with the C_PetJournal functions.
speciesID
The petID to be used with C_PetJournal.GetPetInfoBySpeciesID

Example

for _,speciesID in LibPetJournal:IterateSpeciesIDs() do 
    local name, icon, petType, creatureID, sourceText, description, isWild,
        canBattle, tradable, unique = C_PetJournal.GetPetInfoBySpeciesID(speciesID)
     -- do something with the pet information for a species here
end


LibPetJournal:IterateCreatureIDs()

Get an iterator over the list of creature IDs in the format of:

idx
An index over the list, not for use with the C_PetJournal functions.
creatureID
The creature ID, such as can be retrieved from functions such as UnitGUID


LibPetJournal:GetSpeciesIDForCreatureID(creatureID)

Convert a creature ID into a species ID, which can be used with C_PetJournal.GetPetInfoBySpeciesID()

Arguments

creatureID
The creature ID to convert.

Return

speciesID
The corresponding species ID


Callbacks


"PetListUpdated"

Fires in response to the list of pet ids being updated.

Example

LibPetJournal.RegisterCallback(addon, "PetListUpdated", function()
    for _,petID in LibPetJournal:IteratePetIDs() do 
        local speciesID, customName, level, xp, maxXp, displayID, name, icon,
            petType, creatureID, sourceText, description, isWild, canBattle,
            tradable, unique = C_PetJournal.GetPetInfoByPetID(petID)
         -- do something with the pet information here
    end
end)


"PetsUpdated"

Fires in response to PET_JOURNAL_LIST_UPDATED, after the list of pets has updated.


Other Library Methods


LibPetJournal:LoadPets()

Load pets stored in the PetJournal.

You do not need to call this method manually. Under normal circumstances this will be run in response to updates to the Pet Journal.


LibPetJournal:IsLoaded()

Determine if the pet list has been loaded.

Return

loaded
boolean - indicating whether the pet list has been loaded.


LibPetJournal:NumPets()

Determine how many pets the player owns.

Return

numPets
integer - number of pets the player owns


LibPetJournal:NumSpecies()

Determine how many total species there are.

Return

numSpecies
integer - number of species in the PetJournal

Comments

Posts Quoted: