I'm writing some tools that can be used cross different scenes through add on script. And call add on functions through sim.getScript and sim.callScriptFunction.
It seems that an add-on script can also call functions from another script. However, the source script must have been loaded and initialized. I wonder if I can manage the order of add-on initialization so that the base script is always initialized when used by another add-on? Or if there are other ways to manage the dependency between scripts?
By the way, how is sim.callScriptFunction implemented? Does it call functions through remote communication or not?
Dependency between add on script.
Re: Dependency between add on script.
Hello,
as of now, you can't specify the load and initialization order of add-ons. You'll have to implement some messaging between your add-ons in order to make sure all required are loaded. Simplest would be to try with a protected call sim.callScriptFunction: if the call fails, the target add-on (e.g. the service add-on) was not yet initialized.
sim.callScriptFunction happens immediately without communication overhead if both scripts run in Lua. Otherwise the call is implemented under the hood via interprocess communication.
What you can also do is modify the sandbox script (which is initialized first) and call relevant functions in the sandbox.
Cheers
as of now, you can't specify the load and initialization order of add-ons. You'll have to implement some messaging between your add-ons in order to make sure all required are loaded. Simplest would be to try with a protected call sim.callScriptFunction: if the call fails, the target add-on (e.g. the service add-on) was not yet initialized.
sim.callScriptFunction happens immediately without communication overhead if both scripts run in Lua. Otherwise the call is implemented under the hood via interprocess communication.
What you can also do is modify the sandbox script (which is initialized first) and call relevant functions in the sandbox.
Cheers
Re: Dependency between add on script.
Thank you for your reply. Is there any update plan for such a feature? Either a script loading API or something like an add-on manager?coppelia wrote: 11 Jun 2024, 07:19 Hello,
as of now, you can't specify the load and initialization order of add-ons. You'll have to implement some messaging between your add-ons in order to make sure all required are loaded. Simplest would be to try with a protected call sim.callScriptFunction: if the call fails, the target add-on (e.g. the service add-on) was not yet initialized.
sim.callScriptFunction happens immediately without communication overhead if both scripts run in Lua. Otherwise the call is implemented under the hood via interprocess communication.
What you can also do is modify the sandbox script (which is initialized first) and call relevant functions in the sandbox.
Cheers
Re: Dependency between add on script.
There is no immediate plan for modification in that regard. Have also a look at the add-on addOns/Point sampler service.lua which provides various functionality to other add-ons.
Cheers
Cheers