Thread Tools Display Modes
Old 05-11-14, 05:15 PM   #21
A Chromatic Dragonspawn
Lombra's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 175
Originally Posted by Billtopia View Post
I see what you are saying there... that when defining a method it adds the 'self' variable in before the function variables... I was thinking that it did it by setting the first variable to self
Kindof, but it's important (or maybe not) to know that doing it that way is in no way magical. All that happens is that the first parameter is hidden and is called self. It doesn't have to refer to any frame at all. That's just the normal usage of it.

You could do this if you wanted:
local t = {}

function t:print()

function t.print(blarg) -- these functions work exactly the same, but this one doesn't use colon syntax, so the parameter must be explicitly defined

t:print() -- when calling a function using colon syntax it automatically passes the table in question as the first argument (and "hides" it), so this will print the table t

t.print("hax") -- regular syntax, no hidden arguments will be passed
Grab your sword and fight the Horde!
Lombra is offline   Reply With Quote
Old 05-11-14, 08:43 PM   #22
A Deviate Faerie Dragon
AddOn Compiler - Click to view compilations
Join Date: Dec 2013
Posts: 15
Thanks for the help I'm going to try reworking it and then I'll re-post if I have further isssue..
WhiteWolf87 is offline   Reply With Quote

Go BackWoWInterface » Developer Discussions » Lua/XML Help » Having trouble writing an addon

Thread Tools
Display Modes

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