Okay, so Nameplates don't have a lot of API in order to play with them.
In an nice world, something like this could be interesting :
nameplateUnitIndex = An ID64 at the creation of EACH unit. This one will stay same for every unit in game until UI reload / character logoff.
If the unit is destroyed because it have disppeared from your screen, the ID64 must remain same when the same unit come back.
When unit is not visible, all those functions below returns nil
If the unit is an NPC and being killed, the respawn of that same npc can provide another id64 if there is any security issue.
Then the big question, are those events triggers / function return nil when nameplates are disabled ?
So, 2 events :
EVENT_NAMEPLATE_UNIT_CREATED(integer eventId, id64 nameplateUnitIndexCreated)
Event triggers when a nameplate enters on screen (should trigger only when 1st pixel of text is visible on screen).
EVENT_NAMEPLATE_UNIT_DESTROYED(integer eventId, id64 nameplateUnitIndexDestroyed)
Event triggers when a nameplate totally disappear from screen (should trigger only when last pixel of text exit screen).
Those events can be spammy. If I have 20 units front of me and I turn my camera, the event should fire 20 times. If I look at them back, even should fire 20 more times.
Few functions :
Lua Code:
local numNameplatesVisible = GetNumNamePlateUnitVisible(nameplateUnitIndex)
-- return the count of NamePlatesUnit visible
local nameplateUnitIndex = GetNamePlateUnitIndex(index)
-- return the id64 nameplateUnitIndex at index X.
local displayName = GetNamePlateDisplayName(nameplateUnitIndex)
-- return the DisplayName of the nameplateUnitIndex or nil if nameplateUnitIndex is not a player
local caption = GetNamePlateCaption(nameplateUnitIndex)
-- return the caption of the NPC or nil if nameplateUnitIndex has no caption / not a NPC
local isVisible = IsNamePlateGuildShown(nameplateUnitIndex)
-- return true if a guild name is displayed
local guildName = GetNamePlateGuildName(nameplateUnitIndex)
-- return guildName of the nameplateUnitIndex or nil if no guild name / not a player
local namePlateType GetNamePlateType(nameplateUnitIndex)
-- return an UnitNameplateType constant ( wiki.esoui.com/Globals#UnitNameplateType )
local name = GetNamePlateName(nameplateUnitIndex)
-- return the name of the nameplateUnitIndex
-- if unit is an NPC, it returns its whole name
-- if unit is a player, it returns ONLY his characterName
The Title problem :
Titles are formatted with a translator convenience. They don't follow vanilla titles. Experts could find them in xx.csv
For PVP and emperor, they're prefixed.
<<Title>> <<YourName>>
For PVE, they're suffixed with comma and pronoun.
<<YourName>>, <<pronoun>> <<title>> (Except new "Silencer" Title which is prefixed like PVP titles).
And, when title is active, title is merged with your name.
a GetNamePlateTitle(nameplateUnitIndex) will return the title and your name I guess.
So :
Lua Code:
local isTitleShown = IsNamePlateTitleShown(nameplateUnitIndex)
-- return true if a title is displayed, nil if not a player or no title.
to get the Title.. I think we'll have to play with gsub.
Setting our own NamePlates :
Lua Code:
SetNamePlateName(value, nameplateUnitIndex)
-- Set the name of the concerned nameplateUnitIndex. if unit is a player, his title if shown won't be changed
SetNamePlateFullName(value, nameplateUnitIndex)
-- Set the full name of the concerned nameplateUnitIndex (will erase title)
SetNamePlateGuild(value, nameplateUnitIndex)
-- Set the Guild Name of the concerned nameplateUnitIndex if unit is a player
SetNamePlateCaption(value, nameplateUnitIndex)
-- Set the name of the concerned nameplateUnitIndex if unit is a npc
For SetNamePlateName, if nameplateUnitIndex is a player, the value should follow at least the max length name.
For SetNamePlateFullName, the length of the value must not be > max name length + length the longest title available ingame (we have a title in french of 45 chars per ex.)
For those 2 last functions : They function should let us play with the format ("<" and ">") if we want to remove them. Without those chars, they must not be displayed. If I set "Something", it must be "Something", not "<Something>"
Colors :
Lua Code:
SetNamePlateBaseColorForType(type, r, g, b, closeAlpha, farAlpha)
-- Set the color of the UnitNameplateType when unit is not targetted. closeAlpha is the alpha value when the unit is the closest possible, farAlpha is the alpha when the unit is the farthest possible.
SetNamePlateTargettedColorForType(type, r, g, b, closeAlpha, farAlpha)
-- Set the color of the UnitNameplateType when unit is targetted. closeAlpha is the alpha value when the unit is the closest possible, farAlpha is the alpha when the unit is the farthest possible.
If type == UNIT_NAMEPLATE_DEFAULT (the local player), the 2nd function won't do nothing. And 1st function is inverted (the more we zoom, the less we see our nameplate).
Finally, the fonts :
Lua Code:
GetNamePlateBaseFont() -- Returns the NamePlate font when unit is not targetted
GetNamePlateTargettedFont() -- Returns the NamePlate font when unit is targetted
SetNamePlateBaseFont() -- Set the NamePlate font when unit is not targetted
SetNamePlateTargettedFont() -- Set the NamePlate font when unit is targetted
That's all
It was interesting writing this and we'll maybe never have those functions, maybe because already thinked and considered too intense. but we never know.