fix switch to use new oop

This commit is contained in:
Redo 2020-09-10 15:42:37 -05:00
parent ab19de7333
commit 58133caa95
2 changed files with 7 additions and 6 deletions

View File

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

View File

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