Logic Machine Forum
Pause an event 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: Pause an event script (/showthread.php?tid=3899)



Pause an event script - sashhun - 23.02.2022

Please tell me if there is a way to interrupt the execution of an event script if this script is already running but has not finished executing. The problem is that when you repeatedly press the light switch, the LM processor starts to load. Since the script execution has not yet completed, and the user presses the same switch several times
Below is an example of one of the scripts
Code:
value = event.getvalue()
local rgbw_color_zal = storage.get('active_rule_3', 3739391)                    
obj_ligth = grp.tag('master_led')

if (value==true) then
    for id, obj in ipairs(obj_ligth) do
    if (obj.datatype==1) then
                grp.write(obj.address, true)                             
    elseif(obj.datatype==5001) then
            grp.write(obj.address, 100)                              
    elseif(obj.datatype==12600) then
            grp.write(obj.address, rgbw_color_zal)             
    elseif(obj.datatype==5) then
      grp.write(obj.address, 0)             
       end
        os.sleep(0.3)
    end
else
    for id, obj in ipairs(obj_ligth) do
    if (obj.datatype==1) then
                grp.write(obj.address, false)                         
    elseif(obj.datatype==5001) then
            grp.write(obj.address, 0)                                      
    elseif(obj.datatype==12600) then
            grp.write(obj.address, 0)                                      
    elseif(obj.datatype==5) then
            grp.write(obj.address, 0)                                     
       end
        os.sleep(0.3)
    end
end
scripts are different depending on what, where and when should be included. This is one of those scripts.


RE: Pause an event script - Daniel - 23.02.2022

https://forum.logicmachine.net/showthread.php?tid=2955&pid=19051#pid19051


RE: Pause an event script - sashhun - 23.02.2022

(23.02.2022, 11:55)Daniel Wrote: https://forum.logicmachine.net/showthread.php?tid=2955&pid=19051#pid19051
Maybe I didn't explain the situation well. The script that is being executed does not need to be stopped, it must be completed to the end, I need that at this moment when this script is being executed, the second instance does not start for execution when a repeated event arrives at the group address


RE: Pause an event script - Daniel - 23.02.2022

Then you talking about semaphore
https://openrb.com/docs/semaphore.htm
Consider also using this
https://forum.logicmachine.net/showthread.php?tid=1893&pid=11774#pid11774


RE: Pause an event script - sashhun - 23.02.2022

(23.02.2022, 12:08)Daniel Wrote: Then you talking about semaphore
https://openrb.com/docs/semaphore.htm
Consider also using this
https://forum.logicmachine.net/showthread.php?tid=1893&pid=11774#pid11774


Thanks