View Single Post
07-09-15, 02:15 PM   #2
Choonstertwo
A Chromatic Dragonspawn
 
Choonstertwo's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2011
Posts: 194
Each Lua file in your AddOn is called with two arguments: the AddOn's folder name and a table unique to the AddOn (often called namespace or ns). You can use the namespace table to store your AddOn's data, it's not accessible to any other AddOn (unless you make it so).

You can retrieve these values from the vararg in the main body of a Lua file. As an example:

File1.lua
lua Code:
  1. local addonName, ns = ...
  2.  
  3. ns.foo = "bar"

File2.lua
lua Code:
  1. local addonName, ns = ...
  2.  
  3. print(ns.foo)

Assuming File1.lua is loaded before File2.lua, the text bar will be printed in the chat frame.
  Reply With Quote