Quantcast
WoWInterface - View Single Post - UnitOwner (GUID), identifying guardians and pets.
View Single Post
09-24-14, 06:05 PM   #2
semlar
A Pyroguard Emberseer
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 1,059
In the meantime, you can try something like this if you encounter a guardian without witnessing its creation.
Lua Code:
  1. local tip = CreateFrame('GameTooltip', 'GuardianOwnerTooltip', nil, 'GameTooltipTemplate')
  2. function GetGuardianOwner(guid)
  3.     tip:SetOwner(WorldFrame, 'ANCHOR_NONE')
  4.     tip:SetHyperlink('unit:' .. guid or '')
  5.     local text = GuardianOwnerTooltipTextLeft2
  6.     return strmatch(text and text:GetText() or '', "^([^%s']+)'")
  7. end

This example will probably only work on english clients, however there are a number of entries in GlobalStrings.lua that could potentially be matched against the line in the tooltip.
Lua Code:
  1. UNITNAME_SUMMON_TITLE1 = "%s's Pet";
  2. UNITNAME_SUMMON_TITLE10 = "%s's Mount";
  3. UNITNAME_SUMMON_TITLE11 = "%s's Lightwell";
  4. UNITNAME_SUMMON_TITLE12 = "%s's Butler";
  5. UNITNAME_SUMMON_TITLE13 = "%s'aka";
  6. UNITNAME_SUMMON_TITLE14 = "%s's Gateway";
  7. UNITNAME_SUMMON_TITLE15 = "%s's Hatred";
  8. UNITNAME_SUMMON_TITLE16 = "%s's Statue";
  9. UNITNAME_SUMMON_TITLE17 = "%s's Spirit";
  10. UNITNAME_SUMMON_TITLE18 = "%s's War Banner";
  11. UNITNAME_SUMMON_TITLE19 = "%s's Heartwarmer";
  12. UNITNAME_SUMMON_TITLE2 = "%s's Guardian";
  13. UNITNAME_SUMMON_TITLE20 = "Hired by %s";
  14. UNITNAME_SUMMON_TITLE21 = "Purchased by %s";
  15. UNITNAME_SUMMON_TITLE22 = "%s's Pride";
  16. UNITNAME_SUMMON_TITLE23 = "Twisted Image of %s";
  17. UNITNAME_SUMMON_TITLE24 = "%s's Noodle Cart";
  18. UNITNAME_SUMMON_TITLE3 = "%s's Minion";
  19. UNITNAME_SUMMON_TITLE4 = "%s's Totem";
  20. UNITNAME_SUMMON_TITLE5 = "%s's Companion";
  21. UNITNAME_SUMMON_TITLE6 = "%s's Runeblade";
  22. UNITNAME_SUMMON_TITLE7 = "%s's Construct";
  23. UNITNAME_SUMMON_TITLE8 = "%s's Opponent";
  24. UNITNAME_SUMMON_TITLE9 = "%s's Vehicle";
  Reply With Quote