Thread Tools Display Modes
01-08-15, 12:33 PM   #1
10leej
A Molten Giant
 
10leej's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2011
Posts: 583
Multiple config files

Is it possible to use multiple config files in lua?
__________________
Tweets YouTube Website
  Reply With Quote
01-08-15, 01:24 PM   #2
p3lim
A Pyroguard Emberseer
 
p3lim's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 1,710
Yes.

10 char limit
  Reply With Quote
01-08-15, 05:18 PM   #3
Clamsoda
A Frostmaul Preserver
Join Date: Nov 2011
Posts: 269
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.
  Reply With Quote
01-08-15, 06:06 PM   #4
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,871
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.
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote
01-08-15, 11:04 PM   #5
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by Fizzlemizz View Post
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.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
01-09-15, 12:19 AM   #6
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,871
Originally Posted by Phanx View Post
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.
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote
01-09-15, 01:56 AM   #7
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
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).
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
01-09-15, 11:48 PM   #8
10leej
A Molten Giant
 
10leej's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2011
Posts: 583
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.
__________________
Tweets YouTube Website
  Reply With Quote
01-10-15, 01:45 AM   #9
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by 10leej View Post
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
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Multiple config files

Thread Tools
Display Modes

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