Logic Machine Forum
Loop script - 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: Loop script (/showthread.php?tid=3622)



Loop script - victor.back - 16.10.2021

Hi. 

I want to make a set of group adresses to turn On and Off in a sequence loop as long as a switch is turned On, When this switch is turend Off I want this loop to stop. 
I made this event script, but it only runs once and I cant stop it. 
I tried a resident script as well but havent got it right yet, because that just runs all the time even if my switch is On or Off. 

Someone who can help me out here? Smile  

Code:
-- loop until condition is met

if event.getvalue(true)
  then
 
repeat
    grp.write('32/1/127', true)
        os.sleep(1.0)
  grp.write('32/1/128', true)
  grp.write('32/1/127', false)
      os.sleep(1.0)
  grp.write('32/1/129', true)
  grp.write('32/1/128', false)
  os.sleep(1.0)
  grp.write('32/1/130', true)
  grp.write('32/1/129', false)
    sleep(1.0)
  grp.write('32/1/131', true)
  grp.write('32/1/130', false)
    sleep(1.0)
  grp.write('32/1/131', false)

until grp.read('32/1/126', false)
  end



RE: Loop script - Dré - 17.10.2021

You can start and stop a script with command of this.
Answer to a question of me
(12.10.2021, 12:22)admin Wrote: Simply create an event script attached to a 1-bit boolean object and put this into the editor.
Code:
enable = event.getvalue()
script.set('bedroom [fb], turn off', enable)

if im right, group adress '32/1/126' is the start and stop adres for this script?
you can add the script (of Admin) above in this group adres to start and stop this script,

I used the script like this
Code:
if lights_TM == true then
script.set('01.03 0 study (tm) (vertraging uit)', enable)
elseif lights_TM == false  then
script.set('01.03 0 study (tm) (vertraging uit)', disable)
end


and use your script you post here in a resident script.


RE: Loop script - admin - 18.10.2021

In your while loop you must use grp.getvalue() instead of grp.read(). grp.read() just sends a read request to the bus.


RE: Loop script - victor.back - 18.10.2021

(17.10.2021, 10:04)Dré Wrote: You can start and stop a script with command of this.
Answer to a question of me
(12.10.2021, 12:22)admin Wrote: Simply create an event script attached to a 1-bit boolean object and put this into the editor.
Code:
enable = event.getvalue()
script.set('bedroom [fb], turn off', enable)

if im right, group adress '32/1/126' is the start and stop adres for this script?
you can add the script (of Admin) above in this group adres to start and stop this script,

I used the script like this
Code:
if lights_TM == true then
script.set('01.03 0 study (tm) (vertraging uit)', enable)
elseif lights_TM == false  then
script.set('01.03 0 study (tm) (vertraging uit)', disable)
end


and use your script you post here in a resident script.

Thanks for your help. 
It now works as I want to (: With this 
Event script
Code:
PendLoop = event.getvalue()
script.set('Pendel loop seq', PendLoop)

if PendLoop == false
  then
  os.sleep(0.1)
    grp.write('32/1/127', false)
  grp.write('32/1/128', false)
  grp.write('32/1/129', false)
  grp.write('32/1/130', false)
  grp.write('32/1/131', false)
  end
Resident script
Code:
repeat
    grp.write('32/1/127', true)
        os.sleep(1.0)
  grp.write('32/1/128', true)
  grp.write('32/1/127', false)
      os.sleep(1.0)
  grp.write('32/1/129', true)
  grp.write('32/1/128', false)
  os.sleep(1.0)
  grp.write('32/1/130', true)
  grp.write('32/1/129', false)
    os.sleep(1.0)
  grp.write('32/1/131', true)
  grp.write('32/1/130', false)
    os.sleep(1.0)
  grp.write('32/1/131', false)

until grp.getvalue('32/1/126', false)