This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

lua table find higest value
#6
(08.04.2024, 14:07)admin Wrote: Try this:
Code:
tags = {
  { tag = 'tag1', output = '1/1/1' },
  { tag = 'tag2', output = '2/1/1' },
}

function tag_max(tag)
  local objects = grp.tag(tag)
  local result = -math.huge

  for _, object in ipairs(objects) do
    result = math.max(result, object.value)
  end

  return result
end

for _, t in ipairs(tags) do
  max = tag_max(t.tag)
  grp.checkwrite(t.output, max)

  os.sleep(0.1)
end

Thank you Admin. Works as expected Smile .

If I want to also calculate the min value in the same script and write on diff object?
Reply


Messages In This Thread
RE: lua table find higest value - by admin - 23.06.2020, 06:28
RE: lua table find higest value - by admin - 08.04.2024, 14:07
RE: lua table find higest value - by manos@dynamitec - 08.04.2024, 14:32

Forum Jump: