49
edits
No edit summary |
m (→Parameters) |
||
| Line 12: | Line 12: | ||
function MyAddOn_OnLoad() | function MyAddOn_OnLoad() | ||
print("MyAddOn is started") | print("MyAddOn is started") | ||
end | |||
== Parameters == | |||
In WoW Lua files have file parameters passed when the Lua file is loaded, which can be accessed via standard Lua ellipses. | |||
* addonName (string) - the addon name that is the addon's folder name in the 'Interface\AddOns' WoW folder | |||
* addonTable (table) - a singular pre-created Lua table that is for the addon's private use, starts empty, not referenced in the global table, and is the same table passed to all Lua files loaded during the AddOn's load under the AddOn's folder, or referenced outside the folder during that AddOns load. | |||
==== Example ==== | |||
For the 'MyAddOn' AddOn in the 'Interface\AddOns\MyAddOn' folder: | |||
MyAddOn TOC file | |||
myaddon1.lua | |||
myaddon2.lua | |||
myaddon.xml | |||
Lua file 1 for MyAddOn | |||
local addonName, addonTable = ... | |||
addonTable.banana = "apple" | |||
Lua file 2 for MyAddOn | |||
local addonName, addonTable = ... | |||
function MyAddOn_OnLoad() | |||
print("MyAddOn's name is " .. addonName) -- prints 'MyAddOn' | |||
print("MyAddOn's addon table banana var is " .. addonTable.banana) -- prints 'apple' | |||
end | end | ||