Skip to content

Latest commit

 

History

51 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

Class Lua License: MIT

A high-performance class manager with annotations.

Extending a class

---@class Object: Class
local Object = class:extend()

Templates

Templates represent the data structure of class objects. Classes are uninstantiable if no template is defined.

---@param x number
---@param y number
---@param z number
function Object:template(x, y, z)

  self.position = vector(x, y, z)
  self.orientation = quaterion(1, 0, 0, 0)

end

Extended templates

If a class inherits from another, templates can be written like this:

---@class Sphere: Object
local Sphere = Object:extend()

function Sphere:template()

  Object.template(self)
  self.radius = 5

end

Merged classes

Merged classes are classes that inherit from multiple other classes. If class A and class B share field X, the new class obtains field X of class B, if it is the last passed class.

---@class Engine: Object
local Engine = Object:extend()
-- ...

---@class Wheels: Object
local Wheels = Object:extend()
-- ...

---@class Car: Engine, Wheels
local Car = class.merge(Engine, Wheels)

function Car:template()

  Object.template(self)
  Engine.template(self)
  Wheels.template(self)

end

Instantiating

local car = Car:new()

About

A simple lua class manager.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages