Thread Tools Display Modes
Prev Previous Post   Next Post Next
11-12-16, 09:59 AM   #1
Krainz
A Wyrmkin Dreamwalker
Join Date: Oct 2016
Posts: 57
How do I reference an option from another file?

Setting up interface options panel for the addon.

My previous issues are all solved and I will share the addon with you guys once the interface options panel is done.

File 1:
Lua Code:
  1. local function getOptions()
  2.     if not options then
  3.         options = {
  4.             type = "group",
  5.             name = "ImmersiveHide",
  6.             args = {
  7.                 general = {
  8.                     order = 1,
  9.                     type = "group",
  10.                     name = "General Settings",
  11.                     get = optGetter,
  12.                     set = optSetter,
  13.                     args = {
  14.                         intro = {
  15.                             order = 1,
  16.                             type = "description",
  17.                             name = L["Lorem ipsum."],
  18.                         },
  19.                         alphadesc = {
  20.                             order = 2,
  21.                             type = "description",
  22.                             name = L["Lorem ipsum."],
  23.                         },
  24.                         TESTVARIABLE = {
  25.                             order = 2.2,
  26.                             type = "toggle",
  27.                             name = "TEST_VARIABLE",
  28.                             desc = L["Hello world will be shown."],
  29.                             get = function() return GetCVarBool("TESTVARIABLE") end,
  30.                             set = function(_, v) v = v and 1 or 0; SetCVar("TESTVARIABLE", v); end,
  31.                             width = "full",
  32.                         },
  33.                         alpha = {
  34.                             order = 3,
  35.                             name = L["Alpha"],
  36.                             desc = L["The transparency of stuff."],
  37.                             type = "range",
  38.                             min = 0, max = 1, bigStep = 0.01,
  39.                             isPercent = true,
  40.                         },
  41.                         fadealpha = {
  42.                             order = 4.1,
  43.                             type = "range",
  44.                             name = L["Faded Alpha"],
  45.                             desc = L["The transparency of stuff while faded."],
  46.                             get = function() return MIN_ALPHA end,
  47.                             set = function(_, v) SetCVar("MinAlpha", v); WORLD_MAP_MIN_ALPHA = v end,
  48.                             min = 0, max = 1, bigStep = 0.01,
  49.                             isPercent = true,
  50.                             disabled = function() return not GetCVarBool("Fade") end,
  51.                         },
  52.                     },
  53.                 },
  54.             },
  55.         }
  56.         for k,v in pairs(moduleOptions) do
  57.             options.args[k] = (type(v) == "function") and v() or v
  58.         end
  59.     end
  60.  
  61.     return options
  62. end

File 2:
Lua Code:
  1. local function HelloWorld()
  2.         if TESTVARIABLE = true then
  3.                 print("Hello World!")
  4.         end
  5. end
  6.  
  7. HelloWorld()
  8.  
  9. function addon:FadeIn()
  10.     UIFrameFadeIn(UIParent, 1, fadealpha, alpha);
  11. end;
  12.  
  13. function addon:FadeOut()
  14.     UIFrameFadeOut(UIParent, 1, alpha, fadealpha);
  15. end;


Variables from the first file that I want to use on the second file: TESTVARIABLE, alpha, fadealpha.

I've read plenty of addon files but they are all confusing to me because each addon creates the interface options panel in a different way and I have a really hard time identifying when they're using the configuration variables.
  Reply With Quote
 

WoWInterface » Developer Discussions » Lua/XML Help » How do I reference an option from another file?


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off