Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/superzazu/bluclass.lua
Lua OOP module with simple inheritance
https://github.com/superzazu/bluclass.lua
library oop oop-library
Last synced: about 2 months ago
JSON representation
Lua OOP module with simple inheritance
- Host: GitHub
- URL: https://github.com/superzazu/bluclass.lua
- Owner: superzazu
- Created: 2015-02-14T22:16:41.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2019-10-23T14:13:03.000Z (over 5 years ago)
- Last Synced: 2024-10-15T06:08:15.073Z (3 months ago)
- Topics: library, oop, oop-library
- Language: Lua
- Size: 6.84 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# bluclass
bluclass is a simple OOP module for Lua with basic inheritance.
## create a class
```lua
local bluclass = require 'bluclass'local vec2 = bluclass.class()
function vec2:init(x, y)
self.x = x
self.y = y
endmy_vec2 = vec2:new(23, 0)
print(my_vec2.x .. ',' .. my_vec2.y) -- '23,0'
```## simple inheritance
```lua
-- ...local vec3 = bluclass.class(vec2)
function vec3:init(x, y, z)
vec3.super.init(self, x, y)
self.z = z
end
function vec3:__tostring()
return self.x .. ',' .. self.y .. ',' .. self.z
endmy_vec3 = vec3:new(2, 0, -23)
print(my_vec3) -- '2,0,-23'
```