diff --git a/NEWS b/NEWS index 3c53c5b5f..3f7588d9f 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,7 @@ DFHack future + Internals: + - support for global onLoadWorld.init and onUnloadWorld.init files, + called when loading and unloading a world DFHack 0.40.11-r1 diff --git a/library/Core.cpp b/library/Core.cpp index 01964139c..b6ae13ae1 100644 --- a/library/Core.cpp +++ b/library/Core.cpp @@ -1435,9 +1435,11 @@ static void handleLoadAndUnloadScripts(Core* core, color_ostream& out, state_cha std::string rawFolder = "data" + separator + "save" + separator + (df::global::world->cur_savegame.save_dir) + separator + "raw" + separator; switch(event) { case SC_WORLD_LOADED: + core->loadScriptFile(out, "onLoadWorld.init", true); core->loadScriptFile(out, rawFolder + "onLoad.init", true); break; case SC_WORLD_UNLOADED: + core->loadScriptFile(out, "onUnloadWorld.init", true); core->loadScriptFile(out, rawFolder + "onUnload.init", true); break; default: