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.

Dealing with objects with tag
#1
Hello 
I have set of GA(1,2,3,4,...) linked to TAG (TESt)
I want the script based on GA(1,2,3,4,...) value to write something in different GA(101,102,103,104,...) 

how to achieve this  especially when multiple GA's values changed together?
with Best regards,
Best Regards,
Reply
#2
This will add 100 to the last group address part:
Code:
addr = event.dst:gsub('%d+$', function(a)
  return tonumber(a) + 100
end)
log(addr)
Reply
#3
(19.04.2022, 06:58)admin Wrote: This will add 100 to the last group address part:
Code:
addr = event.dst:gsub('%d+$', function(a)
  return tonumber(a) + 100
end)
log(addr)

Thanks Admin 
and the Value?
Best Regards,
Reply
#4
Use event.getvalue() as in any other event script. It does not matter if the script is attached to a tag or a single group address.
Reply
#5
(19.04.2022, 06:58)admin Wrote: This will add 100 to the last group address part:
Code:
addr = event.dst:gsub('%d+$', function(a)
  return tonumber(a) + 100
end)
log(addr)
Thanks Admin
I think it will be easy for me to get only the last group address part as number, because its not the same pattern.

Also what is function(a)?

BR,
Best Regards,
Reply
#6
This function replaces last part of the group address with the last part value + 100.
Another option for this is to split the address into parts and then join back:
Code:
parts = event.dst:split('/')
parts[3] = tonumber(parts[3]) + 100
addr = table.concat(parts, '/')

log(addr)
Reply
#7
(19.04.2022, 08:49)admin Wrote: This function replaces last part of the group address with the last part value + 100.
Another option for this is to split the address into parts and then join back:
Code:
parts = event.dst:split('/')
parts[3] = tonumber(parts[3]) + 100
addr = table.concat(parts, '/')

log(addr)

Thanks Admin
Best Regards,
Reply


Forum Jump: