View Single Post
01-18-14, 12:08 PM   #7
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by LanceDH View Post
If it fine to have functions in the global space though?
For example my core file has a function to get your kills end some of the other files use that function.
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()
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote