1. #1
    Deleted

    Question Extract NPC name from ID or beta client

    Hello.

    I'm trying to write some guides in spanish and I was looking for some WoD NPC names in my language, however it's hard to find them in the most of websites like wowhead because they aren't updated yet.

    I was wondering if there are some scripts to get these names from the game with the NPC ID, or tools to extract these names from the client.
    I've been looking in the files of the beta client, but I'm not sure if the names are in the client or they are downloaded from the server once you find the NPC in the game.

    Thanks!

  2. #2
    Here's an addon I wrote for something else, but I've adapted it to output the name of an npc from an ID..
    Code:
    local QUEST_TIMEOUT = 0.3
    local function ScrapeQTip(self)
    	local tipName = self:GetName()
    	local name, description = _G[tipName .. 'TextLeft1']:GetText(), _G[tipName ..'TextLeft2']:GetText()
    	if name then
    		print(format('|cffffff00|Hunit:Creature-0-0-0-0-%d-0|h[%s]|h|r (%d) %s', self.npcID, name, self.npcID, description or ''))
    	end
    	self:SetScript('OnTooltipSetUnit', nil)
    	self.npcID = nil
    end
    
    local QTips = {}
    local function GetQTip()
    	local now = GetTime()
    	for i, tip in ipairs(QTips) do
    		if not tip.npcID or now - tip.lastUpdate > QUEST_TIMEOUT + 0.2 then
    			tip.lastUpdate = now
    			return tip
    		end
    	end
    	local tip = CreateFrame('GameTooltip',  'SemlarsQTip' .. (#QTips + 1), WorldFrame, 'GameTooltipTemplate')
    	tip:Show()
    	tip:SetHyperlink('unit:')
    	tip.lastUpdate = now
    	tinsert(QTips, tip)
    	return tip
    end
    
    function GetNPCInfo(npcID)
    	local tip = GetQTip()
    	tip:SetOwner(WorldFrame, 'ANCHOR_NONE')
    	tip.npcID = npcID or 0
    	tip:SetScript('OnTooltipSetUnit', ScrapeQTip)
    	tip:SetHyperlink('unit:Creature-0-0-0-0-' .. npcID .. '-0')
    	C_Timer.After(QUEST_TIMEOUT, function() -- Run a second pass for uncached units or the event will never fire
    		if tip.npcID == npcID then
    			tip:SetHyperlink('unit:Creature-0-0-0-0-' .. npcID .. '-0')
    		end
    	end)
    end

    Usage is "/run GetNPCInfo(npcID)", and you'll have to wait for a response from the server if the unit isn't cached.

    It's capable of scanning multiple IDs at once.

    Paste it into http://addon.bool.no if you need help turning it into an addon, change the interface number to 60000 in the toc options.
    Last edited by semlar; 2014-09-28 at 09:03 AM.

  3. #3
    Deleted
    You are my heroe I'm going to try it right away!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •