GetActioninfo() refers to the action buttons, which are the buttons on the bars where spells and so forth go. The return value is to tell you what the button would do. In that case, type would be "action" to invoke such a button, but I'm pretty certain this isn't what you want. There are only so many action buttons.
I don't think you'll be satisfied with the answers you'll find. Your options are probably "macro" (which I know you already knew about), or maybe delegating to yet another button via "click", but that just seems like a silly way to go about it.
This is somewhat contrived and unlikely to happen in the wild, but something like
debugprofilestart()
local id = AceTimer:ScheduleTimer(...)
print(id)
seems to cause duplicate ids about 10% of the time (at least on my setup).
Luckily, while this will cause it to lose track of timers on the short term, it will find them again when they expire and are put into the inactive list.
any chance you could wait for C_PetJournal.IsJournalUnlocked( ) == true before setting the lib as loaded and sending the first callback?
until the journal is unlocked theres some functions that return all nils, which is a pain when youre scanning.
Okay, I think this is finally fixed!
It looks like the problem is just that .GetPetInfoByIndex works before .GetPetInfoByPetID does.
pet renames arent being caught (same owned count so i presume the update gets ignored). you could possibly hook C_PetJournal.SetCustomName for that purpose
Sorry, I didn't see this before. LibPetJournal-2.0 doesn't track anything but pet ids/species ids, so it doesn't really care that much.
There's the PetsUpdated event, but that fires in response to practically every PJLU event (but always after pet ids have been updated), as opposed to PetListUpdated, which is just the list of pet ids changing. This does mean it fires a lot though, so I might at some point make it not respond to filter changes again.
Now that I think about it a bit, C_PetJournal.IsJournalUnlocked() is not an appropriate function to check, since it's primary purpose is actually detection of players with multiple accounts online in the same b.net account.
Until I investigate further, I am going to just check for IsLoggedIn(). This might be sufficient to prevent pulling data early.
Okay, we now check for C_PetJournal.IsJournalUnlocked(), and also IsLoggedIn() too (since C_PetJournal.IsJournalUnlocked() is true very early during login) and don't load pets or fire events before this point.
Also, I fixed an issue where species IDs weren't being properly loaded on an empty cache.
Okay, stencil and I were talking about it on IRC, and he suggested an easy strategy for handling PET_JOURNAL_LIST_UPDATE while not hitting filters. Essentially you check for changes to the owned component of C_PetJournal.GetNumPets(false) because that will decrease or increase as you lose or gain pets, and is not affected by filters.
If you don't feel like using my library, for whatever reason, it works something like this:
local last_owned_count = 0
function event_handler:PET_JOURNAL_LIST_UPDATE()
local _, owned = C_PetJournal.GetNumPets(false)
if last_owned_count ~= owned then
event_handler:UnregisterEvent("PET_JOURNAL_LIST_UPDATE")
-- clear some filters
-- run any code pertaining to new or lost pets
-- restore some filters
event_handler:RegisterEvent("PET_JOURNAL_LIST_UPDATE")
last_owned_count = owned
end
-- code pertaining some other pet changing maybe
end
Yeah, I don't want to throw too much crap in, and the primary focus is in gathering pet/species IDs.
Maybe it'd be worthwhile to write a separate library that unifies the PetJournal (using LibPetJournal-2.0) and Companion APIs? I don't really know how much use it would get.
With 5.0 a new C_PetJournal API was introduced, and unfortunately the old GetCompanionInfo API no longer works properly (it does not, for example, know anything about non-combat pets obtained before the account-wide merge, and you also can no longer summon non-combat pets using it).
During the beta I wrote a library to help deal with this new API, but unfortunately it had issues, so I've since rewritten the library to simplify its scope a little bit. The library itself only retrieves a list of pet ids and species ids, which can be used with C_PetJournal.GetPetInfoByPetID() and C_PetJournal.GetPetInfoBySpeciesID().
It primarily deals with two problems with scanning the pet journal:
Filters: The Pet Journal filters are cleared and then restored, as they affect the return values given from C_PetJournal.GetPetInfoByIndex()
Updating in response to event: Manipulating the Pet Journal filters causes PET_JOURNAL_LIST_UPDATE to fire, which is also the only event that always fires when you lose or gain a pet. Filter manipulation is detected and we never try to rescan pets in response. When this is not the case, a CallbackHandler event is fired which can be used to safely detect changes to the pet list.
A really silly example (you should never actually use petName for checking for a particular pet):
local LibPetJournal = LibStub("LibPetJournal-2.0")
local function ScanPets()
for i,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)
if name == "Feline Familiar" then
print("Player has a cat in a hat.")
end
end
end
ScanPets()
-- watch for when the player gets new pets too
LibPetJournal:RegisterCallback("PetListUpdated", ScanPets)
Okay, tried out the beta version you posted, try to configure bartender, and I get an error about the metamorphosis name being nil in the options. I check how the name is being pulled and
GetSpellInfo(59672) => nil
That seems odd since that's the spell id wowhead has, but I put metamorphosis on my action bar and pull the spellid using GetActionInfo and I get 103958. I guess they changed it.
We haven't gotten around to writing a different Text Provider. It's on my todo list to write a simple one that has the options for common texts but doesn't come with the overhead/configurability of DogTags.
You aren't actually planning on removing support for DogTags though, right? Some of the things I've done with DogTags for PB3 aren't likely to be replicated with a more simple system.
0
it's unique to each addon. Use it for whatever you'd like.
0
GetActioninfo() refers to the action buttons, which are the buttons on the bars where spells and so forth go. The return value is to tell you what the button would do. In that case, type would be "action" to invoke such a button, but I'm pretty certain this isn't what you want. There are only so many action buttons.
For a full list of what type can be, see what the SECURE_ACTIONS table contains: https://www.townlong-yak.com/framexml/ptr/SecureTemplates.lua#286
I don't think you'll be satisfied with the answers you'll find. Your options are probably "macro" (which I know you already knew about), or maybe delegating to yet another button via "click", but that just seems like a silly way to go about it.
0
seems to cause duplicate ids about 10% of the time (at least on my setup).
Luckily, while this will cause it to lose track of timers on the short term, it will find them again when they expire and are put into the inactive list.
0
Okay, I think this is finally fixed!
It looks like the problem is just that .GetPetInfoByIndex works before .GetPetInfoByPetID does.
Sorry, I didn't see this before. LibPetJournal-2.0 doesn't track anything but pet ids/species ids, so it doesn't really care that much.
There's the PetsUpdated event, but that fires in response to practically every PJLU event (but always after pet ids have been updated), as opposed to PetListUpdated, which is just the list of pet ids changing. This does mean it fires a lot though, so I might at some point make it not respond to filter changes again.
0
Until I investigate further, I am going to just check for IsLoggedIn(). This might be sufficient to prevent pulling data early.
0
Also, I fixed an issue where species IDs weren't being properly loaded on an empty cache.
0
0
Also there was strange issue where I was getting PJLU despite having unregistered it.
0
If you don't feel like using my library, for whatever reason, it works something like this:
0
Maybe it'd be worthwhile to write a separate library that unifies the PetJournal (using LibPetJournal-2.0) and Companion APIs? I don't really know how much use it would get.
0
During the beta I wrote a library to help deal with this new API, but unfortunately it had issues, so I've since rewritten the library to simplify its scope a little bit. The library itself only retrieves a list of pet ids and species ids, which can be used with C_PetJournal.GetPetInfoByPetID() and C_PetJournal.GetPetInfoBySpeciesID().
It primarily deals with two problems with scanning the pet journal:
A really silly example (you should never actually use petName for checking for a particular pet):
Getting Started
API Documentation
Project Page
So here I am, actually trying to get people to look at it. Any feedback would be appreciated.
0
0
GetSpellInfo(59672) => nil
That seems odd since that's the spell id wowhead has, but I put metamorphosis on my action bar and pull the spellid using GetActionInfo and I get 103958. I guess they changed it.
GetSpellInfo( 103958 ) => "Metamorphosis", "", "Interface\etc etc
Changed the code to use the "correct" spell id for metamorphosis, and now I can get into the bartender options.
0
You aren't actually planning on removing support for DogTags though, right? Some of the things I've done with DogTags for PB3 aren't likely to be replicated with a more simple system.