From 9fab5d594cab4c0a027f0aecf356382f3a37c1de Mon Sep 17 00:00:00 2001 From: emixa-d <85313564+emixa-d@users.noreply.github.com> Date: Wed, 6 Oct 2021 22:19:41 +0000 Subject: Add "MINETEST_MOD_PATH" environment variable (#11515) This adds an environment variable MINETEST_MOD_PATH. When it exists, Minetest will look there for mods in addition to ~/.minetest/mods/. --- src/script/lua_api/l_mainmenu.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/script/lua_api/l_mainmenu.cpp') diff --git a/src/script/lua_api/l_mainmenu.cpp b/src/script/lua_api/l_mainmenu.cpp index 6e9a5c34f..57fddc0be 100644 --- a/src/script/lua_api/l_mainmenu.cpp +++ b/src/script/lua_api/l_mainmenu.cpp @@ -502,6 +502,21 @@ int ModApiMainMenu::l_get_modpath(lua_State *L) return 1; } +/******************************************************************************/ +int ModApiMainMenu::l_get_modpaths(lua_State *L) +{ + int index = 1; + lua_newtable(L); + ModApiMainMenu::l_get_modpath(L); + lua_rawseti(L, -2, index); + for (const std::string &component : getEnvModPaths()) { + index++; + lua_pushstring(L, component.c_str()); + lua_rawseti(L, -2, index); + } + return 1; +} + /******************************************************************************/ int ModApiMainMenu::l_get_clientmodpath(lua_State *L) { @@ -856,6 +871,7 @@ void ModApiMainMenu::Initialize(lua_State *L, int top) API_FCT(get_mapgen_names); API_FCT(get_user_path); API_FCT(get_modpath); + API_FCT(get_modpaths); API_FCT(get_clientmodpath); API_FCT(get_gamepath); API_FCT(get_texturepath); @@ -889,6 +905,7 @@ void ModApiMainMenu::InitializeAsync(lua_State *L, int top) API_FCT(get_mapgen_names); API_FCT(get_user_path); API_FCT(get_modpath); + API_FCT(get_modpaths); API_FCT(get_clientmodpath); API_FCT(get_gamepath); API_FCT(get_texturepath); -- cgit v1.2.3