Maintenance for the week of March 25:
• [COMPLETE] Xbox: NA and EU megaservers for patch maintenance – March 26, 6:00AM EDT (10:00 UTC) - 12:00PM EDT (16:00 UTC)
• [COMPLETE] PlayStation®: NA and EU megaservers for patch maintenance – March 26, 6:00AM EDT (10:00 UTC) - 12:00PM EDT (16:00 UTC)
• ESO Store and Account System for maintenance – March 28, 9:00AM EDT (13:00 UTC) - 12:00PM EDT (16:00 UTC)

Custom Title - Need Help from Smart Person

cmetzger93
cmetzger93
✭✭✭✭✭
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)
  • cmetzger93
    cmetzger93
    ✭✭✭✭✭
    @Ayantir Since this is your Mod I figured you would know better than anybody else. I would appreciate any help very much
  • Reorx_Holybeard
    Reorx_Holybeard
    ✭✭✭✭✭
    It depends exactly what you want to do. If you just want to give yourself a unique title you can do something like add the following line:
    LibCustomTitles:RegisterTitle("@YourAccountName", nil, true, {en = "Awesome Title Here."})
    

    If you're looking for something else just let us know what you are trying to do.
    Edited by Reorx_Holybeard on March 15, 2017 1:49AM
    Reorx Holybeard -- NA/PC
    Founder/Admin of www.uesp.net -- UESP ESO Guilds
    Creator of the "Best" ESO Build Editor
    I'm on a quest to build the world's toughest USB drive!
  • cmetzger93
    cmetzger93
    ✭✭✭✭✭
    Thank you for replying @Reorx_Holybeard That's exactly what I'm trying to do! Sorry I should've been more specific. I added that line of text to the LUA file where all the other lines were, and now I am getting the following error: user:/AddOns/RaidNotifier/libs/LibCustomTitles/LibCustomTitles.lua:87:) expected near ';'

    I appreciate the help so far. I am using the console UI if that matters.
  • Reorx_Holybeard
    Reorx_Holybeard
    ✭✭✭✭✭
    Remove all the semi-colons (";") from the lines after the account name string. Not sure where they come from (the forum software adds them for some reason):
    LibCustomTitles:RegisterTitle("..." , nil, true, {en = "Awesome Title Here."})
    
    Reorx Holybeard -- NA/PC
    Founder/Admin of www.uesp.net -- UESP ESO Guilds
    Creator of the "Best" ESO Build Editor
    I'm on a quest to build the world's toughest USB drive!
  • cmetzger93
    cmetzger93
    ✭✭✭✭✭
    Hey thank you so much @Reorx_Holybeard I got it working. You're the man!
  • smithist
    smithist
    ✭✭
    Love this thread! Takes me back to editing local assets for gear appearance in wow years ago. Good times
Sign In or Register to comment.