Creating a function that accepts a set of objects and and a single instance of such object

How do I…

Create a function that accepts a set of objects and and a single instance of such object

What is the expected result

Function that performs operations basing on the above data.

Current results

Currently the function accepts one argument, an object - inside it performs “pick all objects” and later on uses the passed in instance to perform operation on.
But the log (as in the screenshots) prints only 1 as the number of picked instances.

This looks like the function works in an isolated context, not taking into account what’s beside it. It’s an inconsistent behavior of what functions are meant to be in most of programming languages (they reach to outer, usually global, scope).

I agree, if you pass a function an object whose pick list has been reduced then you should be able to use pick all to get the entire list.

Maybe, you can move the condition that filters the objects list into the function.

For example, if you pick an object with the mouse or through collision then pass that instance to the function then you could pass the object to the function and pick the object either touched or collided with from within the function.

You could probably do it with Javascript.

Otherwise, you would need to provide the object and something else to identify the target object like an ID or coordinate.

I don’t know if there’s a suggestion or bug report for this. It couldn’t hurt to create one.