In the rotating cubes example, the program uses 3 nested for loops to builds a list of boxes, each of which are appended to the boxes[] list.
It is then possible to set the color of a specific box with something like boxes[37].color=color.blue. If you know what box you want to set, you can refer to it by number.
Later, the program uses hit.color = color.white to set the color of the box that was clicked on. It must know the number of the box to do this.
I have a similar task, but I have the desired color in another list called colors[] that corresponds 1:1 with the boxes[] list. How do I find out the number of the box that was clicked on so I can look up the color in the other list and apply it to the box?
I want to do something like:
hit = scene.mouse.pick
myindex = hit.index
mycolor = colors[myindex]
hit.color = mycolor
I know "index" is not the right property (I tried it) but I couldn't find a list of all the properties and methods of scene.mouse.pick. I saw this info, but is is confusing the way it is written.
pick Execute var obj = scene.mouse.pick to obtain the object pointed to by the mouse. If you have a box named B, you can determine whether the picked object is that box by asking if (B == obj). If there is no object pointed to by the mouse, obj is None. Also, obj will be None if the object has the pickable attribute set to False. For example, the curves, spheres, and arrows created by make_trail, attach_trail, and attach_arrow are not pickable, and you may wish to specify that some of your own objects are not pickable. At present label, helix, and extrusion cannot be picked. For curve objects, obj.segment is the number of the picked segment along the curve, starting with 1 (representing the segment from point number 0 to point number 1). You can test for a curve object with if instanceof(obj, curve):. See the GlowScript example MousePicking.
Specifically, I don't know if "var" and "obj" are actual python terms of if they are placeholders for my own variable names. That description seems to imply that I would have to test all 1000 of my boxes one at a time until I found the one that was clicked on. That can't be right.
Thanks