Lua Code:
local CONFIG = CopyTable(D, TEST_CONFIG)
ns.CONFIG = CONFIG -- makes this table available throughout addon
local playerName, playerFaction, playerRealm = UnitName("player"), UnitFactionGroup("player"), GetRealmName()
if not CONFIG["money_related_stuff"][playerRealm] then
CONFIG["money_related_stuff"][playerRealm] = {} -- creates a table if it doesn't exist
end
local realmData = CONFIG["money_related_stuff"][playerRealm] -- just an alias
ns.realmData = realmData
if not realmData[playerFaction] then
realmData[playerFaction] = {} -- creates a table if it doesn't exist
end
local factionData = realmData[playerFaction]
ns.factionData = factionData
if not factionData[playerName] then
factionData[playerName] = {} -- creates a table if it doesn't exist
end
ns.playerData = factionData[playerName]
self:UnregisterEvent("ADDON_LOADED")
Drycoded, haven't tested it, but if there are typos, you can easily fix them.
One more warning, Pandarens are created as characters of "Neutral" faction, you'll need to handle it later on your own.