aboutsummaryrefslogtreecommitdiff
path: root/src/script/lua_api
diff options
context:
space:
mode:
authoremixa-d <85313564+emixa-d@users.noreply.github.com>2021-10-06 22:19:41 +0000
committerGitHub <noreply@github.com>2021-10-07 00:19:41 +0200
commit9fab5d594cab4c0a027f0aecf356382f3a37c1de (patch)
treea5bed4dfac50fcd76464dfb2010713fa4265e5e2 /src/script/lua_api
parent53e126ac49807d066328377c7c06352b0fc1a380 (diff)
downloadminetest-9fab5d594cab4c0a027f0aecf356382f3a37c1de.tar.gz
minetest-9fab5d594cab4c0a027f0aecf356382f3a37c1de.tar.bz2
minetest-9fab5d594cab4c0a027f0aecf356382f3a37c1de.zip
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/.
Diffstat (limited to 'src/script/lua_api')
-rw-r--r--src/script/lua_api/l_mainmenu.cpp17
-rw-r--r--src/script/lua_api/l_mainmenu.h2
2 files changed, 19 insertions, 0 deletions
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
@@ -503,6 +503,21 @@ int ModApiMainMenu::l_get_modpath(lua_State *L)
}
/******************************************************************************/
+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)
{
std::string modpath = fs::RemoveRelativePathComponents(
@@ -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);
diff --git a/src/script/lua_api/l_mainmenu.h b/src/script/lua_api/l_mainmenu.h
index ec2d20da2..781185425 100644
--- a/src/script/lua_api/l_mainmenu.h
+++ b/src/script/lua_api/l_mainmenu.h
@@ -112,6 +112,8 @@ private:
static int l_get_modpath(lua_State *L);
+ static int l_get_modpaths(lua_State *L);
+
static int l_get_clientmodpath(lua_State *L);
static int l_get_gamepath(lua_State *L);