aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPerttu Ahola <celeron55@gmail.com>2012-03-28 13:22:48 +0300
committerPerttu Ahola <celeron55@gmail.com>2012-03-28 13:22:48 +0300
commitae7aa65069983003343af8af5274df2e12ba5393 (patch)
tree6f621fa44f696f1c6bf037ef53a2b0ae5818ab11
parent9e0f969b8bd95dc700b3457886250fed9f318d05 (diff)
downloadminetest-ae7aa65069983003343af8af5274df2e12ba5393.tar.gz
minetest-ae7aa65069983003343af8af5274df2e12ba5393.tar.bz2
minetest-ae7aa65069983003343af8af5274df2e12ba5393.zip
Add minetest.is_singleplayer()
-rw-r--r--doc/lua_api.txt1
-rw-r--r--src/scriptapi.cpp8
-rw-r--r--src/server.h2
3 files changed, 11 insertions, 0 deletions
diff --git a/doc/lua_api.txt b/doc/lua_api.txt
index 9017eedd0..49da0089b 100644
--- a/doc/lua_api.txt
+++ b/doc/lua_api.txt
@@ -424,6 +424,7 @@ minetest.get_modpath(modname) -> eg. "/home/user/.minetest/usermods/modname"
^ Useful for loading additional .lua modules or static data from mod
minetest.get_worldpath() -> eg. "/home/user/.minetest/world"
^ Useful for storing custom data
+minetest.is_singleplayer()
minetest.debug(line)
^ Goes to dstream
diff --git a/src/scriptapi.cpp b/src/scriptapi.cpp
index 23c18473f..d2ded57c6 100644
--- a/src/scriptapi.cpp
+++ b/src/scriptapi.cpp
@@ -3840,6 +3840,13 @@ static int l_sound_stop(lua_State *L)
return 0;
}
+// is_singleplayer()
+static int l_is_singleplayer(lua_State *L)
+{
+ lua_pushboolean(L, get_server(L)->isSingleplayer());
+ return 1;
+}
+
static const struct luaL_Reg minetest_f [] = {
{"debug", l_debug},
{"log", l_log},
@@ -3859,6 +3866,7 @@ static const struct luaL_Reg minetest_f [] = {
{"get_worldpath", l_get_worldpath},
{"sound_play", l_sound_play},
{"sound_stop", l_sound_stop},
+ {"is_singleplayer", l_is_singleplayer},
{NULL, NULL}
};
diff --git a/src/server.h b/src/server.h
index 6c789f7b5..b827c5e27 100644
--- a/src/server.h
+++ b/src/server.h
@@ -583,6 +583,8 @@ public:
std::string getWorldPath(){ return m_path_world; }
+ bool isSingleplayer(){ return m_simple_singleplayer_mode; }
+
void setAsyncFatalError(const std::string &error)
{
m_async_fatal_error.set(error);