update logic functions to remove metatable OOP
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user