update logic functions to remove metatable OOP

This commit is contained in:
Redo
2020-09-10 12:58:25 -05:00
parent 4095d193ff
commit ab19de7333
206 changed files with 22726 additions and 3544 deletions

View File

@ -20,5 +20,5 @@ return function(gate, argv)
end
queueBit(false)
gate:queue(0)
Gate.queue(gate, 0)
end

View File

@ -2,9 +2,9 @@
return function(gate)
if #gate.queueBits~=0 then
local bit = table.remove(gate.queueBits, #gate.queueBits)
gate.ports[1]:setstate(bit)
gate:queue(1)
Gate.setportstate(gate, 1, bit)
Gate.queue(gate, 1)
else
gate.ports[1]:setstate(false)
Gate.setportstate(gate, 1, false)
end
end

View File

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

View File

@ -14,6 +14,7 @@ datablock fxDTSBrickData(LogicGate_Switch_Data)
isLogicGate = 1;
isLogicInput = 1;
logicInit = "return function(gate) gate.switchstate = false end";
logicInput = lualogic_readfile($LuaLogic::Path @ "bricks/inputs/switch-input.lua");
numLogicPorts = 2;