Classy provides a C++ esque class and struct implementation for Lua, offering the following syntax:
Code: Select all
class "ExampleClass"
{
-- Class constructor
ExampleClass = function(self)
print "Hello, world!"
end;
-- Sample method
MyMethod = function(self)
print "ExampleClass MyMethod"
end;
}
struct "ExampleStruct"
{
-- Structs do not require constructors, but classes do.
-- If a struct inherits from a class, it will inherit its constructor.
x = 0;
y = 0;
z = 0;
}
This was actually a library I originally made around a year ago, but today I decided to re-write it from the ground up, which proved to be quite beneficial.