Logic Machine Forum
if else - 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: if else (/showthread.php?tid=1635)



if else - Bobby - 08.10.2018

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


if else - Kai-Roger - 08.10.2018

Can't you use FBeditor for this? No scripting there.

BR
Kai-Roger


RE: if else - buuuudzik - 08.10.2018

(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)



RE: if else - admin - 08.10.2018

Assign a tag to your objects and use this script: https://forum.logicmachine.net/showthread.php?tid=291&pid=1518#pid1518

Another solution: https://forum.logicmachine.net/showthread.php?tid=1524


RE: if else - Kai-Roger - 08.10.2018

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?


RE: if else - admin - 08.10.2018

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.