aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPerttu Ahola <celeron55@gmail.com>2012-02-28 20:41:26 +0200
committerPerttu Ahola <celeron55@gmail.com>2012-02-28 20:41:26 +0200
commitb7fd3c86693bcb53f66c6b4b2d83248c534aa17b (patch)
tree86e6b67c9398badf6483bd20836741133cdb87c1 /src
parentb3f4cbe15751dfbe6066211a809a56741a18627a (diff)
downloadminetest-b7fd3c86693bcb53f66c6b4b2d83248c534aa17b.tar.gz
minetest-b7fd3c86693bcb53f66c6b4b2d83248c534aa17b.tar.bz2
minetest-b7fd3c86693bcb53f66c6b4b2d83248c534aa17b.zip
Add minetest.get_worldpath() for getting location for custom data
Diffstat (limited to 'src')
-rw-r--r--src/scriptapi.cpp9
-rw-r--r--src/server.h2
2 files changed, 11 insertions, 0 deletions
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: