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.

grp.checkwrite / grp.checkupdate
#15
Hii sir ,
 
I have created resident script in which when a light ON in particular area it sends command to another object which tells me that a light is ON in this area the problem is that when i Active this script then logic machine become a slow or hang.and script sleep interval time is 0 second.

Can you suggest me solution for this query.

here is script --


-- Define the function that will run every 5 seconds
function checkValues()
-- Get the values from the grp (assuming grp.getvalue() returns the values for these keys)
value = grp.getvalue('0/6/2')
value2 = grp.getvalue('0/6/10')
value3 = grp.getvalue('0/5/6')
value4 = grp.getvalue('0/6/8')
value5 = grp.getvalue('2/5/22') -- value5 is checked for >= 1
value18 = grp.getvalue('2/5/27') -- value18 is checked for >= 1
value19 = grp.getvalue('0/6/44') -- value19 is checked for >= 1
value20 = grp.getvalue('0/6/25') -- value20 is checked for >= 1
value21 = grp.getvalue('0/6/58') -- value21 is checked for >= 1
value22 = grp.getvalue('0/6/30') -- value22 is checked for >= 1

-- Adjust the conditions for clarity (use parentheses to ensure proper evaluation order)
if (value or value2 or value3 or value4 or value5 >= 1 or
value18 >= 1 or value19 >= 1 or value20 >= 1 or
value21 >= 1 or value22 >= 1) then
grp.write('0/6/65', true) -- Write true if any condition is met
else
grp.write('0/6/65', false) -- Write false otherwise
end
end

-- Set the script to run every 5 seconds
while true do
checkValues() -- Call the function to check values
os.execute("sleep 5") -- Sleep for 5 seconds before checking again
end
Reply


Messages In This Thread
grp.checkwrite / grp.checkupdate - by Dré - 30.12.2022, 09:12
RE: grp.checkwrite / grp.checkupdate - by sx3 - 02.01.2023, 11:39
RE: grp.checkwrite / grp.checkupdate - by Ranjeet - Yesterday, 08:46

Forum Jump: