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/flipflopcomponent.lua

20 lines
565 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 == 1 then
if mem.value == "0" then mem.value = "1" else mem.value = "0" end
elseif input == 0 then
mem.value = "0"
elseif input == -1 then
mem.value = "1"
end
this.sendSignal(mem.value, "state_out")
end
Hook.Add("signalreceived.flipflopcomponent", "flipflopcomponent.signalReceived", signalReceived)