19.04.2022, 06:03
(13.04.2022, 11:21)admin Wrote: Here's a solution with a lookup table. All input objects should have a common tag to which an event script is attached. Fill the addrlist table with group addresses as needed. Each entry is a single room (input 1/2 + output).TNX
The script finds the second input based on the group address that triggered the script and writes the maximum between two inputs to the output object.
Code:addrlist = {
{
input1 = '1/1/1',
input2 = '1/1/2',
output = '1/1/3',
},
{
input1 = '1/1/4',
input2 = '1/1/5',
output = '1/1/6',
},
{
input1 = '1/2/4',
input2 = '1/2/5',
output = '1/2/6',
},
}
for _, addrs in ipairs(addrlist) do
if event.dst == addrs.input1 then
altinput = addrs.input2
output = addrs.output
break
elseif event.dst == addrs.input2 then
altinput = addrs.input1
output = addrs.output
break
end
end
if altinput and output then
value1 = event.getvalue()
value2 = grp.getvalue(altinput)
grp.checkwrite(output, math.max(value1, value2))
end