Correct way to handle build callbacks in script (buildStarted / buildEnded)

I am creating a custom script that build banks to a specific folder, rather than changing the build path in the preferences. The script will then fallback to the default path, not changing the default build behaviour.

image

Everything works fine except that once you have set the “listeners” to buildStarted and buildEnded, they live on. So if I build using my script, and then build using F7, the callback functions will run again.

Is there any way to remove the “listeners” to buildStarted and buildEnded? I can’t seem to find anything in the documentation.

https://fmod.com/resources/documentation-studio?version=2.1&page=scripting-api-reference-project.html#projectbuildstartedconnectcallback

I could skip the listeners and rely on the execution order but I rather learn something new. •͡˘㇁•͡˘

SetBanksOutputDirectory(outputDirectory);
studio.project.build();
SetBanksOutputDirectory(fallbackDirectory);

Thanks
Mattias

It looks like when the listeners were implemented it was under the assumption these would be done through one-off scripts run through the command line, so decoupling or having them as a one time use function was not considered. Therefore it’s not necessarily a bug, but it’s behaviour can definitely be improved.

I’ve raised a suggestion to improve these functions in a future release, thank you for bringing it to our attention.

1 Like

Thanks for your reply. I skipped the listeners for now.