View Single Post
04-06-13, 06:21 AM   #2
Vlad
A Molten Giant
 
Vlad's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2005
Posts: 793
Just some code, maybe it helps:
Code:
local test = {} -- local example table
function test:Hello(word) print(word) end -- same as below
function test.Hello(self, word) print(word) end -- same as above
test:Hello("World") -- same as below
test.Hello(test, "World") -- same as above
These are all local because "test" is a local table.

If you want a local function you do local function onupdate(self, elapsed) ... end and now you can SetScript directly to "onupdate", and it is a local function.

The benefit of keeping everything to your "ns" for example is that all the files can access those functions trough the namespace.
__________________
Profile: Curse | Wowhead
  Reply With Quote