Logic Machine Forum
traffic light effect - 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: traffic light effect (/showthread.php?tid=5401)



traffic light effect - Nir70 - 01.05.2024

Hello 
Is it possible to create 4-5 lamps that will work like a traffic light, one turns on and the other turns off in cycles? If the enable option is disabled Shy . Thanks


RE: traffic light effect - admin - 02.05.2024

Use this resident script. Sleep time controls when the next lamp will be turned on. Any number of objects can be specified.
Code:
objects = {
  '0/0/1',
  '0/0/2',
  '0/0/3',
}

curr = (curr or 0) + 1

if curr > #objects then
  curr = 1
end

if prev then
  grp.checkwrite(objects[ prev ], false)
end

grp.checkwrite(objects[ curr ], true)
prev = curr

This script can be enabled/disabled from a different script using these functions: https://kb.logicmachine.net/libraries/lua/#scriptenablename


RE: traffic light effect - Nir70 - 02.05.2024

(02.05.2024, 07:38)admin Wrote: Use this resident script. Sleep time controls when the next lamp will be turned on. Any number of objects can be specified.
Code:
objects = {
  '0/0/1',
  '0/0/2',
  '0/0/3',
}

curr = (curr or 0) + 1

if curr > #objects then
  curr = 1
end

if prev then
  grp.checkwrite(objects[ prev ], false)
end

grp.checkwrite(objects[ curr ], true)
prev = curr

This script can be enabled/disabled from a different script using these functions: https://kb.logicmachine.net/libraries/lua/#scriptenablename

objects = {
  '1/0/51',
  '1/0/53', 
}

curr = (curr or 0) + 1

if curr > #objects then
  curr = 1
end

if prev then
  grp.checkwrite(objects[ prev ], false)
end

grp.checkwrite(objects[ curr ], true)
prev = curr

Hello, I put the data in this way, where do I see the time it is supposed to change, it doesn't work, I work with a Schneider LS 100 200 product, thanks


RE: traffic light effect - Daniel - 02.05.2024

Did you use resident script? The script interval defines the change.