If all "tag" objects are false, then - 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 all "tag" objects are false, then (/showthread.php?tid=1981) |
If all "tag" objects are false, then - Kai-Roger - 18.03.2019 Hi. Is there a script that can do something if all objects with a certain tag is false? BR Kai-Roger RE: If all "tag" objects are false, then - Erwin van der Zwart - 18.03.2019 Hi, Try this: Code: tagname = 'tag name' Erwin RE: If all "tag" objects are false, then - Kai-Roger - 18.03.2019 (18.03.2019, 22:03)Erwin van der Zwart Wrote: Hi, Hi. Thanks a lot! With a lot of trial and error, i finaly got this to do what i want. If all tags are false, then Lights_status is false. If one or more of the tags are true, then Lights_status are true :) tagname = 'Lights_room1' Lights_status = grp.find('1/1/137') for _, obj in ipairs(grp.tag(tagname)) do if obj.value then return Lights_status:write(true) end end Lights_status:write(false) And here a little more adjusted to suite my purpose better in a bigger script, and to work with only tag's (no group adresses) :) for _, obj in ipairs(grp.tag('Lights_room1')) do if obj.value then return grp.tag('All_lights'):write(true) end end grp.tag('All_lights'):write(false) RE: If all "tag" objects are false, then - Erwin van der Zwart - 19.03.2019 Hi, Are you sure your script works? I would expect the command in true state before the return.. BR, Erwin RE: If all "tag" objects are false, then - Kai-Roger - 19.03.2019 (19.03.2019, 05:39)Erwin van der Zwart Wrote: Hi, Hi. Yes it does what i expected. Here is how it responds: But what i failed to do, was to use two of these codes after another in the same code. I think it stops at the first one, so i have to change something so that the scripts run every part of the code. RE: If all "tag" objects are false, then - Krstfr2k - 20.03.2019 (19.03.2019, 06:35)Kai-Roger Wrote:(19.03.2019, 05:39)Erwin van der Zwart Wrote: Hi, Not the prettiest script but atleast it works Code: tag = grp.tag('lights_1') RE: If all "tag" objects are false, then - admin - 20.03.2019 You don't need grp.getvalue there, each object table already has value field populated. |