I'm trying to make a custom title that is local so that only I can see. I have the .LUA file but I'm not sure what to change in order to get it to work. If anybody can tell me what to change in this fie I would be forever grateful.
--[[
Author: Ayantir
Filename: LibCustomTitles.lua
Version: 10
]]--
--[[
This software is under : CreativeCommons CC BY-NC-SA 4.0
Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0)
You are free to:
Share — copy and redistribute the material in any medium or format
Adapt — remix, transform, and build upon the material
The licensor cannot revoke these freedoms as long as you follow the license terms.
Under the following terms:
Attribution — You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
NonCommercial — You may not use the material for commercial purposes.
ShareAlike — If you remix, transform, or build upon the material, you must distribute your contributions under the same license as the original.
No additional restrictions — You may not apply legal terms or technological measures that legally restrict others from doing anything the license permits.
Please read full licence at :
http://creativecommons.org/licenses/by-nc-sa/4.0/legalcode
]]--
--[[
Changed/Additions
- Moved table with custom titles into seperate section with register function
- Use achievementId instead of raw title name to make it work with all languages
- Make it default to english custom title if nothing is specified for the user's language
- (Added the option to make a title hidden from the user itself) *mhuahahahaha*
]]--
local libLoaded
local LIB_NAME, VERSION = "LibCustomTitlesRN", 11
local LibCustomTitles, oldminor = LibStub:NewLibrary(LIB_NAME, VERSION)
if not LibCustomTitles then return end
local customTitles = {}
function LibCustomTitles:RegisterTitle(displayName, charName, override, title, hidden)
if hidden and (displayName == GetUnitDisplayName("player") or charName == GetUnitName("player")) then
return
end
if type(override) == "boolean" then --override all titles
override = "-ALL-"
elseif type(override) == "number" then --get override title from achievementId
local hasRewardOfType, titleName = GetAchievementRewardTitle(override)
if hasRewardOfType and titleName then
override = titleName
end
end
if not customTitles[displayName] then
customTitles[displayName] = {}
end
if charName then
if not customTitles[displayName][charName] then
customTitles[displayName][charName] = {}
end
customTitles[displayName][charName][override] = title
else
customTitles[displayName][override] = title
end
end
function LibCustomTitles:Init()
LibCustomTitles:RegisterTitle("@cmetzger93", nil, 1391, {en = "Cat-Healer", de = "Katzenheiler"})
LibCustomTitles:RegisterTitle("@Rogue78", nil, 92, {en = "Plopkoek"})
LibCustomTitles:RegisterTitle("@Tino93", nil, 1391, {en = "Procerer", de = "Der Procerer"})
LibCustomTitles:RegisterTitle("@DschiPeunt", nil, 1391, {en = "Burning Burrito", de = "Brennender Burrito"})
LibCustomTitles:RegisterTitle("@Baumlaus", nil, 92, {en = "Master of Roleplay", de = "Meister des Rollenspiels"})
LibCustomTitles:RegisterTitle("@Vuurhart", nil, 94, {en = "Vanguard"})
LibCustomTitles:RegisterTitle("@Vuurhart", nil, 93, {en = "Vyrelord"})
LibCustomTitles:RegisterTitle("@Woeler", nil, 1391, {en = "The Almighty God", de = "Der allmächtige Gott"})
LibCustomTitles:RegisterTitle("@Kruspinator", nil, 1391, {en = "John Cena"})
LibCustomTitles:RegisterTitle("@Kruspinator", nil, 92, {en = "John Cena"})
LibCustomTitles:RegisterTitle("@GeneralPardon", nil, 702, {en = "Fang of Lorkhaj"})
LibCustomTitles:RegisterTitle("@DeCarn", nil, 1391, {en = "Nerevarine"})
LibCustomTitles:RegisterTitle("@Kyoma", nil, 494, {en = "Master Hoarder"})
LibCustomTitles:RegisterTitle("@Stillian", nil, 1391, {en = "Fiery Soul"})
LibCustomTitles:RegisterTitle("@Zantaria", nil, 627, {en = "Exploiter"})
LibCustomTitles:RegisterTitle("@BlueMoon270", nil, 1391, {en = "Xanti's Property"}, true)
LibCustomTitles:RegisterTitle("@KisoValley", nil, 92, {en = "Decent."})
local CT_NO_TITLE = 0
local CT_TITLE_ACCOUNT = 1
local CT_TITLE_CHARACTER = 2
local lang = GetCVar("Language.2")
local function GetCustomTitleType(displayName, unitName)
if customTitles[displayName] then
if customTitles[displayName][unitName] then
return CT_TITLE_CHARACTER
end
return CT_TITLE_ACCOUNT
end
return CT_NO_TITLE
end
local function GetCustomTitle(originalTitle, customTitle)
if customTitle["-ALL-"] then
return customTitle["-ALL-"][lang] or customTitle["-ALL-"]["en"]
end
if customTitle[originalTitle] then
return customTitle[originalTitle][lang] or customTitle[originalTitle]["en"]
end
end
local function GetModifiedTitle(originalTitle, displayName, unitName, registerType)
if registerType == CT_TITLE_CHARACTER then
return GetCustomTitle(originalTitle, customTitles[displayName][unitName]) or originalTitle
elseif registerType == CT_TITLE_ACCOUNT then
return GetCustomTitle(originalTitle, customTitles[displayName]) or originalTitle
end
return originalTitle
end
local GetUnitTitle_original = GetUnitTitle
GetUnitTitle = function(unitTag)
local unitTitleOriginal = GetUnitTitle_original(unitTag)
local unitDisplayName = GetUnitDisplayName(unitTag)
local unitCharacterName = GetUnitName(unitTag)
local registerType = GetCustomTitleType(unitDisplayName, unitCharacterName)
if registerType ~= CT_NO_TITLE then
return GetModifiedTitle(unitTitleOriginal, unitDisplayName, unitCharacterName, registerType)
end
return unitTitleOriginal
end
local GetTitle_original = GetTitle
GetTitle = function(index)
local titleOriginal = GetTitle_original(index)
local displayName = GetDisplayName()
local characterName = GetUnitName("player")
local registerType = GetCustomTitleType(displayName, characterName)
if registerType ~= CT_NO_TITLE then
return GetModifiedTitle(titleOriginal, displayName, characterName, registerType)
end
return titleOriginal
end
end
local function OnAddonLoaded()
if not libLoaded then
libLoaded = true
local LCC = LibStub('LibCustomTitlesRN')
LCC:Init()
EVENT_MANAGER:UnregisterForEvent(LIB_NAME, EVENT_ADD_ON_LOADED)
end
end
EVENT_MANAGER:RegisterForEvent(LIB_NAME, EVENT_ADD_ON_LOADED, OnAddonLoaded)