forked from KirbyKid256/mari0_aces
-
Notifications
You must be signed in to change notification settings - Fork 0
/
animationtrigger.lua
66 lines (54 loc) · 1.19 KB
/
animationtrigger.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
58
59
60
61
62
63
64
65
66
--input
animationtrigger = class:new()
function animationtrigger:init(x, y, r, id)
self.x = x
self.y = y
self.cox = x
self.coy = y
self.r = r
self.id = tostring(id)
end
function animationtrigger:link()
if #self.r > 2 then
for j, w in pairs(outputs) do
for i, v in pairs(objects[w]) do
if tonumber(self.r[5]) == v.cox and tonumber(self.r[6]) == v.coy then
v:addoutput(self)
end
end
end
end
end
function animationtrigger:input(t)
if t == "on" or t == "toggle" then
if not animationtriggerfuncs[self.id] then
return
end
for i = 1, #animationtriggerfuncs[self.id] do
animationtriggerfuncs[self.id][i]:trigger()
end
animationtriggerfuncs[self.id].triggered = true
end
end
--output
animationoutput = class:new()
function animationoutput:init(x, y, r, id)
self.x = x
self.y = y
self.cox = x
self.coy = y
self.r = r
self.id = tostring(id)
self.out = true
self.outtable = {}
end
function animationoutput:addoutput(a, t)
table.insert(self.outtable, {a, t})
end
function animationoutput:trigger(signal)
for i = 1, #self.outtable do
if self.outtable[i][1].input then
self.outtable[i][1]:input(signal or "toggle", self.outtable[i][2])
end
end
end