From 66b3db360115de5d46cc036b2387810bf1460bd5 Mon Sep 17 00:00:00 2001 From: grorp Date: Wed, 21 Aug 2024 20:25:58 +0200 Subject: [PATCH] Fix mods folder being read twice with RUN_IN_PLACE=1 (#15024) --- doc/menu_lua_api.md | 2 +- src/script/lua_api/l_mainmenu.cpp | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/doc/menu_lua_api.md b/doc/menu_lua_api.md index 9f0e23a11..8f945052c 100644 --- a/doc/menu_lua_api.md +++ b/doc/menu_lua_api.md @@ -282,7 +282,7 @@ Package - content which is downloadable from the content db, may or may not be i ```lua { mods = "/home/user/.minetest/mods", - share = "/usr/share/minetest/mods", + share = "/usr/share/minetest/mods", -- only provided when RUN_IN_PLACE=0 -- Custom dirs can be specified by the MINETEST_MOD_DIR env variable ["/path/to/custom/dir"] = "/path/to/custom/dir", diff --git a/src/script/lua_api/l_mainmenu.cpp b/src/script/lua_api/l_mainmenu.cpp index 97101955a..78808792b 100644 --- a/src/script/lua_api/l_mainmenu.cpp +++ b/src/script/lua_api/l_mainmenu.cpp @@ -675,10 +675,12 @@ int ModApiMainMenu::l_get_modpaths(lua_State *L) ModApiMainMenu::l_get_modpath(L); lua_setfield(L, -2, "mods"); - std::string modpath = fs::RemoveRelativePathComponents( - porting::path_share + DIR_DELIM + "mods" + DIR_DELIM); - lua_pushstring(L, modpath.c_str()); - lua_setfield(L, -2, "share"); + if (porting::path_share != porting::path_user) { + std::string modpath = fs::RemoveRelativePathComponents( + porting::path_share + DIR_DELIM + "mods" + DIR_DELIM); + lua_pushstring(L, modpath.c_str()); + lua_setfield(L, -2, "share"); + } for (const std::string &component : getEnvModPaths()) { lua_pushstring(L, component.c_str());