View Single Post
01-20-09, 06:38 PM   #5
Tuhljin
A Flamescale Wyrmkin
 
Tuhljin's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2008
Posts: 106
"self" is implied as the first argument if the function is defined like so:
Code:
function MyTable:PrintNameAndNumber(num)
  print(self.name, num)
end
Notice the colon (":").

It's also implied when used in the XML like this:
Code:
<OnEnter>
  GameTooltip:SetOwner(self, "ANCHOR_RIGHT");
  GameTooltip:AddLine(self.date, 1, 1, 1);
  GameTooltip:Show();
</OnEnter>
However, in a case like the below, self isn't implied so you'd have to put it in yourself:
Code:
MyFrame:RegisterEvent("ZONE_CHANGED_NEW_AREA")
MyFrame:SetScript("OnEvent", function(self)
  print(self.name)
end)
See: http://lua-users.org/wiki/ObjectOrientationTutorial
  Reply With Quote