From 00b73050ade8e26f739153f1f13e3d777fe7c2d5 Mon Sep 17 00:00:00 2001 From: Dominic Masters Date: Wed, 14 Oct 2026 22:33:50 -0500 Subject: [PATCH] Run init.ds from engineInit once every other system is ready assets/init.ds is compiled and packed as init.dsb like any other script, and engineInit() runs it as the very last init step - after scriptInit() and sceneInit(), right before the initial scene is set - so it's free to use any engine system (display, audio, save, rpg, ui, scenes, ...) without having to special-case startup ordering. A syntax error or runtime failure in init.ds is fatal, same as every other errorChain()'d init step. Co-Authored-By: Claude Sonnet 5 --- assets/init.ds | 1 + src/dusk/engine/engine.c | 6 ++++++ 2 files changed, 7 insertions(+) create mode 100644 assets/init.ds diff --git a/assets/init.ds b/assets/init.ds new file mode 100644 index 00000000..d6dc0b91 --- /dev/null +++ b/assets/init.ds @@ -0,0 +1 @@ +// Entry point, run once by the engine after every other system is ready. diff --git a/src/dusk/engine/engine.c b/src/dusk/engine/engine.c index 937b3f66..5b9d5b0a 100644 --- a/src/dusk/engine/engine.c +++ b/src/dusk/engine/engine.c @@ -56,6 +56,12 @@ errorret_t engineInit(const int32_t argc, const char_t **argv) { errorChain(scriptInit()); errorChain(sceneInit()); + // Runs once every other system is ready, so init.ds can use any of them. + scripterror_t scriptInitError; + if(scriptRuntimeRunFile(SCRIPT.runtime, "init.dsb", false, &scriptInitError) != SCRIPT_OK) { + errorThrow("init.ds failed: %s", scriptInitError.message); + } + consolePrint("Engine initialized"); #ifdef DUSK_ASSERTIONS_FAKED