[CSM] add screenshot api lua (#5674)
authorVincent Glize <vincentglize@hotmail.fr>
Sat, 29 Apr 2017 07:16:06 +0000 (09:16 +0200)
committerLoïc Blot <nerzhul@users.noreply.github.com>
Sat, 29 Apr 2017 07:16:06 +0000 (09:16 +0200)
* [CSM] add screenshot api lua

doc/client_lua_api.md
src/client.h
src/script/lua_api/l_client.cpp
src/script/lua_api/l_client.h

index b2aeb3f251b36b0dbe860b991b31bc89e130d02b..86fcd02a7e7a3845a5415156457462055be42a0f 100644 (file)
@@ -703,6 +703,8 @@ Call these functions only at load time!
 * `minetest.get_protocol_version()`
     * Returns the protocol version of the server.
     * Might not be accurate at start up as the client might not be connected to the server yet, in that case it will return 0.
+* `minetest.take_screenshot()`
+    * Take a screenshot.
 
 ### Misc.
 * `minetest.parse_json(string[, nullvalue])`: returns something
index 68953d40216fe3e2150bc44d28cab4f4944f50d9..699550eacec07b14329e8f6374041c6e45ab6630 100644 (file)
@@ -509,6 +509,8 @@ public:
        void showGameFog(const bool show = true);
        void showGameDebug(const bool show = true);
 
+       IrrlichtDevice *getDevice() const { return m_device; }
+
 private:
 
        // Virtual methods from con::PeerHandler
index 09ea5506b70dc75c65db55e89b138a6bb74c9e45..c982a2f1146cdc51613028b2dda0d8ebd831374b 100644 (file)
@@ -241,6 +241,13 @@ int ModApiClient::l_get_protocol_version(lua_State *L)
        return 1;
 }
 
+int ModApiClient::l_take_screenshot(lua_State *L)
+{
+       Client *client = getClient(L);
+       client->makeScreenshot(client->getDevice());
+       return 0;
+}
+
 void ModApiClient::Initialize(lua_State *L, int top)
 {
        API_FCT(get_current_modname);
@@ -259,4 +266,5 @@ void ModApiClient::Initialize(lua_State *L, int top)
        API_FCT(sound_play);
        API_FCT(sound_stop);
        API_FCT(get_protocol_version);
+       API_FCT(take_screenshot);
 }
index 478b8ed6c20d917697d37512b5e51cb1c78abf4f..6afcd996b7c137dca16dc9524545f201a075ffc9 100644 (file)
@@ -72,6 +72,8 @@ private:
        // get_protocol_version()
        static int l_get_protocol_version(lua_State *L);
 
+       static int l_take_screenshot(lua_State *L);
+
 public:
        static void Initialize(lua_State *L, int top);
 };