WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Getting links for uncollected pets and mounts (https://www.wowinterface.com/forums/showthread.php?t=58795)

Walkerbo 06-14-21 10:42 PM

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?

Ketho 06-15-21 07:07 AM

Quote:

Originally Posted by Walkerbo (Post 339388)
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")


Walkerbo 06-15-21 10:16 PM

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.

Ketho 06-16-21 04:46 AM

Quote:

Originally Posted by Walkerbo (Post 339399)
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 :rolleyes:
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

Walkerbo 06-16-21 05:52 PM

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. :)


All times are GMT -6. The time now is 07:00 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI