1notgate = class:new()
2
3function notgate:init(x, y, 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.state = "on"
12	self.initial = true
13end
14
15function notgate:link()
16	if #self.r > 3 then
17		for j, w in pairs(outputs) do
18			for i, v in pairs(objects[w]) do
19				if tonumber(self.r[4]) == v.cox and tonumber(self.r[5]) == v.coy then
20					v:addoutput(self)
21				end
22			end
23		end
24	end
25end
26
27function notgate:addoutput(a)
28	table.insert(self.outtable, a)
29end
30
31function notgate:update(dt)
32	if self.initial then
33		self.initial = false
34		if self.state == "on" then
35			self:input("off")
36		end
37	end
38end
39
40function notgate:draw()
41	love.graphics.setColor(255, 255, 255)
42
43	love.graphics.drawq(entitiesimg, entityquads[84].quad, math.floor((self.x-1-xscroll)*16*scale), ((self.y-1)*16-8)*scale, 0, scale, scale)
44end
45
46function notgate:out(t)
47	for i = 1, #self.outtable do
48		if self.outtable[i].input then
49			self.outtable[i]:input(t)
50		end
51	end
52end
53
54function notgate:input(t)
55	if t == "off" then
56		self.state = "on"
57	elseif t == "on" then
58		self.state = "off"
59	else
60		if self.state == "off" then
61			self.state = "on"
62		else
63			self.state = "off"
64		end
65	end
66	self:out(self.state)
67end