-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathClass.lua
57 lines (46 loc) · 1.41 KB
/
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
-----------------------------------------
-- LOCALIZED GLOBAL VARIABLES
-----------------------------------------
local ZGV = _G.ZGV
local Class = {}
local STRICT_CLASSES = false
local allowed_nils
local zginherits, type = table.zginherits, type
-----------------------------------------
-- SAVED REFERENCES
-----------------------------------------
ZGV.Class = Class
-----------------------------------------
-- LOAD TIME SETUP
-----------------------------------------
if STRICT_CLASSES then
allowed_nils = {
["Guide.CurrentStepNum"]=1
}
end
-----------------------------------------
-- CLASS FUNCTIONS
-----------------------------------------
function Class:New(classType)
local class = {
class = classType
}
-- zginherits sets __UNSTRICT_CLASS to avoid biting its own tail.
if STRICT_CLASSES then
setmetatable( class, {
__index = function(tab,ind)
if not rawget( tab, "__UNSTRICT_CLASS" )
and type(ind) == "string"
and not allowed_nils[ classType.."."..ind ]
and ind:sub( 1,1 ):match("[A-Z]") then
error(("|c00cc00%s|r.|c00ff00%s|r not found"):format(classType,ind),2)
end
end
})
end
zginherits(class,Class) -- Don't use a metatable because might/probably setup a metatable elsewhere
return class
end
function Class:tostring()
return "Class: "..self.class
end