Thread Tools Display Modes
05-11-14, 05:15 PM   #21
Lombra
A Molten Giant
 
Lombra's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 554
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:
Code:
local t = {}

function t:print()
	print(self)
end

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
	print(blarg)
end

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!
  Reply With Quote
05-11-14, 08:43 PM   #22
WhiteWolf87
A Deviate Faerie Dragon
 
WhiteWolf87's Avatar
AddOn Compiler - Click to view compilations
Join Date: Dec 2013
Posts: 16
Thanks for the help I'm going to try reworking it and then I'll re-post if I have further isssue..
  Reply With Quote

WoWInterface » 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