Hey there!
I'm working on my wardrobe manager mod, and any outfit that has been recently unlocked has an empty string for its name even though its label is "Outfit N." This breaks my code and prevents my LAM dropdowns from populating correctly.
I tried implementing a fix that renamed any unnamed outfits to the label (Outfit N) which got the job done, but the first time that code runs it throws the error listed below. Also below is the relevant code and a link to the project on Github.
Full code
Lua Code:
function LWM:Initialize()
LWM.vars = ZO_SavedVars:NewCharacterIdSettings("LWMVars", LWM.variableVersion, nil, LWM.default, GetWorldName())
self.inCombat = IsUnitInCombat("player")
self.inStealth = GetUnitStealthState("player")
for i=1,GetNumUnlockedOutfits() do
name = GetOutfitName(0, i)
-- TODO: This throws an error the first time it runs, fix it
if name == '' then
RenameOutfit(0, i, "Outfit " .. tostring(i))
end
self.allOutfits[i + OUTFIT_OFFSET] = name
end
...
end
Error:
Code:
user:/AddOns/LeonardosWardrobeManager/LeonardosWardrobeManager.lua:112: attempt to index a nil value
stack traceback:
user:/AddOns/LeonardosWardrobeManager/LeonardosWardrobeManager.lua:112: in function 'LeonardosWardrobeManager.OnOutfitRenamed'
|caaaaaa<Locals> event = 131661, response = 0, index = 0 </Locals>|r