Brick_LuaLogic/bricks/inputs/switch-input.lua

12 lines
298 B
Lua

return function(gate, argv)
if #argv == 1 then
gate.switchstate = toboolean(argv[1])
else
gate.switchstate = not gate.switchstate
end
Gate.setportstate(gate, 1, gate.switchstate)
Gate.setportstate(gate, 2, gate.switchstate)
Gate.cb(gate, bool_to_int[gate.ports[1].state])
end