Macro which cages pets from bank/guild bank
Does anyone know of a macro, or is anyone able to create a macro, which would cage any pets from either my bank or guild bank of which I have less than three of in my pet collection.
Being a pet seller with banks and guild banks full of pets, I now have to manually hover over all these pets every time to see if any are cageable. With a macro as described above, I would save LOTS of time. Hope this is possible.
Thanks in advance!
Kris
Being a pet seller with banks and guild banks full of pets, I now have to manually hover over all these pets every time to see if any are cageable. With a macro as described above, I would save LOTS of time. Hope this is possible.
Thanks in advance!
Kris
Re: Macro which cages pets from bank/guild bank
I'm not sure I understand. If they are in a bank, they are already caged, so they must all be cageable. Can you maybe elaborate some more?
Carry Pet Experience Reference Guide:
http://www.warcraftpets.com/community/forum/viewtopic.php?f=10&t=8829
http://www.warcraftpets.com/community/forum/viewtopic.php?f=10&t=8829
Re: Macro which cages pets from bank/guild bank
Yup. Let's say I have 100 pets in my bank, out of which 50 I have 3/3 in my pet collection. Then those 50 are 'not cageable' at the moment, since I can only add 3 of each pet. If the other 50 ones I have I either have 1/3 or 2/3 of in my pet journal, they ARE cageable.
So the macro I'd love to have would automatically, one by one, cage all those pets that I have 1/3 or 2/3 of in my pet journal. The alterenative I am doing now is hover over all 100 pets, which shows me which I can add to my pet journal, and then I add them. But with HUNDREDS of pets in bank and guildbank, spread over 7 realms, this is very time consuming, so a macro (or addon) would save me an incredible amount of time.
Hope that explains it
Kris
So the macro I'd love to have would automatically, one by one, cage all those pets that I have 1/3 or 2/3 of in my pet journal. The alterenative I am doing now is hover over all 100 pets, which shows me which I can add to my pet journal, and then I add them. But with HUNDREDS of pets in bank and guildbank, spread over 7 realms, this is very time consuming, so a macro (or addon) would save me an incredible amount of time.
Hope that explains it
Kris
Re: Macro which cages pets from bank/guild bank
I think I understand, but I think you are using "cageable" when you mean "learnable"? Cageable means that you can cage something, but adding pets to your collection is actually uncaging/learning, not caging.
Now if I understand what you are asking, you want an addon that will scan through your already caged pets in your bank and learn the ones that you have room in your pet journal to learn. I believe the WoW API can iterate through all your bank slots, so that isn't an issue. I would guess that WoW's API can also tell you if you have 3/3 or 1/3 since Rematch has the ability to filter on that. I think the outstanding question is how "automated" can the "learning" step be automated. I feel like this might be rough for a macro to do (only somewhere near 256 chars allowed in a macro), but maybe a small addon? Honestly I don't think it matters if you have 1/3 or 2/3 or 3/3 if you can iterate over all of them. Trying to uncage a pet will just fail if you can't learn it, and you move onto the next.
Now if I understand what you are asking, you want an addon that will scan through your already caged pets in your bank and learn the ones that you have room in your pet journal to learn. I believe the WoW API can iterate through all your bank slots, so that isn't an issue. I would guess that WoW's API can also tell you if you have 3/3 or 1/3 since Rematch has the ability to filter on that. I think the outstanding question is how "automated" can the "learning" step be automated. I feel like this might be rough for a macro to do (only somewhere near 256 chars allowed in a macro), but maybe a small addon? Honestly I don't think it matters if you have 1/3 or 2/3 or 3/3 if you can iterate over all of them. Trying to uncage a pet will just fail if you can't learn it, and you move onto the next.
Last edited by Jerebear on November 7th, 2020, 3:36 pm, edited 1 time in total.
Carry Pet Experience Reference Guide:
http://www.warcraftpets.com/community/forum/viewtopic.php?f=10&t=8829
http://www.warcraftpets.com/community/forum/viewtopic.php?f=10&t=8829
Re: Macro which cages pets from bank/guild bank
Yeah the cageable usage made the question really difficult to understand.
Right click a pet in journal and Put In Cage -> leaves pet journal
Right click a pet in bags -> enters pet journal
The answer to which pets in bags or bank are not in the journal is...all the pets in your bags or bank?
That said, the following will put a green paw over all learnable pets in your bags, bank and guild bank; regardless whether they're an item that teaches a pet or a caged pet. Some pets are unique and it will consider 1/1 collected of those as unlearnable too. You can turn it into an addon by pasting it into https://addon.bool.no/
(Note: this only works for default bags and banks and only on English clients that use "Collected (2/3)" on tooltips of items that teach pets. And as an aside, the guild bank UI code is hideously awful. I can't believe Blizzard hasn't totally refactored that ugly mess. And I say that as the unproud owner of thousands and thousands of lines of ugly code lol)
Right click a pet in journal and Put In Cage -> leaves pet journal
Right click a pet in bags -> enters pet journal
The answer to which pets in bags or bank are not in the journal is...all the pets in your bags or bank?
That said, the following will put a green paw over all learnable pets in your bags, bank and guild bank; regardless whether they're an item that teaches a pet or a caged pet. Some pets are unique and it will consider 1/1 collected of those as unlearnable too. You can turn it into an addon by pasting it into https://addon.bool.no/
Code: Select all
-- returns true if the given link is of a pet that can be learned (less than max collected)
local function isLinkLearnable(link)
if not link then
return false
end
-- check for link being a caged pet first
local speciesID = link:match("battlepet:(%d+)")
if speciesID then
local learned,maxLearned = C_PetJournal.GetNumCollectedInfo(speciesID)
if learned<maxLearned then
return true -- link is a caged pet that can be learned
end
end
-- next check for an item that can learn a pet using awful tooltip scans
if select(7,GetItemInfo(link))=="Companion Pets" then
GameTooltip:SetOwner(UIParent,"ANCHOR_NONE")
GameTooltip:SetHyperlink(link)
for j=1,GameTooltip:NumLines() do
local text = _G["GameTooltipTextLeft"..j]:GetText()
local learned,maxLearned = (text or ""):match("^Collected %((%d)/(%d)%)")
if learned and maxLearned and learned<maxLearned then
GameTooltip:Hide()
return true -- link is an item of a pet that can be learned
end
end
GameTooltip:Hide()
end
end
-- updates the badge on the given button to show or hide depending on whether the link
-- for that button's contents is a learnable pet
local function updateBadge(button,link)
if not button then
return
end
if not button.learnablePet then
button.learnablePet = button:CreateTexture(nil,"OVERLAY")
button.learnablePet:SetSize(16,16)
button.learnablePet:SetPoint("TOPLEFT",2,-2)
button.learnablePet:SetTexture("Interface\\Icons\\Tracking_WildPet")
end
button.learnablePet:SetShown(isLinkLearnable(link))
end
-- updates the main bank area
hooksecurefunc("BankFrameItemButton_Update",function(button)
updateBadge(button,GetContainerItemLink(button:GetParent():GetID(),button:GetID()))
end)
-- updates bags (backpack, bags and bank bags)
hooksecurefunc("ContainerFrame_Update",function(frame)
local bag = frame:GetID()
for i=1,frame.size do
local button = _G[frame:GetName().."Item"..i]
updateBadge(button,GetContainerItemLink(bag,button:GetID()))
end
end)
-- updates awfully-coded guild bank
local frame = CreateFrame("Frame")
frame:SetScript("OnEvent",function(self,event,addon)
if IsAddOnLoaded("Blizzard_GuildBankUI") then
self:UnregisterAllEvents()
hooksecurefunc("GuildBankFrame_Update",function()
local tab = GetCurrentGuildBankTab()
for i=1,MAX_GUILDBANK_SLOTS_PER_TAB do
local index = mod(i,NUM_SLOTS_PER_GUILDBANK_GROUP)
if index==0 then
index = NUM_SLOTS_PER_GUILDBANK_GROUP
end
local column = ceil((i-0.5)/NUM_SLOTS_PER_GUILDBANK_GROUP)
local button = _G["GuildBankColumn"..column.."Button"..index] -- seriously, blizzard? wtf
updateBadge(button,GetGuildBankItemLink(tab,i))
end
end)
end
end)
frame:RegisterEvent("ADDON_LOADED")
frame:RegisterEvent("PLAYER_LOGIN")
Re: Macro which cages pets from bank/guild bank
First of all, thank you Gello; this addon is EXACTLY what I meant and I really can't thank you enough. There's only one bug of sort with it in that in the guild banks, it only shows the green paw on pet cages with the text "use: teaches you how to summon this companion". It does NOT show on all the other pets, which is the vast majority. (both bank and bags work as intended by the way).
In the attachments (I can't for the life of me seem to put the screenshots straight into my message) below you can see this; the highlighted Chitterspine Devourer is learnable as I have 2/3 in my pet journal, yet it doesn't show the green paw, while the Mechanical Pandaren Dragonling to the left of it DOES show as learnable, but that's because it's an unused cage, so to speak.
I feel bad asking you to have another try at it, Gello, but this is SO close to being such a game changer for me, and I'm super excited for this. Thanks again for this, and thank you too, Jerebear, for clearing things up!
In the attachments (I can't for the life of me seem to put the screenshots straight into my message) below you can see this; the highlighted Chitterspine Devourer is learnable as I have 2/3 in my pet journal, yet it doesn't show the green paw, while the Mechanical Pandaren Dragonling to the left of it DOES show as learnable, but that's because it's an unused cage, so to speak.
I feel bad asking you to have another try at it, Gello, but this is SO close to being such a game changer for me, and I'm super excited for this. Thanks again for this, and thank you too, Jerebear, for clearing things up!
You guys are absolutely right. Sorry about the unnecessary confusion!
- Attachments
-
- image0[952].jpeg (132.78KiB)Viewed 47555 times
-
- image0[950].jpeg (164.43KiB)Viewed 47555 times
Re: Macro which cages pets from bank/guild bank
Funny enough, I wondered if it'd break the other way. I found a new api to do this without tooltip scans that's not locale-dependent. I can't guarantee I can look at it tonight but I'll update this in the next couple days.
Re: Macro which cages pets from bank/guild bank
I really appreciate it and can't thank you enough
I'll be waiting here patiently!
Kris
I'll be waiting here patiently!
Kris
Re: Macro which cages pets from bank/guild bank
Round two:
There's a minor "bug" where if you have the same pet in multiple bags, learning a pet will only update/hide paws in your current bag until you do something to refresh the bag, like close/open or moving something in that other bag. The workaround for this would require a bit more code than I can commit to right now so I'm letting the behavior remain.
Code: Select all
-- returns true if the given link is of a pet that can be learned (less than max collected)
local function isLinkLearnable(link)
if not link then
return false
end
-- check for link being a caged pet first
local speciesID = link:match("battlepet:(%d+)")
if not speciesID then
local itemID = link:match("item:(%d+)")
if itemID then
speciesID = select(13,C_PetJournal.GetPetInfoByItemID(itemID))
end
end
if speciesID then
local learned,maxLearned = C_PetJournal.GetNumCollectedInfo(speciesID)
if learned<maxLearned then
return true -- link is a caged pet that can be learned
end
end
end
-- updates the badge on the given button to show or hide depending on whether the link
-- for that button's contents is a learnable pet
local function updateBadge(button,link)
if not button then
return
end
if not button.learnablePet then
button.learnablePet = button:CreateTexture(nil,"OVERLAY")
button.learnablePet:SetSize(16,16)
button.learnablePet:SetPoint("TOPLEFT",2,-2)
button.learnablePet:SetTexture("Interface\\Icons\\Tracking_WildPet")
end
button.learnablePet:SetShown(isLinkLearnable(link))
end
-- updates the main bank area
hooksecurefunc("BankFrameItemButton_Update",function(button)
updateBadge(button,GetContainerItemLink(button:GetParent():GetID(),button:GetID()))
end)
-- updates bags (backpack, bags and bank bags)
hooksecurefunc("ContainerFrame_Update",function(frame)
local bag = frame:GetID()
for i=1,frame.size do
local button = _G[frame:GetName().."Item"..i]
updateBadge(button,GetContainerItemLink(bag,button:GetID()))
end
end)
-- updates awfully-coded guild bank
local frame = CreateFrame("Frame")
frame:SetScript("OnEvent",function(self,event,addon)
if IsAddOnLoaded("Blizzard_GuildBankUI") then
self:UnregisterAllEvents()
hooksecurefunc("GuildBankFrame_Update",function()
local tab = GetCurrentGuildBankTab()
for i=1,MAX_GUILDBANK_SLOTS_PER_TAB do
local index = mod(i,NUM_SLOTS_PER_GUILDBANK_GROUP)
if index==0 then
index = NUM_SLOTS_PER_GUILDBANK_GROUP
end
local column = ceil((i-0.5)/NUM_SLOTS_PER_GUILDBANK_GROUP)
local button = _G["GuildBankColumn"..column.."Button"..index] -- seriously, blizzard? wtf
GameTooltip:SetOwner(UIParent,"ANCHOR_NONE")
local speciesID = GameTooltip:SetGuildBankItem(tab,button:GetID())
updateBadge(button,speciesID and "battlepet:"..speciesID or GetGuildBankItemLink(tab,button:GetID()))
end
GameTooltip:Hide()
end)
end
end)
frame:RegisterEvent("ADDON_LOADED")
frame:RegisterEvent("PLAYER_LOGIN")
Re: Macro which cages pets from bank/guild bank
It works! I am one extremely happy customer right now, thank you so much!
Kris
Kris
Re: Macro which cages pets from bank/guild bank
By request, this is a version that makes the paw red when there's only one learnable and green otherwise:
Unfortunately, the paw is shaded too much to make a vibrant color. You can try changing the r,g,b values at the top of the code to try different colors. Maybe one will stand out.
A better solution would be to have dedicated textures, but it wouldn't be as easy to post on the forum. Maybe if I get time this weekend I can wrap it up into an addon to post on wowinterface/curse with proper textures and that other-bag bug fixed.
Code: Select all
-- color for paw when there's only one learnable; the texture is too shaded to make a vibrant color
local r,g,b = 1,0.5,0.5
-- returns number of pets that can be learned if the given link is of a pet that can be learned (less than max collected)
local function isLinkLearnable(link)
if not link then
return false
end
-- check for link being a caged pet first
local speciesID = link:match("battlepet:(%d+)")
if not speciesID then
local itemID = link:match("item:(%d+)")
if itemID then
speciesID = select(13,C_PetJournal.GetPetInfoByItemID(itemID))
end
end
if speciesID then
local learned,maxLearned = C_PetJournal.GetNumCollectedInfo(speciesID)
if learned<maxLearned then
return maxLearned-learned -- link is a caged pet that can be learned; return number that can be learned
end
end
end
-- updates the badge on the given button to show or hide depending on whether the link
-- for that button's contents is a learnable pet
local function updateBadge(button,link)
if not button then
return
end
if not button.learnablePet then
button.learnablePet = button:CreateTexture(nil,"OVERLAY")
button.learnablePet:SetSize(16,16)
button.learnablePet:SetPoint("TOPLEFT",2,-2)
button.learnablePet:SetTexture("Interface\\Icons\\Tracking_WildPet")
end
local numLearnable = isLinkLearnable(link)
button.learnablePet:SetShown(numLearnable) -- will be nil if none learnable
if numLearnable==1 then
button.learnablePet:SetDesaturated(true)
button.learnablePet:SetVertexColor(1,0.5,0.5)
elseif numLearnable then
button.learnablePet:SetDesaturated(false)
button.learnablePet:SetVertexColor(1,1,1)
end
end
-- updates the main bank area
hooksecurefunc("BankFrameItemButton_Update",function(button)
updateBadge(button,GetContainerItemLink(button:GetParent():GetID(),button:GetID()))
end)
-- updates bags (backpack, bags and bank bags)
hooksecurefunc("ContainerFrame_Update",function(frame)
local bag = frame:GetID()
for i=1,frame.size do
local button = _G[frame:GetName().."Item"..i]
updateBadge(button,GetContainerItemLink(bag,button:GetID()))
end
end)
-- updates awfully-coded guild bank
local frame = CreateFrame("Frame")
frame:SetScript("OnEvent",function(self,event,addon)
if IsAddOnLoaded("Blizzard_GuildBankUI") then
self:UnregisterAllEvents()
hooksecurefunc("GuildBankFrame_Update",function()
local tab = GetCurrentGuildBankTab()
for i=1,MAX_GUILDBANK_SLOTS_PER_TAB do
local index = mod(i,NUM_SLOTS_PER_GUILDBANK_GROUP)
if index==0 then
index = NUM_SLOTS_PER_GUILDBANK_GROUP
end
local column = ceil((i-0.5)/NUM_SLOTS_PER_GUILDBANK_GROUP)
local button = _G["GuildBankColumn"..column.."Button"..index] -- seriously, blizzard? wtf
GameTooltip:SetOwner(UIParent,"ANCHOR_NONE")
local speciesID = GameTooltip:SetGuildBankItem(tab,button:GetID())
updateBadge(button,speciesID and "battlepet:"..speciesID or GetGuildBankItemLink(tab,button:GetID()))
end
GameTooltip:Hide()
end)
end
end)
frame:RegisterEvent("ADDON_LOADED")
frame:RegisterEvent("PLAYER_LOGIN")
A better solution would be to have dedicated textures, but it wouldn't be as easy to post on the forum. Maybe if I get time this weekend I can wrap it up into an addon to post on wowinterface/curse with proper textures and that other-bag bug fixed.
Re: Macro which cages pets from bank/guild bank
Absolutely fantastic! I see what you mean with the red shading, but honestly, I'm very happy with this already. Thanks so much
Kris
Kris
Re: Macro which cages pets from bank/guild bank
Update for 9.1.5 which made some changes to the guild bank code:
Also Caliban or anyone who wants this tweaked, I will generally catch new messages on this forum, but the PM system here is extremely difficult for me. So unfortunately I'm turning off messaging on this site. If I don't respond to a thread on this forum in a timely manner, I get an automated email from PMs on wowinterface or curse that are much easier for me to reply to.
Code: Select all
-- color for paw when there's only one learnable; the texture is too shaded to make a vibrant color
local r,g,b = 1,0.5,0.5
-- make this true to make a red (or whatever color above) paw when only one more of a pet can be learned
local ALT_PAWS_FOR_ONE_LEARNABLE = false
-- from Blizzard_GuildBankUI (now local)
local MAX_GUILDBANK_SLOTS_PER_TAB = 98
local NUM_SLOTS_PER_GUILDBANK_GROUP = 14
-- returns number of pets that can be learned if the given link is of a pet that can be learned (less than max collected)
local function isLinkLearnable(link)
if not link then
return false
end
-- check for link being a caged pet first
local speciesID = link:match("battlepet:(%d+)")
if not speciesID then
local itemID = link:match("item:(%d+)")
if itemID then
speciesID = select(13,C_PetJournal.GetPetInfoByItemID(itemID))
end
end
if speciesID then
local learned,maxLearned = C_PetJournal.GetNumCollectedInfo(speciesID)
if learned<maxLearned then
return maxLearned-learned -- link is a caged pet that can be learned; return number that can be learned
end
end
end
-- updates the badge on the given button to show or hide depending on whether the link
-- for that button's contents is a learnable pet
local function updateBadge(button,link)
if not button then
return
end
if not button.learnablePet then
button.learnablePet = button:CreateTexture(nil,"OVERLAY")
button.learnablePet:SetSize(16,16)
button.learnablePet:SetPoint("TOPLEFT",2,-2)
button.learnablePet:SetTexture("Interface\\Icons\\Tracking_WildPet")
end
local numLearnable = isLinkLearnable(link)
button.learnablePet:SetShown(numLearnable) -- will be nil if none learnable
if ALT_PAWS_FOR_ONE_LEARNABLE and numLearnable==1 then
button.learnablePet:SetDesaturated(true)
button.learnablePet:SetVertexColor(1,0.5,0.5)
elseif numLearnable then
button.learnablePet:SetDesaturated(false)
button.learnablePet:SetVertexColor(1,1,1)
end
end
-- updates the main bank area
hooksecurefunc("BankFrameItemButton_Update",function(button)
updateBadge(button,GetContainerItemLink(button:GetParent():GetID(),button:GetID()))
end)
-- updates bags (backpack, bags and bank bags)
hooksecurefunc("ContainerFrame_Update",function(frame)
local bag = frame:GetID()
for i=1,frame.size do
local button = _G[frame:GetName().."Item"..i]
updateBadge(button,GetContainerItemLink(bag,button:GetID()))
end
end)
-- updates awfully-coded guild bank
local frame = CreateFrame("Frame")
frame:SetScript("OnEvent",function(self,event,addon)
if IsAddOnLoaded("Blizzard_GuildBankUI") then
self:UnregisterAllEvents()
hooksecurefunc(GuildBankFrame,"Update",function()
local tab = GetCurrentGuildBankTab()
for i=1,MAX_GUILDBANK_SLOTS_PER_TAB do
local index = mod(i,NUM_SLOTS_PER_GUILDBANK_GROUP)
if index==0 then
index = NUM_SLOTS_PER_GUILDBANK_GROUP
end
local column = ceil((i-0.5)/NUM_SLOTS_PER_GUILDBANK_GROUP)
local button = GuildBankFrame.Columns[column].Buttons[index]
GameTooltip:SetOwner(UIParent,"ANCHOR_NONE")
local speciesID = GameTooltip:SetGuildBankItem(tab,button:GetID())
updateBadge(button,speciesID and "battlepet:"..speciesID or GetGuildBankItemLink(tab,button:GetID()))
end
GameTooltip:Hide()
end)
end
end)
frame:RegisterEvent("ADDON_LOADED")
frame:RegisterEvent("PLAYER_LOGIN")
Re: Macro which cages pets from bank/guild bank
Thanks a ton again, Gello, big relief this is working in 9.1.5 now. And understood about the PM's!
Ty
Ty
Re: Macro which cages pets from bank/guild bank
Hi Gello,
Would it be possible for you to update the above 9.1.5 version of the 'Paw' addon for Dragonflight? Since today it's not showing the paw either in guildbank, bank, or my bags (neither in 'combined bag' or 'separate bag' mode). Thanks in advance
Kris
Would it be possible for you to update the above 9.1.5 version of the 'Paw' addon for Dragonflight? Since today it's not showing the paw either in guildbank, bank, or my bags (neither in 'combined bag' or 'separate bag' mode). Thanks in advance
Kris
Re: Macro which cages pets from bank/guild bank
I'll take a look but it may be a while. Quite a lot has changed with bags/containers and in the next patch (10.0.2) there will be even more changes. So I've kind of pushed review of those changes to the side with so much else that needs attention.
Re: Macro which cages pets from bank/guild bank
Yup, I understand! I'll keep an eye on this thread in the meantime, and good luck with all the work you're doing
Kris
Kris
Re: Macro which cages pets from bank/guild bank
Hi Gello,
I'm wondering if you're able and have time to look into updating the addon again. I'd love to use it again, especially now that my banks and guild banks are overflowing. Again, of course, I understand should you still not have time for this - I can wait
Kris
Re: Macro which cages pets from bank/guild bank
I'll try to look but I've got many things competing for my attention right now and the guild bank is horrible to work with. Realistically, this will probably have to wait longer, but I can try to give it a look next weekend.
Re: Macro which cages pets from bank/guild bank
I understand, and thanks for looking into it whether it'll work out or not
Kris