aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data/mods/default/init.lua3
-rw-r--r--data/mods/experimental/init.lua1
-rw-r--r--src/scriptapi.cpp9
-rw-r--r--src/server.h2
4 files changed, 15 insertions, 0 deletions
diff --git a/data/mods/default/init.lua b/data/mods/default/init.lua
index d07337379..3f4a8175e 100644
--- a/data/mods/default/init.lua
+++ b/data/mods/default/init.lua
@@ -118,6 +118,9 @@
-- {type="node", pos={x=, y=, z=}}
-- minetest.get_current_modname() -> string
-- 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)
-- ^ Goes to dstream
diff --git a/data/mods/experimental/init.lua b/data/mods/experimental/init.lua
index 9a8f8868d..ddc89f92c 100644
--- a/data/mods/experimental/init.lua
+++ b/data/mods/experimental/init.lua
@@ -540,5 +540,6 @@ minetest.register_abm({
print("experimental modname="..dump(minetest.get_current_modname()))
print("experimental modpath="..dump(minetest.get_modpath("experimental")))
+print("experimental worldpath="..dump(minetest.get_worldpath()))
-- END
diff --git a/src/scriptapi.cpp b/src/scriptapi.cpp
index a064cd688..8350c75f1 100644
--- a/src/scriptapi.cpp
+++ b/src/scriptapi.cpp
@@ -3560,6 +3560,14 @@ static int l_get_modpath(lua_State *L)
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 [] = {
{"debug", l_debug},
{"log", l_log},
@@ -3576,6 +3584,7 @@ static const struct luaL_Reg minetest_f [] = {
{"get_hitting_properties", l_get_hitting_properties},
{"get_current_modname", l_get_current_modname},
{"get_modpath", l_get_modpath},
+ {"get_worldpath", l_get_worldpath},
{NULL, NULL}
};
diff --git a/src/server.h b/src/server.h
index 40f0fe582..04bd61a87 100644
--- a/src/server.h
+++ b/src/server.h
@@ -525,6 +525,8 @@ public:
IWritableCraftDefManager* getWritableCraftDefManager();
const ModSpec* getModSpec(const std::string &modname);
+
+ std::string getWorldPath(){ return m_mapsavedir; }
private: