Thread Tools Display Modes
10-09-22, 05:03 PM   #1
Gello
A Molten Giant
AddOn Author - Click to view addons
Join Date: Jan 2005
Posts: 521
Another beta vs PTR difference: getting npcID names

For years I've been getting the name of an npcID by doing this:

Code:
-- takes an npcID and returns the name of the npc
-- if the return is nil, the npcID is invalid or it's not been cached yet
function tamer:GetNameFromNpcID(npcID)
	local tooltip = BattlePetDailyTamerScanTooltip
	tooltip:SetOwner(UIParent, "ANCHOR_NONE")
	tooltip:SetHyperlink(format("unit:Creature-0-0-0-0-%d-0000000000", npcID))
	if tooltip:NumLines() > 0 then
		local name = BattlePetDailyTamerScanTooltipTextLeft1:GetText()
		tooltip:Hide()
		return name
	end
end
On the PTR this still works. It spoofs a GUID of the npcID and lifts the localized name from the tooltip.

On the beta this seems to drop the first line (the name) from the tooltip and leaves the rest; generally giving names like 'Master Pet Trainer' and such. It's does not appear to be a caching issue.

Is this a bug or will it become the new normal? Have any methods been added to get the localized name of an npcID, or any that I've missed?

This is (I hope!) a bug on the beta but I can't post to the official beta forums, and the 255-character limit is too small to explain this. It's incredibly frustrating.
  Reply With Quote
10-12-22, 11:52 PM   #2
Ketho
A Pyroguard Emberseer
 
Ketho's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,026
Originally Posted by Gello View Post
Is this a bug or will it become the new normal? Have any methods been added to get the localized name of an npcID, or any that I've missed?

It appears to be a bug and not intentional

https://github.com/Stanzilla/WoWUIBugs/issues/297
  Reply With Quote
10-13-22, 05:06 AM   #3
Gello
A Molten Giant
AddOn Author - Click to view addons
Join Date: Jan 2005
Posts: 521
Thanks. Fingers crossed that they fix it.
  Reply With Quote
10-18-22, 04:52 PM   #4
galvin
A Frostmaul Preserver
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 265
Btw you don't have to use tooltip. to get stuff like this you can just do something like

Not sure if this will work, but it should I think. I use the same thing to read tooltip text for SpellIDs

Code:
    local Hyperlink = C_TooltipInfo.GetHyperlink(format("unit:Creature-0-0-0-0-%d-0000000000", npcID))
    if Hyperlink and #Hyperlink.lines > 0 then
    -- do stuff here
    end
if you want to read the tooltip text from the table just do something like
Code:
      for LineIndex = 1, #Lines do
        local Line = Lines[LineIndex]
        local Args = Line.args

        for ArgIndex = 1, #Args do
          local Arg = Args[ArgIndex]
          local Text = Arg.stringVal
  Reply With Quote
10-18-22, 06:48 PM   #5
Gello
A Molten Giant
AddOn Author - Click to view addons
Join Date: Jan 2005
Posts: 521
This appears fixed in today's beta build.

I'll look into C_Tooltip thanks.
  Reply With Quote
10-19-22, 01:39 PM   #6
galvin
A Frostmaul Preserver
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 265
Looks like C_TooltipInfo isn't going live in prepatch
  Reply With Quote

WoWInterface » PTR » PTR General Discussion » Another beta vs PTR difference: getting npcID names

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