Add minetest.get_worldpath() for getting location for custom data
parent
b3f4cbe157
commit
b7fd3c8669
|
@ -118,6 +118,9 @@
|
||||||
-- {type="node", pos={x=, y=, z=}}
|
-- {type="node", pos={x=, y=, z=}}
|
||||||
-- minetest.get_current_modname() -> string
|
-- minetest.get_current_modname() -> string
|
||||||
-- minetest.get_modpath(modname) -> eg. "/home/user/.minetest/usermods/modname"
|
-- minetest.get_modpath(modname) -> eg. "/home/user/.minetest/usermods/modname"
|
||||||
|
-- ^ Useful for loading additional .lua modules or static data from mod
|
||||||
|
-- minetest.get_worldpath(modname) -> eg. "/home/user/.minetest/world"
|
||||||
|
-- ^ Useful for storing custom data
|
||||||
--
|
--
|
||||||
-- minetest.debug(line)
|
-- minetest.debug(line)
|
||||||
-- ^ Goes to dstream
|
-- ^ Goes to dstream
|
||||||
|
|
|
@ -540,5 +540,6 @@ minetest.register_abm({
|
||||||
|
|
||||||
print("experimental modname="..dump(minetest.get_current_modname()))
|
print("experimental modname="..dump(minetest.get_current_modname()))
|
||||||
print("experimental modpath="..dump(minetest.get_modpath("experimental")))
|
print("experimental modpath="..dump(minetest.get_modpath("experimental")))
|
||||||
|
print("experimental worldpath="..dump(minetest.get_worldpath()))
|
||||||
|
|
||||||
-- END
|
-- END
|
||||||
|
|
|
@ -3560,6 +3560,14 @@ static int l_get_modpath(lua_State *L)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// get_worldpath()
|
||||||
|
static int l_get_worldpath(lua_State *L)
|
||||||
|
{
|
||||||
|
std::string worldpath = get_server(L)->getWorldPath();
|
||||||
|
lua_pushstring(L, worldpath.c_str());
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
static const struct luaL_Reg minetest_f [] = {
|
static const struct luaL_Reg minetest_f [] = {
|
||||||
{"debug", l_debug},
|
{"debug", l_debug},
|
||||||
{"log", l_log},
|
{"log", l_log},
|
||||||
|
@ -3576,6 +3584,7 @@ static const struct luaL_Reg minetest_f [] = {
|
||||||
{"get_hitting_properties", l_get_hitting_properties},
|
{"get_hitting_properties", l_get_hitting_properties},
|
||||||
{"get_current_modname", l_get_current_modname},
|
{"get_current_modname", l_get_current_modname},
|
||||||
{"get_modpath", l_get_modpath},
|
{"get_modpath", l_get_modpath},
|
||||||
|
{"get_worldpath", l_get_worldpath},
|
||||||
{NULL, NULL}
|
{NULL, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -526,6 +526,8 @@ public:
|
||||||
|
|
||||||
const ModSpec* getModSpec(const std::string &modname);
|
const ModSpec* getModSpec(const std::string &modname);
|
||||||
|
|
||||||
|
std::string getWorldPath(){ return m_mapsavedir; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
// con::PeerHandler implementation.
|
// con::PeerHandler implementation.
|
||||||
|
|
Loading…
Reference in New Issue