make simulation non-global
This commit is contained in:
11
sim/port.lua
11
sim/port.lua
@@ -17,7 +17,7 @@ Port = {
|
||||
logictype = 1,
|
||||
}
|
||||
|
||||
function Port.new(self, type, direction, position, causeupdate)
|
||||
function Port.new(self, type, direction, position, causeupdate, sim)
|
||||
local o = {
|
||||
type = type,
|
||||
direction = direction,
|
||||
@@ -26,6 +26,7 @@ function Port.new(self, type, direction, position, causeupdate)
|
||||
state = false,
|
||||
gate = nil,
|
||||
group = nil,
|
||||
sim = sim,
|
||||
}
|
||||
setmetatable(o, self)
|
||||
self.__index = self
|
||||
@@ -35,7 +36,7 @@ end
|
||||
function Port.setstate(port, state)
|
||||
if state ~= port.state then
|
||||
port.state = state
|
||||
Simulation.queuegroup(sim, port.group)
|
||||
Simulation.queuegroup(port.sim, port.group)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -43,7 +44,7 @@ function Port.setinputstate(port, state)
|
||||
if state ~= port.state then
|
||||
port.state = state
|
||||
if port.causeupdate then
|
||||
Simulation.queuegate(sim, port.gate)
|
||||
Simulation.queuegate(port.sim, port.gate)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -57,14 +58,14 @@ function Port.isrising(self)
|
||||
if self.group == nil then
|
||||
return false
|
||||
end
|
||||
return self.group.state and (self.group.updatetick == sim.currenttick)
|
||||
return self.group.state and (self.group.updatetick == self.sim.currenttick)
|
||||
end
|
||||
|
||||
function Port.isfalling(self)
|
||||
if self.group == nil then
|
||||
return false
|
||||
end
|
||||
return self.group.state == false and (self.group.updatetick == sim.currenttick)
|
||||
return self.group.state == false and (self.group.updatetick == self.sim.currenttick)
|
||||
end
|
||||
|
||||
function Port.setgate(self, gate)
|
||||
|
||||
Reference in New Issue
Block a user