1.
You can learn a bit more about ... here:
http://www.lua.org/pil/5.2.html
Essentially ... in a function definition represents a list of "all the rest" of the arguments that were supplied to that function. This allows a function to take in a variable number of arguments.
In the function body, you can use that ... in various ways. You can assign variables values out of it, as in "local a, b = ..." where a and b will receive the first two values in that list. You could also pull individual arguments out with select(), or loop over the list to get all the values with something like:
Lua Code:
for i = 1, select('#', ...) do
local val = select(i, ...)
-- do whatever with val
end
You can also turn it into a table with pack() or pass it to another function you want to call like "otherFunction(true, 1, ...)".
2.
Yes, you can put references to your function in a globally accessible place and they can be called by any other addon or another file in your own addon. Of course you need to make sure the functions and/or variable names in question are already defined before you put them in that table.
3.
In this case it's kind of up to you how you want to handle it, but basically there is no language feature to "skip" an argument. Rather you have to pass an argument and that function has to know how to deal with it. A good thing to pass might be nil, for instance, e.g. "MyFunction(nil, arg2, arg3)". But this means that MyFunction needs to know what to do if arg1 is "nil". So you'll have to code around that convention.
The basic idea is, you have to do all of this manually in your function, and there's no magic "blank" value you can use to skip an argument. Of course you can choose any value here: nil, false, -1, or any arbitrary value that MyFunction can check for to see if that argument was "skipped".
4.
This may be a little complicated but basically, it may help to understand that:
Lua Code:
SomeTable = {}
function SomeTable:SomeFunction()
print("Hello from " .. tostring(self))
end
SomeTable:SomeFunction()
is the same as
Lua Code:
SomeTable = {}
function SomeTable.SomeFunction(self)
print("Hello from " .. tostring(self))
end
SomeTable.SomeFunction(SomeTable)
which is also the same as
Lua Code:
SomeTable = {}
SomeTable.SomeFunction = function (self)
print("Hello from " .. tostring(self))
end
SomeTable.SomeFunction(SomeTable)
In both cases SomeFunction is just a function that's been assigned to a table key called SomeFunction, in a table called SomeTable.
The colon syntax is a syntactic shortcut that helps reduce clutter. What the colon in place of the period means depends on where it's used. In a function definition, it means the function will automatically assign the first argument it's given to the local variable "self". The manual version of this you can see in the second example.
When calling a function, the colon means to pass the table you're using to look up that function into the function call as the first argument. You can see the manual version of that in the second example too.
What that means is that when combined, using a : in both the definition and calling of a function means you never have to explicitly put self as the first parameter and never have to explicitly pass a value for self in when calling it. But under the hood, this is exactly what is happening.
Knowing that, all that's important for making your function visible to the outside world is making sure the table it's being assigned to is also accessible. If MyFrame is a global, then functions defined as MyFrame:SomeFunction or MyFrame.SomeFunction will all be globally accessible via MyFrame. So if that's what you want, all you need to do is make sure that MyFrame is a global already, or set explicitly to a global at some point. If MyFrame was local for example, you could do "_G.MyFrame = MyFrame" to make sure that other addons also have a globally accessible version of your table/frame.