ESOUI - View Single Post - Where to put functions?
View Single Post
11/27/18, 10:50 AM   #9
Baertram's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 3,287
Local variables (a table is a variable too at the end) can be accesed only in this particular file where you write it into.
Global variables can be access in your different addon files (like in a lua + a xml file of your addon) AND in other addons as well.

From the example below:
If you e.g. use the addon ZGOO and do something like /zgoo GlobalTableWithUniqueName into the chat you'll see the contents of this table in a an UI.
It will show you the variable x with value 10.

If you do /zgoo MyAddon it won't work as it is local though! But as you have defined MyAddon to be a local variable poinetr to the global variable GlobalTableWithUniqueName , everything you have added to MyAddon will be in GlobalTableWithUniqueName as well.

So if you go back to 1) you'll also notice that the added function MyAddon.Add will be shown as

If you use this into the chat:
/script GlobalTableWithUniqueName.Add(20) it will output the value x + y (20) = 30 into the chat.
  Reply With Quote