remove colon syntax from oop

This commit is contained in:
Redo
2021-02-03 09:17:33 -06:00
parent 1b7915de4c
commit 941348002b
7 changed files with 124 additions and 120 deletions

View File

@@ -1,3 +1,4 @@
PortTypes = {
output = 0,
input = 1
@@ -16,7 +17,7 @@ Port = {
logictype = 1,
}
function Port:new(type, direction, position, causeupdate)
function Port.new(self, type, direction, position, causeupdate)
local o = {
type = type,
direction = direction,
@@ -31,35 +32,35 @@ function Port:new(type, direction, position, causeupdate)
return o
end
function Port:setstate(state)
function Port.setstate(self, state)
if state ~= self.state then
self.state = state
sim:queuegroup(self.group)
Simulation.queuegroup(sim, self.group)
end
end
function Port:setinputstate(state)
function Port.setinputstate(self, state)
if state ~= self.state then
self.state = state
if self.causeupdate then
sim:queuegate(self.gate)
Simulation.queuegate(sim, self.gate)
end
end
end
function Port:getconnectionposition()
function Port.getconnectionposition(self)
local offset = PortDirections[self.direction]
return {self.position[1]+offset[1], self.position[2]+offset[2], self.position[3]+offset[3]}
end
function Port:isrising()
function Port.isrising(self)
if self.group == nil then
return false
end
return self.group.state and (self.group.updatetick == sim.currenttick)
end
function Port:isfalling()
function Port.isfalling(self)
if self.group == nil then
return false
end