Guildbank BattlePet cages
Dairyman opened this issue ยท 7 comments
Snippet which checks if the item is a cage and when yes checks if any pet of this species is learned.
local learned = false
local speciesID = scantip:SetGuildBankItem(tab, button:GetID())
if speciesID and speciesID > 0 then
learned = C_PetJournal.GetNumCollectedInfo(speciesID) > 0
end
Edit: Use GetNumCollectedInfo
instead of GetOwnedBattlePetString
Sorry for taking so long (had ton of stuff IRL going on), but I have combined your suggestion with the way how I handle caged battlepets in the New AH -hook. I hope this works out of the box, but I don't want to close this issue yet just in case. If this doesn't work, I'll just update the addon to be more close to your original suggestion.
Don't hesitate to let me know if you have any other suggestions/bug fixes for this or other aspects of the addon.
Need to use itemID
the texture in the GuildBank is from the Pet itself, e.g:
if itemLink and strmatch(itemLink, "item:82800" then -- Inv_box_petcarrier_01 (BattlePet, itemId 82800)
Then it works.
Changed the addon to use itemId
instead of texture
in GBank, hope it works for real this time!
The itemLink
from the GuildBank is the dummy one ("item:82800::::::::60:102:::::::::"
) which has no information.
That's why the need to call GameTooltip:SetGuildBankItem()
, to get the speciesID
.
How is this different from the current C_PetJournal.GetNumCollectedInfo
method other than using the tooltip:SetGuildBankItem() instead of pulling the itemlink from the button first and using that? As far as I understand, both of these methods should yield the exact same results.
if itemLink:match("|H(.-):") == "battlepet" then -- Check if item is Caged Battlepet (dummy item 82800)
local _, battlepetId = strsplit(":", itemLink)
if C_PetJournal.GetNumCollectedInfo(battlepetId) > 0 then
if db.debug and not knownTable[itemLink] then Print("%d - BattlePet: %s %d", itemId, battlepetId, C_PetJournal.GetNumCollectedInfo(battlepetId)) end
knownTable[itemLink] = true -- Mark as known for later use
return true -- Battlepet is collected
end
return false -- Battlepet is uncollected... or something went wrong
end