diff options
author | sfan5 <sfan5@live.de> | 2019-11-08 20:18:41 +0100 |
---|---|---|
committer | sfan5 <sfan5@live.de> | 2019-11-09 16:08:38 +0100 |
commit | b1f2a693820537c6ecd47b84056da136e2f9f563 (patch) | |
tree | 77699b68ef46d93b7f880ace49b976d7c359b7e4 /src/script | |
parent | 82a2e02323615473fc3039508b4c4529591e27d9 (diff) | |
download | minetest-b1f2a693820537c6ecd47b84056da136e2f9f563.tar.gz minetest-b1f2a693820537c6ecd47b84056da136e2f9f563.tar.bz2 minetest-b1f2a693820537c6ecd47b84056da136e2f9f563.zip |
Introduce get_modpath() for CSM
Diffstat (limited to 'src/script')
-rw-r--r-- | src/script/lua_api/l_client.cpp | 12 | ||||
-rw-r--r-- | src/script/lua_api/l_client.h | 3 |
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); |