Posts: 2
Threads: 1
Joined: Aug 2015
Reputation:
0
Hello,
I need group address which will show if any of windows is opened. So, I made event-based script, but problem is that only one event (window) affect result. How can I make script that will send result if any of windows open?
Thank you
Posts: 51
Threads: 14
Joined: Jul 2015
Reputation:
0
post code, it will help us to understand the problem
Posts: 2
Threads: 1
Joined: Aug 2015
Reputation:
0
There is no special code... For example, here is logic "a = b and c and d". If I use event based scripting, only change of one group address (for example "b") will change "a", but I need script where change of "b","c" or "d" will change "a". This is because I can choose only one "group address/tag" on which the script will be triggered.
In concrete situation, lets say there are 5 windows, and I want to have object which will show "ON" if any of window is opened, and "OFF" if all of them are "OFF". So this object will change it state if any of this window. It is the most basic logic.
Posts: 22
Threads: 6
Joined: Jul 2015
Reputation:
1
Thank you for that elegant (a > 0). Also didnt think of the # operator, was abit sceptical to use it with the whole true / false / nil statement.
Will a false also show as a nil when it comes to the #? Would it be better to replace it with table.getn(myobjects) since that one cant suddenly stop on a nil value and end the statement like # (according to some other forums).
Posts: 7758
Threads: 42
Joined: Jun 2015
Reputation:
447
objects table is guaranteed a be normal array without any holes (nil elements), so # operator does the same as table.getn
From Lua manual: Both nil and false make a condition false; any other value makes it true.