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.

Conference room with 2 partition walls
#5
Here's a universal solution that should work for any number of partition walls. Modify group addresses in the inputs, sensors and outputs tables as needed. All input objects should have a common tag to which this event script is attached.
Code:
inputs = {
  '33/1/1',
  '33/1/2',
  '33/1/3',
  '33/1/4',
  '33/1/5',
}

sensors = {
  '33/2/1',
  '33/2/2',
  '33/2/3',
  '33/2/4',
}

outputs = {
  '33/3/1',
  '33/3/2',
  '33/3/3',
  '33/3/4',
  '33/3/5',
}

value = event.getvalue()

for i, addr in ipairs(inputs) do
  if addr == event.dst then
    index = i
  end
end

grp.write(outputs[ index ], value)

for i = index, #sensors do
  if grp.getvalue(sensors[ i ]) then
    break
  end

  grp.write(outputs[ i + 1 ], value)
end

for i = index - 1, 1, -1 do
  if grp.getvalue(sensors[ i ]) then
    break
  end

  grp.write(outputs[ i ], value)
end
Reply


Messages In This Thread
RE: Conference room with 2 partition walls - by admin - 05.04.2022, 06:31

Forum Jump: