Quantcast
WoWInterface - View Single Post - Would it be possible to get value of element during table construction?
View Single Post
07-31-16, 07:47 AM   #4
Layback_
An Onyxian Warder
Join Date: Feb 2016
Posts: 356
Originally Posted by Resike View Post
Why don't you just construct your icon like this?

Lua Code:
  1. local height = castbar:GetHeight()
  2. icon:SetSize(height, height)

Then you can ditch the variable too.
That's actually a good point!

But, if possible, I would like to keep them as a two separate variables.

For now, height and iconSize could be the same values, but for some cases I could give some variations on them.

Originally Posted by Banknorris View Post
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.
This could be the possible solution!

So... there is no such a straight-forward way to achieve this, right?
  Reply With Quote