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

@@ -12,23 +12,27 @@ datablock fxDTSBrickData(LogicGate_8bitSubtractor_Data)
isLogic = true;
isLogicGate = true;
isLogicInput = false;
logicUIName = "8bit Subtractor";
logicUIDesc = "Subtracts B from A";
logicUpdate = "return function(gate) local c = bool_to_int[gate.ports[17].state] " @
"local a = 0 " @
"local b = 0 " @
"for i = 1, 8 do " @
"a = bool_to_int[gate.ports[i].state] " @
"b = bool_to_int[gate.ports[i+8].state] " @
"gate.ports[i+17]:setstate(bit.bxor(bit.bxor(a, b), c) == 1) " @
"c = bit.bor(bit.bor(bit.band(bool_to_int[a == 0], b), bit.band(bool_to_int[a == 0], c)), bit.band(b, c)) " @
"end " @
"gate.ports[26]:setstate(c == 1) end";
logicUpdate =
"return function(gate) " @
" local c = bool_to_int[Gate.getportstate(gate, 17)] " @
" local a = 0 " @
" local b = 0 " @
" for i = 1, 8 do " @
" a = bool_to_int[Gate.getportstate(gate, i )] " @
" b = bool_to_int[Gate.getportstate(gate, i+8)] " @
" Gate.setportstate(gate, i+17, bit.bxor(bit.bxor(a, b), c) == 1) " @
" c = bit.bor(bit.bor(bit.band(bool_to_int[a == 0], b), bit.band(bool_to_int[a == 0], c)), bit.band(b, c)) " @
" end " @
" Gate.setportstate(gate, 26, c == 1) " @
"end"
;
numLogicPorts = 26;
logicPortType[0] = 1;
logicPortPos[0] = "-1 -1 0";
logicPortDir[0] = 3;