Quantcast
WoWInterface - View Single Post - Would it be possible to get value of element during table construction?
View Single Post
07-31-16, 06:48 AM   #3
Banknorris
A Chromatic Dragonspawn
 
Banknorris's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2014
Posts: 153
Working on the previous solution, maybe:
Lua Code:
  1. G["castbar"] = {
  2.     ["player"] = {
  3.         ["width"] = 350,
  4.         ["height"] = 35,
  5.         ["point"] = {"CENTER", UIParent, "CENTER", 250, -200},
  6.         ["iconSize"] = "height",
  7.         ["spacing"] = 2,
  8.     },
  9. }

then when using the configuration do something like:

Lua Code:
  1. local height = G["castbar"]["player"]["height"]
  2. local iconSize = G["castbar"]["player"]["iconSize"]
  3. if iconSize=="height" then
  4.         iconSize = height
  5. end
  6. castbar:SetHeight(height)
  7. icon:SetSize(iconSize,iconSize)
If in the future you decide to set iconSize to lets say 50, you just need to change the configuration value from "height" to 50, the code the uses the configuration will still work.
__________________
"In this world nothing can be said to be certain, except that fractional reserve banking is a Ponzi scheme and that you won't believe it." - Mandrill

Last edited by Banknorris : 07-31-16 at 06:59 AM.
  Reply With Quote