View Single Post
04/26/17, 03:43 AM   #7
Dolgubon
 
Dolgubon's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2016
Posts: 409
What Votan means is that when you declare the variable (ADDON_NAME = "Test") you should put local first (local ADDON_NAME = "Test")

That makes it so that ADDON_NAME is only available to code within that file. So if some other addon calls ADDON_NAME, then it will be nil. self.variable name is not generally defined. If you have a table, the table might have a field called variableName, and then it would be defined, but in all other cases it will not be defined. (and in fact, if self is not a table you will get a lua error - 'Attempt to index a non table variable')


You also cannot do functionName.variableName. Local variables within a function are unavailable outside of it, and global variables within a function will be available anywhere simply with variableName.

I would suggest reading some lua tutorials about scope.
  Reply With Quote