Originally Posted by Dridzt
what exactly he needs boss names for
|
I think we can help regardless of his goals.
I reckon one has to use tooltip scanning, meaning the creature must be in the cache, otherwise a internal id to name database is required. It's true, this means the creatures must be in the cache for him to be able to get their localized names. Alternatively internal addon database over id and name is in order, but hopefully not needed.
Here is my example using a cache system:
Code:
local tooltip = CreateFrame("GameTooltip", "ExampleTooltipScanner", UIParent, "GameTooltipTemplate")
tooltip = setmetatable(tooltip, {__index = function(self, id)
self:SetOwner(UIParent, "ANCHOR_NONE")
self:SetHyperlink(("unit:0xF53%05X00000000"):format(id))
local name
if self:IsShown() then
for i = 1, self:NumLines() do
local text = _G[self:GetName() .. "TextLeft" .. i]
if text and text.GetText then
name = text:GetText()
break
end
end
end
self:Hide()
self[id] = name
return name
end})
Note it doesn't handle errors, i.e. if it says "Retrieving data..." it will literally store that, or any other message on the tooltip. Just a heads up, can be fixed by making sure it only stores the "name" value when it's appropriate.