-
Notifications
You must be signed in to change notification settings - Fork 0
/
tbone-class.lua
57 lines (47 loc) · 979 Bytes
/
tbone-class.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
-- This software is released under the MIT License. See LICENSE.txt for details.
--T-Bone Class version 0.2
local class = {}
class.__index=class
class._bobbyTables={}
function class:init() end
function class:_init() self:init() end
function class:newInstance()
local o = {}
setmetatable(o,self)
if self._bobbyTables then
for i=1,#self._bobbyTables do
o[self._bobbyTables[i]]={}
end
end
o:_init()
return o
end
function newClass(tables)
local o = {}
setmetatable(o,class)
o.__index=o
o._bobbyTables=tables
return o
end
function class:addTable(tab)
table.insert(self._bobbyTables,tab)
end
function class:newSubClass(tables)
local o = {}
setmetatable(o,self)
o.__index=o
if tables then
if not o._bobbyTables then
o._bobbyTables=tables
else
local a = #o._bobbyTables
for i = a,a + #tables do
o._bobbyTables[i]=tables[i-a]
end
end
end
return o
end
function newSubClass(mother,tables)
return mother:newSubClass(tables)
end