Skip to content

Use character ID in SavedVars #6

@inimicus

Description

@inimicus

Via Baertram:

Could you PLEASE change the SavedVariables from the very very old "character name" format, which is obviously not rename save, to the character ID settings!
Just renamed a few chars to welcome them to the family name and noticed that your addon is still using this outdated method of SavedVariable saving, unfortunately.

Old/outdated since years/not rename save - Character name:
ZO_SavedVars:New

New/rename save - Character ID:
ZO_SavedVars:NewCharacterId

Both got the same parameters so you just need to exchange the function name!

Example character name to ID migration code:

--Function to get all characters of the account, ID and name.
--Returns a table with 2 possible variants, either the character ID is key and the name is the value,
--or vice versa.
--Parameter boolean, keyIsCharName:
-->True: the key of the returned table is the character name
-->False: the key of the returned table is the unique cahracter ID (standard)
local function getCharactersOfAccount(keyIsCharName)
    keyIsCharName = keyIsCharName or false
    local charactersOfAccount
    --Check all the characters of the account
    for i = 1, GetNumCharacters() do
        local name, _, _, _, _, _, characterId = GetCharacterInfo(i)
        local charName = zo_strformat(SI_UNIT_NAME, name)
        if characterId ~= nil and charName ~= "" then
            if charactersOfAccount == nil then charactersOfAccount = {} end
            if keyIsCharName then
                charactersOfAccount[charName]   = characterId
            else
                charactersOfAccount[characterId]= charName
            end
        end
    end
    return charactersOfAccount
end

Metadata

Metadata

Assignees

Labels

in-progressWork has began on this issueplannedPlanned to be implemented

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions