WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Multiple config files (https://www.wowinterface.com/forums/showthread.php?t=51463)

10leej 01-08-15 12:33 PM

Multiple config files
 
Is it possible to use multiple config files in lua?

p3lim 01-08-15 01:24 PM

Yes.

10 char limit

Clamsoda 01-08-15 05:18 PM

All a file dedicated to configuration does it separate configurable settings from non-configurable/relevant code. The fact that the file is named config.lua or configuration.lua makes it no different than core.lua or MyAddon.lua or modules.lua etc.

Config1.lua:
Lua Code:
  1. local _, AddonTable = ...
  2.  
  3. AddonTable.Config1 = {
  4.     MyNeatSetting      = true,
  5.     MyNotSoNeatSetting = false
  6. }

Config2.lua
Lua Code:
  1. local _, AddonTable = ...
  2.  
  3. AddonTable.Config2 = {
  4.     DucksAreNeat = true,
  5.     CowsAreNeat  = false
  6. }

Understand that you can place anything you can place into a table, into the addon table. As such, you could split your configuration into 1000 files if you wanted to.

Fizzlemizz 01-08-15 06:06 PM

Now I'm confused.

Are we talking physical files on disk or multiple tables saved to a file?

I thought it was 1 global savedvariable file, one per character savedvariable file and each file could hold multiple config tables defined in the .TOC by sepreating their names with a comma.

If there is another option it would be interesting.

Phanx 01-08-15 11:04 PM

Quote:

Originally Posted by Fizzlemizz (Post 304569)
I thought it was 1 global savedvariable file, one per character savedvariable file and each file could hold multiple config tables defined in the .TOC by sepreating their names with a comma.

I did not get the impression from the OP's post that he is talking about saved variables, but you are correct -- you only get up to 1 global saved variables file + 1 character saved variables file for each addon.

Fizzlemizz 01-09-15 12:19 AM

Quote:

Originally Posted by Phanx (Post 304573)
I did not get the impression from the OP's post that he is talking about saved variables, but you are correct -- you only get up to 1 global saved variables file + 1 character saved variables file for each addon.

What other files can you create with WoW lua? I asume OP was talking about WoW lua and I know my knowledge is sketchy at best.

Seerah 01-09-15 01:56 AM

You can create any Lua or XML file to use with an addon. Until 10Leej comes back and clarifies what he means, he's either talking about saved variable files (though he did say "config") or he's talking about a file in his addon with which to program his settings/options panel (usually what "config" means and what many people name as config.lua in their addon).

10leej 01-09-15 11:48 PM

I want to actually use multiple config files on the same config table. So Clamsoda's response was what I was looking for pretty much.

And no I wasn't talking about saved variables. It's a realm I've never looked into.

Phanx 01-10-15 01:45 AM

Quote:

Originally Posted by 10leej (Post 304641)
I want to actually use multiple config files on the same config table. So Clamsoda's response was what I was looking for pretty much.

You can also use one "config" table and insert things into it from other files:

Code:

local _, ns = ...
ns.config = {
    this = 5,
    that = true,
    other = "thing",
}

Code:

local _, ns = ...
ns.config.x = 42
ns.config.y = 50



All times are GMT -6. The time now is 02:17 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI