Originally Posted by Vladinator
A tip, if you put for example this on top of the lua files in your addon:
local addonName, addonTable = ...
The addonName will be the addon name (folder) and addonTable is a table shared by the entire addon locally. Hence if you got several files loading and you in the first one define:
function addonTable:Test() end
Then this function can be called by the later lua files by doing addonTable:Test() of course. Note that this may strain performance if you call a function from a table many times at once, hence this is a bit better (I heard, not tested):
local Test = addonTable.Test
Now calling Test() a bunch of times should be as if the function was created using "function Test() end"
I am sure some of my friends will correct me if I am wrong. :P
|
I pretty much do this everytime I feel I need to have several files..
File 1
lua Code:
local ADDON, ns = ...
local settings = {}
settings.color = {
-- stuff here
}
ns.settings = settings
File 2
lua Code:
local ADDON, ns = ...
local settings = ns.settings
-- now I can use the settings (colors) here
However, he asked to have the function available in another addon, not in another file.
I would really like to know, what you mean by "engine" and how you go about it.
I had a similar problem some time ago (create one look throughout all my addons) and I go the way to create one addon which provides some functions to create borders and backgrounds and stuff and made the functions global.