Add non-active counter & flip-flop components
This commit is contained in:
@@ -1,11 +1,3 @@
|
||||
local allItems = {}
|
||||
|
||||
Hook.Add("item.created", "countercomponent.init", function(item)
|
||||
if item.Prefab.Identifier == "countercomponent" then
|
||||
allItems[item] = true
|
||||
end
|
||||
end)
|
||||
|
||||
local signalReceived = function(signal, connection)
|
||||
local this = connection.Item
|
||||
local mem = this.Components[2]
|
||||
@@ -24,13 +16,8 @@ local signalReceived = function(signal, connection)
|
||||
elseif input < 0 then
|
||||
mem.value = tostring(-input)
|
||||
end
|
||||
|
||||
this.SendSignal(mem.value, "state_out")
|
||||
end
|
||||
|
||||
local think = function()
|
||||
for component, _ in pairs(allItems) do
|
||||
component.SendSignal(component.Components[2].value, "state_out")
|
||||
end
|
||||
end
|
||||
|
||||
Hook.Add("think", "countercomponent.think", think)
|
||||
Hook.Add("signalreceived.countercomponent", "countercomponent.signalReceived", signalReceived)
|
||||
|
Reference in New Issue
Block a user