View Single Post
02-17-14, 01:23 PM   #3
Rainrider
A Firelord
AddOn Author - Click to view addons
Join Date: Nov 2008
Posts: 454
A better way to expose your addon "local" variables to other addons is by putting them inside a global table, named after your addon's name. That way you don't have to take care that every variable is uniquely named in the global scope, just the addon name should be (you can't have two different addons with the same name). The other advantage is that by doing this one has to access your variables by addon.variable which implies that the call is intended and not accidental (i.e. not a mistyped variable that happens to be what you named it). Also this way you add a single entry to the global scope and "hide" the rest into it, instead of the clutter it would be if you added all the rest separately. One could also make a local reference to your addon table in their code and have a slightly faster access to the variables inside it.

Keep in mind that WoW's frames are just tables to Lua. In your code define your frames locally (for access speed) and give them global names, if you need that. If also may be a better idea to define functions that can access your local variables and make those available to other addons, instead of giving direct access to the variables. That way you can detect access and do additional stuff if you need to.
  Reply With Quote