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.

Start multiple scripts
#1
Hi, I need some guidance, I have 10 Event-based/Resident scripts that I need to be able to start from one button and stop from another button.

The scripts i have is as follows:

Event-based:

solenoid_address = '2/0/20'

value = event.getvalue()
script.set('solenoid_east', value)
grp.checkwrite(solenoid_address, value)

Resident:

solenoid_address = '2/0/20'
grp.checkwrite(solenoid_address, true)
os.sleep(60)
grp.checkwrite(solenoid_address, false)
os.sleep(300)

I have 10 similar scripts for different solenoids

If they press "start all" all the scripts should turn on, if one of the scripts was already started it just keeps running

If they press "stop all" all the scripts should stop no matter what.

And can i use the "start button" to indicate only if all solenoids is on?
And the "stop button" to indicate only if all solenoids is off.

Ohh and is it possible to add a delay so that I don't start all the scripts at the same time? (water pressure)


I don't know if my approach with individually scripts is the right way of doing it?

If not can you turn me in the right direction?
Reply
#2
Multiple scripts can be controlled together using categories: https://openrb.com/docs/lua.htm#script.categoryset
But I suggest using a single resident script to control all solenoids to guarantee that there's a delay between turning different solenoids on and off.
Reply
#3
Thank you for pointing me in the right direction.
I got it working but I would like my button(virtual object 62/1/5 01.001 switch) to go back to off when it have executed the script, is that possible?
Tried to just grp.write('62/1/5', false) in the end of my script, but then it just runs the script again.
Reply
#4
See this example on how to prevent script being executed when triggered by an event script: https://forum.logicmachine.net/showthrea...8#pid24808
Reply


Forum Jump: