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.

save mode to array and modify
#1
Good morning.

Let's see if you can give me a hand, I haven't touched the scripts in a while and I'm having a hard time getting my bearings.

I have 160 objects with 5 different modes, from 1 to 5, and the user is going to assign a number to each object in the visualization. Then, I have 5 objects, one for each mode, that will perform an action on those 160 objects, according to the assigned number of each one. For example, if there are 34 objects with the number 3, I will make a script that sends X value to those 34 objects.

To do this, I think the best way is to create an array that saves the mode state of those 160 objects, and when one of those objects is modified, the array is traversed, and only the corresponding position is modified.

The question I ask you then: How can I make that array with the reading of the objects and the subsequent modification?

Thanks for your help.
Reply
#2
Create virtual objects that will contain the selected modes. Use an addressing scheme that allows to easily calculate the output object address. For example output is 1/2/3 and mode is 32/2/3. Assign a common tag to all mode objects.

Event script example where event value is the selected mode. Only objects where the mode is the same as the event value are affected.
Code:
value = event.getvalue()
objects = grp.tag('mode')

for _, object in ipairs(objects) do
  if object.value == value then
    output = object.address:gsub('^32/', '1/')
    grp.checkwrite(output, 123)
    os.sleep(0.1)
  end
end
Reply
#3
Share your script, maybe there is a way to make a single one for all.
------------------------------
Ctrl+F5
Reply
#4
Hi!
I have deleted the previous message because it was not entirely clear. admin, thanks for the help, but I'm late because I had already made all the objects, and changing them now would be cumbersome.

 I'll try to explain it:

I have 160 lights. Each of these luminaires will have 3 operating modes, as if they were DALI groups, and the user will be able to assign the group as needed (only 1 group for each luminaire). Next, when the user wants to turn on the luminaires of a group, the system will have to know which group those luminaires belong to, and turn on the corresponding ones.

Thanks in advance for your help.
Reply


Forum Jump: