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.

Boolean object operations
#1
I need to do a sum with 1 bit objects, is this possible?

For example,
a = 1/1/1 (true)
b = 1/1/2 (false)
c = 1/1/3 (true)
value = 1/1/4

a + b + c = value

*in this operation it would send a value 2
Reply
#2
Like this:
Code:
objs = {
  '1/1/1',
  '1/1/2',
  '1/1/3',
}

sum = 0
for _, obj in ipairs(objs) do
  if grp.getvalue(obj) then
    sum = sum + 1
  end
end

grp.checkwrite('1/1/4', sum)
Reply
#3
(25.08.2020, 14:29)admin Wrote: Like this:
Code:
objs = {
  '1/1/1',
  '1/1/2',
  '1/1/3',
}

sum = 0
for _, obj in ipairs(objs) do
  if grp.getvalue(obj) then
    sum = sum + 1
  end
end

grp.checkwrite('1/1/4', sum)

Thank you so much Admin!  Smile
Reply


Forum Jump: