-
Notifications
You must be signed in to change notification settings - Fork 0
/
panel.lua
93 lines (79 loc) · 2.01 KB
/
panel.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
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
panel = class("panel")
function panel:init(x, y, t)
self.cox = x+1
self.coy = y+1
self.dir = "right"
self.out = false
self.input1state = "off"
--Input list
self.t = {unpack(t)}
table.remove(self.t, 1)
table.remove(self.t, 1)
--Dir
if #self.t > 0 then
self.dir = self.t[1]
table.remove(self.t, 1)
end
--Start white
if #self.t > 0 then
self.out = self.t[1] == "true"
table.remove(self.t, 1)
end
if self.dir == "up" then
self.dir = "top"
elseif self.dir == "down" then
self.dir = "bottom"
end
if self.dir == "left" then
self.r = 0
elseif self.dir == "top" then
self.r = math.pi/2
elseif self.dir == "right" then
self.r = math.pi
elseif self.dir == "bottom" then
self.r = math.pi*1.5
end
self:link()
self:updatestuff()
end
function panel:link()
while #self.t > 3 do
for j, w in pairs(outputs) do
for i, v in pairs(objects[w]) do
if tonumber(self.t[3]) == v.cox and tonumber(self.t[4]) == v.coy then
v:addoutput(self, self.t[2])
end
end
end
table.remove(self.t, 1)
table.remove(self.t, 1)
table.remove(self.t, 1)
table.remove(self.t, 1)
end
end
function panel:draw()
local quad = 2
if self.out then
quad = 1
end
love.graphics.drawq(panelimg, panelquad[quad], math.floor((self.cox-1-xscroll+.5)*16*scale), math.floor((self.coy-1-yscroll)*16*scale), self.r, scale, scale, 8, 8)
end
function panel:input(t, input)
if input == "power" then
if t == "on" and self.input1state == "off" then
self.out = true
elseif t == "off" and self.input1state == "on" then
self.out = false
elseif t == "toggle" then
self.out = not self.out
end
self.input1state = t
self:updatestuff()
end
end
function panel:updatestuff()
map[self.cox][self.coy]["portaloverride"][self.dir] = self.out
if self.out == false and tilequads[map[self.cox][self.coy][1]]:getproperty("portalable", self.cox, self.coy) == false then
checkportalremove(self.cox, self.coy)
end
end