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.

How to stop this script when running
#1
Hi Everyone.

Question one:
This is a scheduled script (script name: Ligths_UP), is there at way to enable/disable it by the use of a grp.adress?

e.g:
if start == true then 
script.enable(Ligths_UP)
else
script.disable(Ligths_UP)


Question Two:
When this script is started i can't stop i from running again. 
It will only stop when value_end is reached.
Is there a way to stop it halfway?

value_sek = grp.getvalue('32/1/4')
value_end = grp.getvalue('32/1/3')
start = grp.getvalue('32/1/1')


-- UP
output = '32/1/2'
for i = grp.getvalue(output) + 1, value_end, 1 do
  grp.write(output, i)
  os.sleep(value_sek)
end

Best regards
Timmi Andersen
Denmark
Reply
#2
1. Script name in enable/disable must be in quotes. Right now you are referring to a variable named Ligths_UP that's not defined. Alternatively you can simply use grp.getvalue() in
your script to determine whether it should run or not:
Code:
-- run only if 1/1/1 value is true
if grp.getvalue('1/1/1') then
  -- do something
end

2. You can set the event script "Execution mode" to "Last instance only" and only execute your action when the event value is true. Sending false will stop the previous script instance.
Code:
if event.getvalue() then
  -- do something
end
Reply


Forum Jump: