Add minetest.is_singleplayer()
authorPerttu Ahola <celeron55@gmail.com>
Wed, 28 Mar 2012 10:22:48 +0000 (13:22 +0300)
committerPerttu Ahola <celeron55@gmail.com>
Wed, 28 Mar 2012 10:22:48 +0000 (13:22 +0300)
doc/lua_api.txt
src/scriptapi.cpp
src/server.h

index 9017eedd09aae359cd68cb1dc4f2a0f9727ed3a6..49da0089bbf0a083f09cb10e9b47fdc868259b88 100644 (file)
@@ -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
index 23c18473f3cd3b12cefa7f1b87f08f11cfe08dbc..d2ded57c6d7efdfeb668c24d87d6afe439ee6090 100644 (file)
@@ -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}
 };
 
index 6c789f7b5f0b7c5055b97f2b6c180efd545fddda..b827c5e27d0abbe81ec73dbd4c9cc3c563c8ad46 100644 (file)
@@ -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);