fork/m-overlay

git clone https://git.julia.blue/fork/m-overlay

BkacjiosBugfixes + Dark Mode skina8034e9

v2.1.5
1.3 KiB76 linesraw
1require("extensions.table")
2
3local class = require("class")
4local object = require("class.object")
5
6io.stdout:setvbuf("no")
7
8local ENTITY = class.create("Entity")
9
10ENTITY:ACCESSOR("Enabled", "m_bEnabled", false)
11
12function ENTITY:Entity()
13	print("3 - Entity Constructor")
14end
15
16function ENTITY:Bar()
17	print("Hello world :)", self)
18end
19
20
21local ANIMAL = class.create("Animal", "Entity")
22
23function ANIMAL:Animal()
24	print("2 - Animal Constructor")
25	self:super()
26end
27
28function ANIMAL:DoThing()
29	print("6")
30end
31
32function ANIMAL:Think()
33	print("5", self)
34	self:DoThing() -- self will always be within the current class structure, so we go to line 26 and not line 48
35end
36
37
38local DOG = class.create("Dog", "Animal")
39
40function DOG:Dog()
41	print("1 - Dog Constructor")
42	self:super()
43end
44
45function DOG:Think()
46	print("4")
47	self:super("Think")
48end
49
50function DOG:DoThing()
51	print("7")
52	self:super("DoThing")
53end
54
55local obj = object.new("Dog")
56print("BEGINNING TEST", obj)
57obj:Bar()
58obj:Think()
59
60-- This creates an override at the object level, the class method will remain in tact
61obj.Think = function(this)
62	print("OVERRIDE")
63end
64
65obj:Think()
66
67-- Origial method can still be accessed via the class
68obj.class.Think(obj)
69
70print(obj:getClass())
71print(obj:getBaseClass())
72print(obj:instanceof("Entity"))
73print(obj:instanceof("Animal"))
74print(obj:instanceof("Dog"))
75
76print(obj:IsEnabled())