From 34d4537a11e8d880fb45009605daaf944e2609f2 Mon Sep 17 00:00:00 2001 From: lethosor Date: Sat, 30 Aug 2014 22:37:23 -0400 Subject: [PATCH] Support for global onLoadWorld.init/onUnloadWorld.init scripts --- NEWS | 2 ++ library/Core.cpp | 2 ++ 2 files changed, 4 insertions(+) diff --git a/NEWS b/NEWS index 4867b2948..ea9961b99 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,8 @@ DFHack future Internals: - Plugins on OS X now use ".plug.dylib" as an extension instead of ".plug.so" + - support for global onLoadWorld.init and onUnloadWorld.init files, + called when loading and unloading a world Fixes: - hack-wish should work now 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: