24 lines
711 B
Lua
24 lines
711 B
Lua
local signalReceived = function(signal, connection)
|
|
local this = connection.Item
|
|
local mem = this.Components[2]
|
|
|
|
if signal.value == "" then return end
|
|
local input = tonumber(signal.value) or 1
|
|
|
|
if input > 0 then
|
|
if tonumber(mem.value) >= this.Components[3].clampMax then
|
|
mem.value = tostring(this.Components[3].clampMin)
|
|
else
|
|
mem.value = tostring(tonumber(mem.value) + 1)
|
|
end
|
|
elseif input == 0 then
|
|
mem.value = "0"
|
|
elseif input < 0 then
|
|
mem.value = tostring(-input)
|
|
end
|
|
|
|
this.SendSignal(mem.value, "state_out")
|
|
end
|
|
|
|
Hook.Add("signalreceived.countercomponent", "countercomponent.signalReceived", signalReceived)
|