How to access custom object functions with javascript

How do i access the function of a custom object with javascript?

Normally, acessing the function of a extension is:

gdjs.evtsExt.__ExtensionName__FunctionName.func(runtimeScene, param1, param2)

But how can I access the function of a custom object?

I’m wondering if it’s this. I haven’t made many custom objects.

Edit: sorry, for some reason I was thinking objects not functions.

I’m not sure either, but it’s likely set on the object. Create an action on the object, call it from your scene (make sure you have an instance on the scene), and in the action use a JavaScript event, obtain the object with the objects array, and log the object in the JavaScript console. From there, you should be able to see all the functions present on it by inspecting it’s prototype - find the one that is named like the function you’ve made and voilà.

Couldn’t edit my post so updating here. As arthuro555 hinted the action function is defined on the custom object’s prototype, so it can be called from the custom object instance, but it requires a parentEventsFunctionContext as the last parameter, for which I just passed through the eventsFunctionContext from the javascript event, and it seemed to work. e.g.

my_custom_object.MyFunction(param1, param2,..., eventsFunctionContext)