How to pick objects from javascript event?

I have a custom condition with a javascript event where I would like to modify which objects are picked in actions that follow the condition. I have a single parameters called objects and tried with code like:

const objects = eventsFunctionContext.getObjectsLists('objects');

for (const [name, instances] of Object.entries(objects.items)) {
    const selectedInstances = instances.filter(isSelected);
    instances.length = 0; // Empty the list
    instances.push(...selectedInstances); // All only the selected ones

As I read the documentation I’m supposed to modify the arrays held by the HashTable returned by getObjectsLists.

ps. having lots of fun playing with gdevelop :smiley: