Edit: I overlooked your correction, but the rest of my post is still relevant so I'm leaving it as-is.
Originally Posted by Nibelheim
Top of first .Lua file
Lua Code:
local addon, ns = ... local Funs, Settings = unpack(select(2, ...))
|
I'm not sure what that's supposed to do... if that's the first file to load, the second argument passed to your file is an
empty table, so
unpacking it won't give you any values. Maybe you meant something like this?
First file:
Code:
local ADDON_NAME, ns = ...
local Functions, Settings = {}, {}
ns[1], ns[2] = Functions, Settings
Other files:
Code:
local ADDON_NAME, ns = ...
local Functions, Settings = ns[1], ns[2]
Functions.DoSomething = function()
-- do something
end
However, that's still a strange way to do it. There's no reason to use cryptic indices in your private table. Just use descriptive keys:
First file:
Code:
local ADDON_NAME, ns = ...
local Functions, Settings = {}, {}
ns.Functions, ns.Settings = Functions, Settings
Other files:
Code:
local ADDON_NAME, ns = ...
local Functions, Settings = ns.Functions, ns.Settings
Functions.DoSomething = function()
-- do something
end
In the same vein, I'm not sure why you'd store functions in their own sub-table. Why not just store them directly in the top-level table?