This repository has been archived on 2025-07-31. You can view files and clone it, but cannot push or open issues or pull requests.
Files
barotrauma-custom-components/Lua/countercomponent.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)