30.06.2022, 10:25
Assign a common tag to all zone status objects. Map an event script to this tag. It will write true when more than half of tagged objects are true, false otherwise. Make sure that the status output object is not mapped to the same tag.
Code:
function tag_status(tag)
local result, objects, count, halfcount
result = false
objects = grp.tag(tag)
count = 0
halfcount = math.floor(#objects / 2)
for _, object in ipairs(objects) do
if object.data then
count = count + 1
end
end
return count > halfcount
end
res = tag_status('central')
grp.checkupdate('1/1/1', res)