1
0
Fork 0

Allow getting the path of builtin.lua using minetest.get_modpath("__builtin")

mutilcraft-mt53
Perttu Ahola 2012-04-01 10:08:52 +03:00
parent d5594e431c
commit 56ba193c77
3 changed files with 12 additions and 3 deletions

View File

@ -3928,8 +3928,13 @@ static int l_get_current_modname(lua_State *L)
// get_modpath(modname) // get_modpath(modname)
static int l_get_modpath(lua_State *L) static int l_get_modpath(lua_State *L)
{ {
const char *modname = luaL_checkstring(L, 1); std::string modname = luaL_checkstring(L, 1);
// Do it // Do it
if(modname == "__builtin"){
std::string path = get_server(L)->getBuiltinLuaPath();
lua_pushstring(L, path.c_str());
return 1;
}
const ModSpec *mod = get_server(L)->getModSpec(modname); const ModSpec *mod = get_server(L)->getModSpec(modname);
if(!mod){ if(!mod){
lua_pushnil(L); lua_pushnil(L);

View File

@ -964,8 +964,7 @@ Server::Server(
} }
// Path to builtin.lua // Path to builtin.lua
std::string builtinpath = porting::path_share + DIR_DELIM + "builtin" std::string builtinpath = getBuiltinLuaPath() + DIR_DELIM + "builtin.lua";
+ DIR_DELIM + "builtin.lua";
// Create world if it doesn't exist // Create world if it doesn't exist
if(!initializeWorld(m_path_world, m_gamespec.id)) if(!initializeWorld(m_path_world, m_gamespec.id))
@ -4410,6 +4409,10 @@ const ModSpec* Server::getModSpec(const std::string &modname)
} }
return NULL; return NULL;
} }
std::string Server::getBuiltinLuaPath()
{
return porting::path_share + DIR_DELIM + "builtin";
}
v3f findSpawnPos(ServerMap &map) v3f findSpawnPos(ServerMap &map)
{ {

View File

@ -553,6 +553,7 @@ public:
IWritableCraftDefManager* getWritableCraftDefManager(); IWritableCraftDefManager* getWritableCraftDefManager();
const ModSpec* getModSpec(const std::string &modname); const ModSpec* getModSpec(const std::string &modname);
std::string getBuiltinLuaPath();
std::string getWorldPath(){ return m_path_world; } std::string getWorldPath(){ return m_path_world; }