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

@@ -16,17 +16,20 @@ datablock fxDTSBrickData(LogicGate_8bitMultiplier_Data)
logicUIName = "8bit Multiplier";
logicUIDesc = "Multiplies A by B";
logicUpdate = "return function(gate) local a, b = 0, 0 " @
"local sum = 0 " @
"for i = 1, 8 do " @
"a = a + bool_to_int[gate.ports[i].state] * 2^(i-1) " @
"b = b + bool_to_int[gate.ports[i+8].state] * 2^(i-1) " @
"end " @
"local sum = a * b " @
"for i = 1, 16 do " @
"gate.ports[i+16]:setstate(bit.band(sum, 2^(i-1)) > 0) " @
"end end";
logicUpdate =
"return function(gate) local a, b = 0, 0 " @
" local sum = 0 " @
" for i = 1, 8 do " @
" a = a + bool_to_int[Gate.getportstate(gate, i )] * 2^(i-1) " @
" b = b + bool_to_int[Gate.getportstate(gate, i+8)] * 2^(i-1) " @
" end " @
" local sum = a * b " @
" for i = 1, 16 do " @
" Gate.setportstate(gate, i+16, bit.band(sum, 2^(i-1)) > 0) " @
" end " @
"end"
;
numLogicPorts = 32;
logicPortType[0] = 1;