From 62a1bd6970332cff890d64c88626833ee5ca4b60 Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Mon, 7 Aug 2023 17:18:00 -0700 Subject: [PATCH] ensure active mod scripts are properly reloaded --- docs/changelog.txt | 1 + library/lua/script-manager.lua | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/changelog.txt b/docs/changelog.txt index 1f9574ea8e..40449b3022 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -56,6 +56,7 @@ Template for new versions: ## New Features ## Fixes +- Core: properly reload scripts in mods when a world is unloaded and immediately loaded again ## Misc Improvements - `hotkeys`: don't display DFHack logo in legends mode since it covers up important interface elements. the Ctrl-Shift-C hotkey to bring up the menu and the mouseover hotspot still function, though. diff --git a/library/lua/script-manager.lua b/library/lua/script-manager.lua index 91b4985acb..c5d9fb3640 100644 --- a/library/lua/script-manager.lua +++ b/library/lua/script-manager.lua @@ -51,9 +51,10 @@ function reload(refresh_active_mod_scripts) enabled_map = utils.OrderedTable() local force_refresh_fn = refresh_active_mod_scripts and function(script_path, script_name) if script_path:find('scripts_modactive') then - internal_script = dfhack.internal.scripts[script_path..'/'..script_name] + local full_path = script_path..'/'..script_name + internal_script = dfhack.internal.scripts[full_path] if internal_script then - internal_script.env = nil + dfhack.internal.scripts[full_path] = nil end end end or nil