11.05.2021, 08:02
There used to be a universal script but I can't find it.
Here's a working solution for any data type. Tag all input objects with the same tag and add an event script to it. Change group addresses as needed. You might need to remove two "not" statements before grp.getvalue depending on how open/closed status works. Right now it assumed that true means that the wall is closed.
Here's a working solution for any data type. Tag all input objects with the same tag and add an event script to it. Change group addresses as needed. You might need to remove two "not" statements before grp.getvalue depending on how open/closed status works. Right now it assumed that true means that the wall is closed.
Code:
inputs = { '32/1/1', '32/1/2', '32/1/3' }
status = { '32/1/7', '32/1/8' }
outputs = { '32/1/4', '32/1/5', '32/1/6' }
for i, addr in ipairs(inputs) do
if addr == event.dst then
index = i
end
end
value = event.getvalue()
writes = {}
writes[ index ] = true
open12 = not grp.getvalue(status[ 1 ])
open23 = not grp.getvalue(status[ 2 ])
if index == 1 then
if open12 then
writes[ 2 ] = true
writes[ 3 ] = open23
end
elseif index == 2 then
writes[ 1 ] = open12
writes[ 3 ] = open23
elseif index == 3 then
if open23 then
writes[ 2 ] = true
writes[ 1 ] = open12
end
end
for i, addr in ipairs(outputs) do
if writes[ i ] then
grp.write(addr, value)
end
end