Get All Object Instances For RuntimeScene with Javascript

Hi,

I want to pull all the instances for each object for a scene, into an array. Documentation says:

gdjs.RuntimeScene.prototype.getObjects = function(name){
    if ( !this._instances.containsKey(name) ) {
        console.log("RuntimeScene.getObjects: No instances called \""+name+"\"! Adding it.");
        this._instances.put(name, []);
    }

    return this._instances.get(name);
};

https://github.com/4ian/GDevelop/blob/master/GDJS/Runtime/runtimescene.js

So, I could get to nowhere with this method as _instances seems to be a private instance of HashTable object, thus I couldn’t access _instances so far from within the JS editor.

Is there a super simplistic way to do it, or should I go and extend the existing functionality?

Thanks in advance,

Cheers!

I figured it out. For future reference, in case it will be useful for somebody, here is how it goes:

if (runtimeScene.getTimeManager().isFirstFrame()) {
    
    getAllObjects(callback);
}

function getAllObjects(callback)
{
    var result = [];
    runtimeScene._instances.keys(result);
    
    for (var i = 0, len = result.length; i < len; i++) {
        const myObject = runtimeScene.getObjects(result[i]);
            if (myObject.length !== 0) {
                callback(myObject[0]);
            }
    }
}

function callback(var1)
{
    var1.hide();
}

I have a similar problem like yours, but can we get the access instance of object without code?
I mean when when there are two instances of same object, say “Player” is object name and there are two “player” instances in the scene. In the events tab can i select them as → Player[0] and Player[1] , something like this…Is there a way??