Hey folks,
I'm fairly new to lua and WoW addon development in general so hopefully this is a simple issue.
I have the following code as the only lua file loaded by my addon.
Code:
local REGION_NAMES = {
[1] = 'us',
[2] = 'kr',
[3] = 'eu',
[4] = 'tw',
[5] = 'cn'
}
local DELIMITER = '::'
local MINOR = 95
local function getWardrobe()
local wardrobe = {}
for colType = 1, Enum.TransmogCollectionTypeMeta.NumValues do
local app = C_TransmogCollection.GetCategoryAppearances(colType)
for k, o in pairs(app) do
if o.isCollected and not o.isHideVisual then
for i, source in ipairs(C_TransmogCollection.GetAppearanceSources(o.visualID)) do
local _, _, _, _, _, link = C_TransmogCollection.GetAppearanceSourceInfo(source.sourceID)
local itemID = GetItemInfoInstant(link)
local str = itemID .. ':' .. colType
tinsert(wardrobe, str)
end
end
end
end
return wardrobe
end
local function saveWardrobe()
local region = REGION_NAMES[GetCurrentRegion()]
local realm = GetRealmName()
local character = UnitName('player')
local wardrobe = getWardrobe()
local hash = region .. ':' .. realm .. ':'.. character
ArmoryHubExportData = ArmoryHubExportData and wipe(ArmoryHubExportData) or {}
ArmoryHubExportData.version = MINOR
ArmoryHubExportData[hash] = ArmoryHubExportData[hash] or {}
ArmoryHubExportData[hash].region = region
ArmoryHubExportData[hash].realm = realm
ArmoryHubExportData[hash].character = character
ArmoryHubExportData[hash].wardrobe = wardrobe
print('ArmoryHub: Saved wardrobe with ' .. table.getn(ArmoryHubExportData[hash].wardrobe) .. ' items')
end
local frame = CreateFrame('FRAME');
frame:RegisterEvent('ADDON_LOADED');
frame:RegisterEvent('PLAYER_LOGOUT');
function frame:OnEvent(event, arg1)
if event == 'PLAYER_LOGOUT' then
saveWardrobe()
end
end
frame:SetScript('OnEvent', frame.OnEvent);
SLASH_ARMORYHUB1 = '/ah';
SlashCmdList['ARMORYHUB'] = function(msg)
saveWardrobe()
end
In-game, the output says something like "ArmoryHub: Saved wardrobe with 5670 items".
However, when I open the SavedVariables file from my local disk, I see:
Code:
ArmoryHubExportData = {
["version"] = 95,
["us:Area 52:Dyspeptic"] = {
["wardrobe"] = {
},
["character"] = "Dyspeptic",
["realm"] = "Area 52",
["region"] = "us",
},
}
I don't know why the "wardrobe" field is not written out. I tried creating a simple table with a few entries and it writes it without issue. Is it a size issue? Is it trying to write too much at once?