From 19960e26c672c6337f8c6ffbe27f2c6bca49750c Mon Sep 17 00:00:00 2001 From: Vincent Glize Date: Sat, 29 Apr 2017 09:16:06 +0200 Subject: [CSM] add screenshot api lua (#5674) * [CSM] add screenshot api lua --- doc/client_lua_api.md | 2 ++ src/client.h | 2 ++ src/script/lua_api/l_client.cpp | 8 ++++++++ src/script/lua_api/l_client.h | 2 ++ 4 files changed, 14 insertions(+) diff --git a/doc/client_lua_api.md b/doc/client_lua_api.md index b2aeb3f25..86fcd02a7 100644 --- a/doc/client_lua_api.md +++ b/doc/client_lua_api.md @@ -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 diff --git a/src/client.h b/src/client.h index 68953d402..699550eac 100644 --- a/src/client.h +++ b/src/client.h @@ -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 diff --git a/src/script/lua_api/l_client.cpp b/src/script/lua_api/l_client.cpp index 09ea5506b..c982a2f11 100644 --- a/src/script/lua_api/l_client.cpp +++ b/src/script/lua_api/l_client.cpp @@ -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); } diff --git a/src/script/lua_api/l_client.h b/src/script/lua_api/l_client.h index 478b8ed6c..6afcd996b 100644 --- a/src/script/lua_api/l_client.h +++ b/src/script/lua_api/l_client.h @@ -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); }; -- cgit v1.2.3