Logic Machine Forum
Or logic gate - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: Or logic gate (/showthread.php?tid=1524)



Or logic gate - benthoma - 09.08.2018

Hi. I have 5 1bit inputs and I want a logic or gate that converts the output to byte. 
False = 0%
True =100%
How will the code look like?


RE: Or logic gate - admin - 10.08.2018

Add or_gate tag to each input object. Add an event script mapped to or_gate tag. Change 32/1/4 to your output object address.

Code:
value = false

objects = grp.tag('or_gate')
for _, object in ipairs(objects) do
  value = value or object.value
end

grp.checkwrite('32/1/4', value and 100 or 0)