Thread Tools Display Modes
10-09-11, 02:50 AM   #1
Animor
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Mar 2011
Posts: 136
Understanding an lua line

Hello,

I'm looking at an addon called IME to understand how some things are done.
The first line in the LUA file of the addon is:
Code:
local addonName, IMETable = ...
After that, the addon uses those 2 variables.
I don't understand how this thing works. Where does the vararg string come from? the toc file perhaps?

IME Addon link:
http://www.wowinterface.com/download...hodEditor.html

Thanks in advance!

Last edited by Animor : 10-09-11 at 02:52 AM.
  Reply With Quote
10-09-11, 02:58 AM   #2
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,930
The 2nd variable is an addon wide variable that allows you to use the same data across multple files.

EG.

File1
local addonTable, addonData = ...
addonData.variable1 = 10

File2
local addonTable,addonData = ...
print(addonData.variable1)


As long as the setting of th variable happns before using it you can pass the data across your files. It's a new feature added in 3.3 if I remember rightly.

This way you can have local variables that don't force you to have one big file for your addon. You can now spread your addons functionality across multiple files.

This also allows you to put identical functionality from multiple addons in a single file and just use that file in all your addons.

Hope that helps you somewhat but like I did you might find it easier to understand if you try it out with a simple addon.
__________________


Characters:
Gwynedda - 70 - Demon Warlock
Galaviel - 65 - Resto Druid
Gamaliel - 61 - Disc Priest
Gwynytha - 60 - Survival Hunter
Lienae - 60 - Resto Shaman
Plus several others below level 60

Info Panel IDs : http://www.wowinterface.com/forums/s...818#post136818
  Reply With Quote
10-09-11, 02:59 AM   #3
Rilgamon
Premium Member
 
Rilgamon's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Sep 2009
Posts: 822
It comes from the loading process. Every file in your addon-loading process is passed the name and a table that is shared through all files.
So you can fill the table with data and functions in one file and use it in another.
__________________
The cataclysm broke the world ... and the pandas could not fix it!
  Reply With Quote
10-09-11, 04:13 AM   #4
Animor
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Mar 2011
Posts: 136
Thank you both for your answers!
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Understanding an lua line


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off