What is the best way to obtain NPC titles?
Currently I check the second line of the GameTooltip in an OnTooltipSetUnit script, looking if it contains the level information (e.g. Level 80 Humanoid) and if not, I assume it is the NPC title.
This method has some problems when it comes to localisation though. The word "Level" will be different depending on what client is used, so I figured I could make it match
TOOLTIP_UNIT_LEVEL which is
"Level %s" on enUS. Specifically I matched this, which is
"^Level .+":
Code:
"^"..TOOLTIP_UNIT_LEVEL:gsub("%%s",".+")
But the problem is, even this doesn't match on all locals. And as I would really hate adding localisation to my addon(s), does anyone know of an easier way to figure out the NPC title, without depending on localisation?
I have a bonus question when it comes to code like this:
Code:
local _, _, _, _, _, value = SomeFunc();
How does the underscore work in Lua precisely? Does Lua know that underscores shouldn't be set, or does it just make one local variable in this block and set the first five parameters to it? Also, is this code good, or is it better done using select(6,SomeFunc())?