General

How to get the object index in a Container?

Started by Perun on .

Sign in or create an account to join the conversation.

11 posts

Topic starter
Hi,
Let's say I have 10 buttons (set to "switch" behavior) in a container. How can I get the object index of the currently selected button (x==1) inside the Container? In my scenario one button is selected at a time.
Thanks
Sorry still dont understand one thing....
Bu your description you have a lot of switches ( names you gave).

Do you want a way to find the "on" switch in each ONE object of multi-rows/columns? Then:
Script on execution x

decl index = firstof(x);
The index declared above will give you the position of the active switch inside the x vector (array)

Or do you want to search for the on switch of all the objects combined?
Here is an simple image of my scenario shown below. I have several buttons in a Container (in this example 4 in one row) but in my actual setup there are about 80 buttons placed in rows and columns. One of them can be switched ON at a time. I have a simple script which switches OFF the last selected button automatically (that script is embedded into each button and executed "On Expression" x of the button.

I need to get the current selected button Index number in the Container. I.e the Container is the array and the example below.
I need something like that:
Index=Btn_Container[2] so the Index=2 in this example.

btn_index.jpg
hi perun and softcore,

i grab some usefull stuff from this post, especially about exemple 3, thanks for this !

next step for me is to send this value over midi, with the value interpoleted betwen 0 to 127,

i mean if i got ten switch and press the first, it send 0, the 5th send 64, and the last send 127
with 20 switch, value 64 will be send with the 10th switch ....

i should have a simple thing missing, but i new to lemur...

thanks