49
edits
(Created page with "{{uiaddon}} == Example ==") |
|||
| (5 intermediate revisions by 3 users not shown) | |||
| Line 1: | Line 1: | ||
{{uiaddon}} | {{uiaddon}}WoW AddOn [[Lua]] files are the code files for a WoW AddOn. This article describes the format for a WoW Lua file as a part of an WoW AddOn. | ||
WoW AddOn [[Lua]] files are the code files for a WoW AddOn. This article describes the format for a WoW Lua file as a part of an WoW AddOn. | |||
== References == | == References == | ||
| Line 14: | Line 13: | ||
print("MyAddOn is started") | print("MyAddOn is started") | ||
end | 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 | |||
<pre> | |||
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 | |||
</pre> | |||
== Guides == | == Guides == | ||
* [[Lua basics]] | * [[Lua basics]] | ||
[[Category:UI technical details]] | |||