-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.lua
More file actions
112 lines (82 loc) · 1.65 KB
/
Copy pathtest.lua
File metadata and controls
112 lines (82 loc) · 1.65 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
require("index")
---@type ValueContainer
local values = ValueContainer()
---@class IEat:LuaType
local IEat = interface("IEat")
function IEat:Eat() end
---@class IShout:LuaType
local IShout = interface("IShout")
function IShout:Shout() end
---@class IHuman:IShout,IEat
local IHuman = interface("IHuman", IShout, IEat)
---@class IDog:IEat
local IDog = interface("IDog", IEat)
---@class A:IHuman
local A = class("A", nil, IHuman)
---@private
function A:ctor(name)
self.name = name
print(name)
end
function A:Eat(test)
print('man eat')
end
function A:Shout(test)
print('man shout')
end
---@class B:A
local B = class("B", A)
---@private
function B:ctor(name, age)
self.age = age
end
function B:Shout()
A.Shout(self)
print('B shout Again')
end
---@class Dog:IDog
local Dog = class("Dog", nil, IDog)
function Dog:ctor(human, name)
---@type IHuman
self.human = human
self.name = name
end
function Dog:Eat()
self.human:Eat()
print('dog eat')
self.human:Shout()
end
local human = B("wang", 15)
values:SetValueAs(human, IHuman)
values:SetValueAsFunc(IDog, Dog, IHuman)
---@type IDog
local dog = values:GetValue(IDog, "chun")
if dog then
dog:Eat()
end
try {
function()
print("1111")
error("big err")
end,
catch = function(e)
print(e .. " 222")
end,
finally = function()
print(3333)
end
}
print(0, os.time())
local finish
async(
function(sec)
await(LuaTask.Delay(sec))
print(1, os.time())
finish = true
end
)(2)
print(2, os.time())
while not finish do
os.execute("timeout /t " .. 1 .. " /nobreak")
Tools.UpdateTimers()
end