Back to Home

ESO Lua File v101042

ingame/namechange/namechange.lua

[◄ back to folders ]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
ZO_NameChange = ZO_Object:Subclass()
function ZO_NameChange:New()
    local obj = ZO_Object.New(self)
    obj:Initialize()
    return obj
end
function ZO_NameChange:Initialize()
    EVENT_MANAGER:RegisterForEvent("ZO_NameChange", EVENT_ADD_ON_LOADED, function(_, addOnName)
        if addOnName == "ZO_Ingame" then
            local sv = ZO_SavedVars:NewAccountWide("ZO_Ingame_SavedVariables", 1, "NameChange", {})
            --initialize all of the id to name mappings on the first login so if they buy a bunch of rename tokens we have all
            --the mappings built for each character
            for i = 1, GetNumCharacters() do
                local name, _, _, _, _, _, characterId = GetCharacterInfo(i)
                if sv[characterId] == nil then
                    --Strip the grammar markup
                    sv[characterId] = zo_strformat("<<1>>", name)
                end
            end
            local characterId = GetCurrentCharacterId()
            self.oldCharacterName = sv[characterId]
            self.newCharacterName = GetUnitName("player")
            sv[characterId] = self.newCharacterName
        end
    end)   
end
function ZO_NameChange:DidNameChange()
    return self.oldCharacterName ~= self.newCharacterName
end
function ZO_NameChange:GetOldCharacterName()
    return self.oldCharacterName
end
NAME_CHANGE = ZO_NameChange:New()