Originally Posted by Tar000un
I also saw with a :, instead the dot.
|
In Lua, using the colon ( : ) instead of the dot makes a variable "self" available in the function.
For example:
Lua Code:
local foo = {}
foo.val = 1
function foo:bar()
d(self.val) --Prints 1
end
When you fully define the tables, it's not as critical, since you can simply use the table name instead:
Lua Code:
function foo.bar()
d(foo.val) --Prints 1
end
Where it's most useful is object-oriented programming style, where you have the same function with different objects and need self to differentiate between them.