06.06.2022, 07:07
Instead of changing tags you can simply tag on/off objects with a different tag. The number of tagged objects for both max and status tags must be the same. It also makes sense to map this script to both value and status objects. A different common tag can be be used for this.
Code:
function sortbyid(a, b)
return a.id < b.id
end
objs = grp.tag('max')
table.sort(objs, sortbyid)
stat = grp.tag('status')
table.sort(stat, sortbyid)
max = -math.huge
for i, obj in ipairs(objs) do
if stat[ i ].value then
max = math.max(obj.value, max)
end
end
log(max)