CustomNames

CustomNames

146 Downloads

Unlock a realm of possibilities as you gain full control over the names of NPCs, players, pets, and more. Whether you're seeking to enhance role-playing scenarios, create thematic storylines, or simply add a touch of personalization to your adventures, CustomNames provides Addon Developers with the tools to do so.

CustomNames gives you the ability of mapping character names to Nicknames of your choosing.
e.G. SuperSaiyanDK to -> "Nick" or Nickspriest-Draenor to -> "Nick". Begone are the times you need to remember everyones alt names.


Current official Implementations:

ElvUI

Plater


It also provides some easy to use slash command to let users add their own custom names if they choose to do so.

CustomNames example usage:
Adding a new name: /cn add Name to CustomName
Editing name: /cn edit Name to CustomName
Deleting old name: /cn del Name
Listing every name: /cn l(ist)


Standalone this doesn't do anything if the addon displaying the Name doesn't implement the usage of the provided functions.


Usage 

local Lib = LibStub("CustomNames")

Both of the below accept units aswell as Names in the format of Name-Realm (for players) or just Name (for npcs)

  • local success = Lib.Set(name, customName) -- for adding/editing 
  • local success = Lib.Set(name) -- for deleting 


local NameList = Lib.GetList() -- returns a copy of the table with all the CustomNames in it

NameList Format
NameList = {
	["Name-Realm1"] = "CustomName1",
	["Name-Realm2"] = "CustomName2",
}

functions to get Names:

  • local customName = Lib.Get(name) -- this works both for Get(Charname) and Get(Btag)
  • local customName = Lib.UnitName(unit) -- behaves equivalent to normal UnitName()
  • local customName = Lib.UnitFullName(unit) -- behaves equivalent to normal UnitFullName()
  • local customName = Lib.UnitNameUnmodified(unit) -- behaves equivalent to normal UnitNameUnmodified()
  • local customName = Lib.GetUnitName(unit,showServerName) -- behaves equivalent to normal GetUnitName()
Bnet api:
local isInDatabase = Lib.isCharInBnetDatabase(name) -- returns true if the charname is already linked to a bnet account (nil otherwise)
local success = Lib.addCharToBtag(charname,btag) -- links a char to a Given Btag. Btag should be in format "BattleTag#12345"

Callbacks 

event names: Name_Removed , Name_Update, Name_Added

Name_Removed (Name) -- will return the name in the database that got removed 
Name_Updated (Name, newCustomName, oldCustomName) -- will return the name in the database, the new CustomName the database was updated to and the old CustomName as it was previously returned by the Getter functions
Name_Added (Name, customName) -- will return the name in the database aswell as the CustomName that was added

Name is always in the format Name-Realm for all player characters and Name for npc's as returned by UnitName()

  • Lib.RegisterCallback(self, "eventName"[, method, [arg]])
  • Lib.UnregisterCallback(self, "eventname")
  • Lib.UnregisterAllCallbacks(self)

    Example:

    Lib:RegisterCallback("Name_Added", function(event, name, customName) print("Added: " .. name .. " is now Renamed to " .. customName) -- this will print whenever a new Name is added end)

    Check CustomNames.lua for more code examples.