Class-like tables for Lua.
- Lua 76.9%
- Python 23.1%
| .gitattributes | Script to generate rockspec file (WIP) | |
| .gitignore | Exclude .rockspec files from Git | |
| example.lua | Rework | |
| gen-rockspec.py | Find absolute root path in rockspec script | |
| LICENSE.txt | Add license & README texts | |
| lua-class.lua | Rework | |
| README.md | Add to TODO list | |
Lua Classes (OOP)
Description
Lua library that provides method for creating class-like tables that can be instantiated.
Notes
Code is AI assisted. AI was used for reference & code checking.
Usage
A single function, NewClass, is provided & can be called with the following parameters:
NewClass(): Creates a bare-minimum new class without inheritence.NewClass(template): Creates a new class fromtemplatewithout inheritence. Same asNewClass(nil, template).NewClass(parent, template): Creates a new class fromtemplatewith inheritence fromparent.
Parameter descriptions:
template: Table template of new class.parent: The parent class that is being inherited.
Construction calls the template.__init function property. If the template table does not have the
function, a default with only the self parameter will be added.
-- example of creating a class with a custom constructor
local MyClass = NewClass({
__init = function(self, name)
self.name = name
end
})
See example.
Licensing
Links
Git Repo Mirrors:
TODO
- Option to make function properties private.
- Mixin support.
- Support calling super-class functions.
- Support checking inheritence with
instanceoflike function.