WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   PTR General Discussion (https://www.wowinterface.com/forums/forumdisplay.php?f=172)
-   -   Another beta vs PTR difference: getting npcID names (https://www.wowinterface.com/forums/showthread.php?t=59252)

Gello 10-09-22 05:03 PM

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.

Ketho 10-12-22 11:52 PM

Quote:

Originally Posted by Gello (Post 341209)
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

Gello 10-13-22 05:06 AM

Thanks. Fingers crossed that they fix it.

galvin 10-18-22 04:52 PM

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


Gello 10-18-22 06:48 PM

This appears fixed in today's beta build.

I'll look into C_Tooltip thanks.

galvin 10-19-22 01:39 PM

Looks like C_TooltipInfo isn't going live in prepatch


All times are GMT -6. The time now is 01:28 PM.

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