Quantcast
Getting links for uncollected pets and mounts - WoWInterface
Thread Tools Display Modes
06-14-21, 10:42 PM   #1
Walkerbo
A Flamescale Wyrmkin
 
Walkerbo's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 134
Getting links for uncollected pets and mounts

Hi all

I am trying to print the links for pets and mounts that I have not yet collected by clicking on them in the Collections journal.

I can add "onclick" functions on the scroll buttons that prints the details of the selected pet yet if it is not collected I cannot seem to get the link.

There are API calls that are meant to return the current pet GUID however on uncollected pets they return nil.

Here is the chunk;
Lua Code:
  1. local petIndex = 0
  2. while true do
  3.     petIndex = petIndex + 1
  4.     local buttonName = "PetJournalListScrollFrameButton" .. petIndex
  5.     local button = _G[buttonName]
  6.     if not button then break end
  7.     button:HookScript("OnClick",
  8.     function(self)
  9.  
  10.         print("*****************************************************")
  11.         print("*****************************************************")
  12.  
  13.         print("PetButton\nindex =", self.index, "\nspeciesID =", self.speciesID, "\npetID =", self.petID, "\n**********************")
  14.  
  15.         local petID, speciesID, owned, customName, level, favorite, isRevoked, speciesName, icon, petType, companionID, tooltip, description, isWild, canBattle, isTradeable, isUnique, obtainable = C_PetJournal.GetPetInfoByIndex(self.index)
  16.  
  17.         print("GetPetInfoByIndex\npetID -", petID, "\nspeciesID -", speciesID, "\nspeciesName -",speciesName, "\ncompanionID -",companionID, "\ntooltip -",tooltip, "\ndescription -",description, "\n **********************")
  18.  
  19.         local speciesName, speciesIcon, petType, companionID, tooltipSource, tooltipDescription, isWild, canBattle, isTradeable, isUnique, obtainable, creatureDisplayID = C_PetJournal.GetPetInfoBySpeciesID(self.speciesID)
  20.  
  21.         print("C_PetJournal.GetPetInfoBySpeciesID\nspeciesName -", speciesName, "\npetType -", petType, "\ncompanionID -",companionID, "\ntooltipSource -",tooltipSource, "\ntooltipDescription -",tooltipDescription, "\ndescription -",description, "\ncreatureDisplayID", creatureDisplayID, "\n **********************")
  22.  
  23.         local speciesId, petGUID = C_PetJournal.FindPetIDByName(speciesName)
  24.  
  25.         print("C_PetJournal.FindPetIDByName\nspeciesId -", speciesId, "\npetGUID -", petGUID)
  26.  
  27.         print("*****************************************************")
  28.         print("*****************************************************")
  29.  
  30.         end)
  31.     end

And these are the results;


I have not been able to get the links no matter what I have tried.

Is there another way to get mount and pet links, or is this totally hidden from us by Blizz?
__________________
"As someone once told me, frames are just special types of tables, and tables are special types of pointers."
Fizzlemizz
  Reply With Quote
06-15-21, 07:07 AM   #2
Ketho
A Molten Giant
 
Ketho's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 991
Originally Posted by Walkerbo View Post
There are API calls that are meant to return the current pet GUID however on uncollected pets they return nil.
[...]
I have not been able to get the links no matter what I have tried.

Is there another way to get mount and pet links, or is this totally hidden from us by Blizz?

The API not returning the GUID makes sense because it refers to a unique pet you own
Pet links include that GUID so you can't normally link pets you don't have collected yourself

You can still make a link yourself, it requires at least:
https://wowpedia.fandom.com/wiki/UI_...nces#battlepet
  • speciesID, level, breedQuality for print()
  • and additionally maxHealth for SendChatMessage()
  • an empty "BattlePet--" GUID otherwise it will give an error when clicking "Click here to view in journal"

For example I don't own Crawbat
Code:
/run print("\124cff1eff00\124Hbattlepet:3083:1:2::::BattlePet--:\124h[Crawbat]\124h\124r")
/run SendChatMessage("\124cff1eff00\124Hbattlepet:3083:1:2:1:::BattlePet--:\124h[Crawbat]\124h\124r")

Last edited by Ketho : 06-15-21 at 07:30 AM.
  Reply With Quote
06-15-21, 10:16 PM   #3
Walkerbo
A Flamescale Wyrmkin
 
Walkerbo's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 134
Hi Ketho

I am not sure that it makes sense that the petGUID is only known for pets that are currently known as there are examples of being able to get the GUID of mounts even if they are unknown.

For example, I can get the mount link for an uncollected mount using the following chunk;
Lua Code:
  1. local mountIndex = 0
  2. while true do
  3.     mountIndex = mountIndex + 1
  4.     local buttonName = "MountJournalListScrollFrameButton" .. mountIndex
  5.     local button = _G[buttonName]
  6.     if not button then
  7.         break
  8.     end
  9.     button:HookScript(
  10.         "OnClick",
  11.         function(self)
  12.             print("*****************************************************") -- debug --
  13.             mountLink = GetSpellLink(self.spellID)
  14.             print(mountLink)
  15.             print("*****************************************************") -- debug --
  16.         end
  17.     )
  18. end

So I still believe the following should work;
Lua Code:
  1. local speciesId, petGUID = C_PetJournal.FindPetIDByName(speciesName)
but it obviously returns nil for the petGUID.

I had no idea that I could create my own link, so thank you very much for the link.

I have had fun building a few of them though having no way of getting the unknown pet rarity I have to use a fixed colour for the link.
__________________
"As someone once told me, frames are just special types of tables, and tables are special types of pointers."
Fizzlemizz
  Reply With Quote
06-16-21, 04:46 AM   #4
Ketho
A Molten Giant
 
Ketho's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 991
Originally Posted by Walkerbo View Post
I am not sure that it makes sense that the petGUID is only known for pets that are currently known as there are examples of being able to get the GUID of mounts even if they are unknown.

I don't think you understand the concept of a GUID. A specific battlepet you own has a globally unique ID, just like a unitGUID and not to be confused with a speciesID
https://en.wikipedia.org/wiki/Univer...que_identifier

Mounts use the spell ID when linked and are obviously different than battlepets where players can collect multiples of the same pet with variable levels and stats
  Reply With Quote
06-16-21, 05:52 PM   #5
Walkerbo
A Flamescale Wyrmkin
 
Walkerbo's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 134
Hi Ketho

Thanks for your post, you make some very good points.

I can see why pets have more unique GUID's to cover the fact that you can have multiples with different stats.

Also, the fact that some players have renamed their pets and the same pet can be captured in different rarities drives that point home.

It still irks me though as the uncollected pets are all baseline, yet the same problem would be the stats and rarities are not all baseline.

Oh well, you did make me think harder about the reasons and I can see that you are right.

Also, you did show me how I can create my own special links and this in itself is a great outcome.

Thanks for your help with this.
__________________
"As someone once told me, frames are just special types of tables, and tables are special types of pointers."
Fizzlemizz
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Getting links for uncollected pets and mounts

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