From ba697c0d334ea046d8ec4491d2de20c9d0b3b65d Mon Sep 17 00:00:00 2001 From: Xeno333 Date: Tue, 10 Jun 2025 21:30:06 -0500 Subject: [PATCH] Add error message --- builtin/mainmenu/dlg_create_world.lua | 3 ++- src/content/mod_configuration.cpp | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/builtin/mainmenu/dlg_create_world.lua b/builtin/mainmenu/dlg_create_world.lua index 30ec05fda..3f501d8ff 100644 --- a/builtin/mainmenu/dlg_create_world.lua +++ b/builtin/mainmenu/dlg_create_world.lua @@ -175,7 +175,8 @@ local function create_world_formspec(dialogdata) if not is_internal_mapgen then -- Select singlenode if using lua-defined mapgen -- Here we have to make sure it doesn't override an internal mapgen - if lua_mapgens[current_mapgen_internal] ~= nil and (current_mapgen == dialogdata.mg or lua_mapgens[current_mapgen_internal].title == dialogdata.mg) then + if lua_mapgens[current_mapgen_internal] ~= nil and + (current_mapgen == dialogdata.mg or lua_mapgens[current_mapgen_internal].title == dialogdata.mg) then current_mapgen_internal = "singlenode" end end diff --git a/src/content/mod_configuration.cpp b/src/content/mod_configuration.cpp index 054952547..c50a3994a 100644 --- a/src/content/mod_configuration.cpp +++ b/src/content/mod_configuration.cpp @@ -132,17 +132,22 @@ void ModConfiguration::addMapgenFromConfig( * * If the mod is enabled, add it to `mapgen_mod` and break */ + bool mapgen_found = false; for (const auto &mapgenPath : mapgenPaths) { std::vector addon_mods_in_path = flattenMods(getModsInPath(mapgenPath.second, mapgenPath.first)); for (const auto &mod : addon_mods_in_path) { if (mod.name == mapgen) { mapgen_mod.push_back(mod); + mapgen_found = true; break; } } } - addMods(mapgen_mod); + if (!mapgen_found) { + throw ModError("This world is configured to use a lua-defined mapgen: '" + mapgen + "' must be installed to load this world."); + } else + addMods(mapgen_mod); } void ModConfiguration::addModsFromConfig(