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.

if else
#1
Im trying to get a pump to work, only if come conditions are met.
I am not good at scripting, but tried to make this script, but doesnt work properly.
Can anyone advice? Wink

value = grp.getvalue('1/5/1 or 1/5/2 or 1/5/3 or 1/5/4 or 1/5/5 or 1/5/6 or 1/5/7 or 1/5/8 or 1/5/9 or 1/5/10')
if (value == "on") then
  grp.write('1/4/23', true)
else grp.write('1/4/23', false)
end
Reply
#2
Can't you use FBeditor for this? No scripting there.

BR
Kai-Roger
BR
Kai-Roger
Reply
#3
(08.10.2018, 11:07)Bobby Wrote: Im trying to get a pump to work, only if come conditions are met.
I am not good at scripting, but tried to make this script, but doesnt work properly.
Can anyone advice? Wink

value = grp.getvalue('1/5/1 or 1/5/2 or 1/5/3 or 1/5/4 or 1/5/5 or 1/5/6 or 1/5/7 or 1/5/8 or 1/5/9 or 1/5/10')
if (value == "on") then
  grp.write('1/4/23', true)
else grp.write('1/4/23', false)
end

Function grp.getvalue() returns true or false not "on" of "off".
Function grp.getvalue() takes only one group address so it should be:

Code:
value = grp.getvalue('1/5/1') or grp.getvalue('1/5/2') -- and others values
grp.write('1/4/23', value)
Done is better than perfect
Reply
#4
Assign a tag to your objects and use this script: https://forum.logicmachine.net/showthrea...18#pid1518

Another solution: https://forum.logicmachine.net/showthread.php?tid=1524
Reply
#5
That looked easy enough Smile

Where do you put this to make it work? Is it under "Event-based" under scripting?
 
Which "Group adress / tag:" do we have to chose prior to insert this code?
Reply
#6
First example is a resident script, second one is an event script.

In any case, all input objects for "or" gate must have the same tag. This tag must be either specified in resident script groups table or assigned to the event script.
Reply


Forum Jump: