View Single Post
01-18-14, 12:18 PM   #8
LanceDH
A Cyclonian
 
LanceDH's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2012
Posts: 41
Originally Posted by Phanx View Post
Just put them in your addon's namespace. There's no reason to make everything a global. For example, if this is what you have now:

Code:
-- File A
function MyAddon_DoThings()
     print("Doing things.")
end

-- File B
MyAddon_DoThings()
Change it to:

Code:
-- File A
local ADDON, private = ...
function private:DoThings()
    print("Doing things without globals!")
end

-- File B
local ADDON, private = ...
private:DoThings()
On one end it's pretty genious that it's so simple, on the other end it's confusing as hell if you're used to other languages.
  Reply With Quote