View Single Post
10-21-15, 01:53 PM   #14
lightspark
A Rage Talon Dragon Guard
 
lightspark's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2012
Posts: 341
Lua Code:
  1. local CONFIG = CopyTable(D, TEST_CONFIG)
  2. ns.CONFIG = CONFIG -- makes this table available throughout addon
  3.  
  4. local playerName, playerFaction, playerRealm = UnitName("player"), UnitFactionGroup("player"), GetRealmName()
  5.  
  6. if not CONFIG["money_related_stuff"][playerRealm] then
  7.     CONFIG["money_related_stuff"][playerRealm] = {} -- creates a table if it doesn't exist
  8. end
  9.  
  10. local realmData = CONFIG["money_related_stuff"][playerRealm] -- just an alias
  11. ns.realmData = realmData
  12.  
  13. if not realmData[playerFaction] then
  14.     realmData[playerFaction] = {} -- creates a table if it doesn't exist
  15. end
  16.  
  17. local factionData = realmData[playerFaction]
  18. ns.factionData = factionData
  19.  
  20. if not factionData[playerName] then
  21.     factionData[playerName] = {} -- creates a table if it doesn't exist
  22. end
  23.  
  24. ns.playerData = factionData[playerName]
  25.  
  26. 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.
__________________
  Reply With Quote