This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

1 script 200 Rooms
#7
(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).

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
TNX
Reply


Messages In This Thread
1 script 200 Rooms - by Stuart2000 - 12.04.2022, 08:49
RE: 1 script 200 Rooms - by admin - 12.04.2022, 08:55
RE: 1 script 200 Rooms - by Stuart2000 - 12.04.2022, 09:05
RE: 1 script 200 Rooms - by admin - 12.04.2022, 09:17
RE: 1 script 200 Rooms - by Stuart2000 - 12.04.2022, 16:30
RE: 1 script 200 Rooms - by admin - 13.04.2022, 11:21
RE: 1 script 200 Rooms - by Stuart2000 - 19.04.2022, 06:03

Forum Jump: