1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Introduce get_modpath() for CSM

This commit is contained in:
sfan5 2019-11-08 20:18:41 +01:00
parent 82a2e02323
commit b1f2a69382
5 changed files with 23 additions and 4 deletions

View file

@ -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);