aboutsummaryrefslogtreecommitdiff
path: root/src/script/lua_api
diff options
context:
space:
mode:
Diffstat (limited to 'src/script/lua_api')
-rw-r--r--src/script/lua_api/l_client.cpp12
-rw-r--r--src/script/lua_api/l_client.h3
2 files changed, 15 insertions, 0 deletions
diff --git a/src/script/lua_api/l_client.cpp b/src/script/lua_api/l_client.cpp
index 6345fc75f..febf528de 100644
--- a/src/script/lua_api/l_client.cpp
+++ b/src/script/lua_api/l_client.cpp
@@ -36,12 +36,23 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "util/string.h"
#include "nodedef.h"
+// get_current_modname()
int ModApiClient::l_get_current_modname(lua_State *L)
{
lua_rawgeti(L, LUA_REGISTRYINDEX, CUSTOM_RIDX_CURRENT_MOD_NAME);
return 1;
}
+// get_modpath(modname)
+int ModApiClient::l_get_modpath(lua_State *L)
+{
+ std::string modname = readParam<std::string>(L, 1);
+ // Client mods use a virtual filesystem, see Client::scanModSubfolder()
+ std::string path = modname + ":";
+ lua_pushstring(L, path.c_str());
+ return 1;
+}
+
// get_last_run_mod()
int ModApiClient::l_get_last_run_mod(lua_State *L)
{
@@ -365,6 +376,7 @@ int ModApiClient::l_get_builtin_path(lua_State *L)
void ModApiClient::Initialize(lua_State *L, int top)
{
API_FCT(get_current_modname);
+ API_FCT(get_modpath);
API_FCT(print);
API_FCT(display_chat_message);
API_FCT(send_chat_message);
diff --git a/src/script/lua_api/l_client.h b/src/script/lua_api/l_client.h
index 0d3e6b106..0a68eeff0 100644
--- a/src/script/lua_api/l_client.h
+++ b/src/script/lua_api/l_client.h
@@ -30,6 +30,9 @@ private:
// get_current_modname()
static int l_get_current_modname(lua_State *L);
+ // get_modpath(modname)
+ static int l_get_modpath(lua_State *L);
+
// print(text)
static int l_print(lua_State *L);