Game Development Reference
In-Depth Information
Note
Semicolons are optional.
A table can be turned into a template to generate instances of it, in other words, a class.
Methods of the instance of the table must be accessed with a : notation:
myTableClassObject:myMethod()
From inside the method, you refer to the instance of the class as self :
self.myProperty = 1
self:myOtherMethod()
Alternatively, you can call the template's method with a dot notation, passing the instance
of that template to it as the first parameter:
myTableClassObject.myMethod(myTableClassObject)
I admit, it's weird, but it can be useful at times as pretty much every method you write in
Lua can be made available for other parts of your code—sort of the way static methods
are used in traditional OOP languages.
Search WWH ::




Custom Search