I see different people writing code in different ways.
Question 1:
Is there some purpose for doing the following
(other than to be able to juse a different name (c1) to call the function)? And when you do that in lua is c1 now a copy of the function or a reference to the original function?
Lua Code:
function myFunction()
...do stuff here
end
c1 = myFunction()
Question 2:
or how about this, what is the purpose of making the function local, if you then create c1 which gives global access to the function?
Lua Code:
local function myFunction()
...do stuff here
end
c1 = myFunction()
Question 3:
Does the reference/copy thing work the same way for libraries?
If I am using a library in several files of myAddon, which would be best:
I wanted to do this in each file so each file has its own local (?reference/copy?)..., but I wasn't sure if LIB is a copy of the library or a reference to the library. If its a copy that means I would be loading a copy of the library for every file I used it in.
Lua Code:
-- Do this in every file --
local LIB = LibStub:GetLibrary("SomeLibrary-1.0")
Or if it creates a copy, I assume I should only grab it once and just leave that reference global like this?
Lua Code:
-- Do this once --
MyAddon.LIB = LibStub:GetLibrary("SomeLibrary-1.0")
and use MyAddon.LIB in every file.