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.

Loop problems
#1
Hello,

Once again, I'm in need of help. I'm trying to do a simple script that adds few %'s to a DALI light while holding dimming button. I have the button setup as dimmer (brighter), which gives value 9 when I hold it and value 0 when I don't. This is the script I came up with but of course it doesn't work. The loop doesn't break, it just keeps on going even after 100% and keeps updating it. This code is inside the dimming button.
12/0/0 = stm = DALI light object, which has a scale from 0-100%.
step = number of % it's supposed to jump each ramp_time


Code:
value = event.getvalue()
step = 4
ramp_time = 0.05
stm = grp.getvalue('12/0/0')

while (value == 9) do
  stm = grp.getvalue('12/0/0')
  grp.write('12/0/0', stm + step)
  if (value == 0) then
    break
  end
  os.sleep(ramp_time)
end

I even tried doing: if (value ~= 9) then break but it doesn't work. Any suggestions?
Reply
#2
See this post:
https://forum.logicmachine.net/showthread.php?tid=13

The problem is that value is only assigned once, you have to add grp.getvalue inside your loop for script to work.
Reply
#3
works nicely, thank you very much. I also wanted to ask you, whenever I create a script and mess up a loop, it cycles infinitely and I have to restart LM. Is there anything else, easier than restarting LM to get rid of the running loop?
Reply


Forum Jump: