View Single Post
01-14-15, 05:07 AM   #63
Ekaterina
A Theradrim Guardian
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 65
Ah...not quite. You're doing a couple of things here that may cause things to act in a way you don't expect them to.

Lua Code:
  1. local addon, ns = ...
  2. local name, ns = ...
  3. local cfg = CreateFrame('Frame')
  4. local _, class = UnitClass('player')
  5. local cfg = {}

What you are doing here is creating two variables (addon and name) that hold the same information (the Addon Name). Then with cfg, first you are creating it as a frame, then re-defining it as a table.

Try this.
Config file:

Lua Code:
  1. local addonName, ns = ...
  2. local _, class = UnitClass('player')
  3. local mediaPath = "Interface\\AddOns\\oUF_Kygo\\Media\\"
  4.  
  5. local cfg = {
  6.    texture = mediaPath.."normTex2.tga",
  7.    bgFile = mediaPath.."backdrop",
  8.    edgeFile = mediaPath.."backdrop_edge",
  9.    Icon = mediaPath.."Neal_border",
  10.    CPoint = mediaPath.."NCPoint",
  11.    font = "Interface\\AddOns\\oUF_Kygo\\Media\\Fonts\\ExpresswayRg.ttf",
  12.    fontsize = 10,
  13.    fontflag = "OUTLINE, MONOCHROME", -- Font flags should be in capitals and separated by a comma
  14.  
  15.    ClassPowerText = {
  16.         Priest = {26/255, 160/255, 255/255}, --Mana
  17.         Shaman = {26/255, 160/255, 255/255}, -- Mana
  18.         Warlock = {26/255, 160/255, 255/255}, -- Mana
  19.         Paladin = {26/255, 160/255, 255/255}, -- Mana
  20.         MonkMistweaver = {26/255, 160/255, 255/255}, --How to check if monk is MW or not status: Unknown atm
  21.         Mage = {26/255, 160/255, 255/255}, -- Mana
  22.         DruidRestoBalance = {26/255, 160/255, 255/255}, -- Mana
  23.         Warrior = {255/255, 26/255, 48/255}, -- Rage
  24.         DruidGuardian = {255/255, 26/255, 48/255}, --Rage
  25.         Hunter = {255/255, 128/255, 64/255}, -- Focus
  26.         Rogue = {255/255, 225/255, 26/255}, -- Energy
  27.         DruidFeral = {255/255, 225/255, 26/255}, -- Energy
  28.         DeathKnight = {0.00, 0.82, 1.00}, -- Runic Power
  29.     }
  30.  
  31. ns.cfg = cfg

Then at the top of the files where you need to access this information

Lua Code:
  1. local addonName, ns = ...
  2. local cfg = ns.cfg -- if you want to save yourself some typing and reference the table as cfg.[i]KeyName[/i]. Otherwise you could just access the values using ns.cfg.[i]keyName[/i]

powerText:SetFont(cfg.font, cfg.fontsize, cfg.fontflag) would then work. It wasn't previously because the way you had the flags set.

The way I think of it is :
Config File
  1. Get Access to the table accessible to the whole addon - (done by assigning it to 'ns')
  2. Assemble the information I want to put into the table
  3. Add the information to the table (ns.cfg = cfg)

Then in each other file you need to get that information.
  1. Get access to the table (assigning it to 'ns' again)
  2. [Optional] Assign the ns.cfg part of the table to a new variable to make typing out table references easier.
  3. Use or change the information as required.

That is just the way I think of it for it to make sense to me and it is a very simplistic view of it. Phanx and others could probably go into more detail for you if you wished.
  Reply With Quote