1walltimer = class:new()
2
3function walltimer:init(x, y, t, r)
4	self.x = x
5	self.y = y
6	self.cox = x
7	self.coy = y
8	self.r = r
9
10	self.outtable = {}
11	self.lighted = false
12	self.time = t
13	self.timer = self.time
14	self.quad = 1
15end
16
17function walltimer:link()
18	if #self.r > 3 then
19		for j, w in pairs(outputs) do
20			for i, v in pairs(objects[w]) do
21				if tonumber(self.r[5]) == v.cox and tonumber(self.r[6]) == v.coy then
22					v:addoutput(self)
23				end
24			end
25		end
26	end
27end
28
29function walltimer:addoutput(a)
30	table.insert(self.outtable, a)
31end
32
33function walltimer:update(dt)
34	if self.lighted then
35		self.quad = 2
36	elseif self.timer == self.time then
37		self.quad = 1
38	else
39		self.timer = self.timer + dt
40		local div = self.time/10
41		for i = 1, 9 do
42			if i == math.floor(self.timer*(1/div)) then
43				self.quad = i+1
44			end
45		end
46
47		if self.timer >= self.time then
48			self:out("off")
49			self.timer = self.time
50		end
51	end
52end
53
54function walltimer:draw()
55	love.graphics.setColor(255, 255, 255)
56
57	love.graphics.drawq(walltimerimg, walltimerquad[self.quad], math.floor((self.x-1-xscroll)*16*scale), ((self.y-1)*16-8)*scale, 0, scale, scale)
58end
59
60function walltimer:out(t)
61	for i = 1, #self.outtable do
62		if self.outtable[i].input then
63			self.outtable[i]:input(t)
64		end
65	end
66end
67
68function walltimer:input(t)
69	if t == "on" then
70		self:out("on")
71		self.timer = self.time
72		self.lighted = true
73		self.quad = 2
74	elseif t == "off" then
75		self.lighted = false
76		self.timer = 0
77	elseif t == "toggle" then
78		self.timer = 0
79		self.quad = 2
80		self.lighted = false
81		self:out("on")
82	end
83end