WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   GetCompanionInfo("MOUNT") broken for WotLK Classic 3.4.3? (https://www.wowinterface.com/forums/showthread.php?t=59687)

fullmoon_sulfuras 10-14-23 03:18 PM

GetCompanionInfo("MOUNT") broken for WotLK Classic 3.4.3?
 
GetCompanionInfo seems broken when getting mount information on WotLK 3.4.3. The following snippet works:

Lua Code:
  1. for i=1,GetNumCompanions("CRITTER") do
  2.     local creatureID, creatureName, creatureSpellID, icon, issummoned = GetCompanionInfo("CRITTER", i);
  3.     print(creatureID, creatureSpellID, creatureName, icon, issummoned)
  4. end

However, this returns all nil values:

Lua Code:
  1. for i=1,GetNumCompanions("MOUNT") do
  2.     local creatureID, creatureName, creatureSpellID, icon, issummoned = GetCompanionInfo("MOUNT", i);
  3.     print(creatureID, creatureSpellID, creatureName, icon, issummoned)
  4. end

My addon's code is very similar to the snippet above and used to work fine until 3.4.3.

The odd thing is that in Interface_Wrath/FrameXML/PetPaperDollFrame.lua there's:

Lua Code:
  1. function PetPaperDollFrame_OnLoad (self)
  2.     self:RegisterEvent("PET_UI_UPDATE");
  3.     self:RegisterEvent("PET_BAR_UPDATE");
  4.  
  5.     ...
  6.  
  7.     PetPaperDollFrameCompanionFrame.mode = "CRITTER";
  8.     PetPaperDollFrameCompanionFrame.idMount = GetCompanionInfo("MOUNT", 1);


Any ideas are more than welcome! Thanks!!

Xrystal 10-14-23 06:38 PM

I suspect this is one of those areas where they pulled in the retail version of the Collections system rather than grab out the old classic version.

I'm gonna see if I can simulate that for loop with the new functionality in 3.4.3 but I've not touched this part of the API before so in the mean time ... here's the warcraft.wiki ( formerly known as wowpedia rofl ) for what I think they have replaced it with.

https://warcraft.wiki.gg/wiki/World_...PI#Collections


Yep, this seems to be working as I thought. Here's the lua and toc for a quick test addon

Lua Code:
  1. local function CheckMounts()
  2.     local mountIDs = C_MountJournal.GetMountIDs()
  3.    
  4.     for i = 1, #mountIDs do
  5.         local name, spellID, icon, isActive, isUsable, sourceType, isFavorite, isFactionSpecific, faction, shouldHideOnChar, isCollected, mountID = C_MountJournal.GetMountInfoByID(i)
  6.         print(mountID,name,isCollected,sourceType,spellID,icon,isActive)
  7.     end
  8. end
  9.  
  10. local function OnEvent(self,event,...)    
  11.     if event == "ADDON_LOADED" then
  12.         CheckMounts()
  13.     elseif event == "PLAYER_LOGIN" then
  14.         --CheckMounts()
  15.     end
  16. end
  17.  
  18. local f = CreateFrame("Frame")
  19. f:RegisterEvent("ADDON_LOADED")
  20. f:RegisterEvent("PLAYER_LOGIN")
  21. f:SetScript("OnEvent",OnEvent)


Lua Code:
  1. ## Interface: 30403
  2. ## Version: v0.0.1
  3. ## Title: Collection Info Test
  4. ## Notes: Testing Collection Info functionality
  5. ## Author: Xrystal
  6. ## SavedVariables:
  7. ## Dependencies: Blizzard_Collections
  8. ## OptionalDeps:
  9. ## IconTexture:
  10. ## DefaultState: Enabled
  11. ## LoadOnDemand: 0
  12.  
  13. CollectionInfoTest.lua

fullmoon_sulfuras 10-15-23 09:22 PM

Thanks to your post, I was able to fix my addon!


All times are GMT -6. The time now is 12:35 PM.

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