Thread: Global vars ?
View Single Post
11-01-14, 01:11 AM   #6
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
You're confusing methods with global variables. There's only one global here:

Code:
function TomTom:SetClosestWaypoint(...)
end

function TomTom:AddMFWaypoint(...)
end

function TomTom:AddZWaypoint(...)
end
Those method names -- AddMFWaypoint, AddZWaypoint, SetClosestWaypoint -- are not global variables. They're not local variables, either. They're table keys. Another way to visualize the situation would be like this:

Code:
TomTom = {
     SetClosestWaypoint = function(TomTom, ...)
     end,
     SetMFWaypoint = function(TomTom, ...)
     end,
     SetZWaypoint = function(TomTom, ...)
     end,
}
This falls under the heading of "your addon's main object" -- in TomTom's case, its main object is a table, and is accessible via the global variable "TomTom". Everything else in your addon -- methods, other frames, font strings, textures, etc. -- should either be strictly local (if you don't need to access them outside of the file where they're defined) or added to your main frame/table (the "frame.text" in my previous post) so it can be accessed through the main object.
__________________
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.

Last edited by Phanx : 11-01-14 at 01:14 AM.
  Reply With Quote