Skip to content

Commit 19960e2

Browse files
Dumbeldornerzhul
authored andcommittedApr 29, 2017
[CSM] add screenshot api lua (#5674)
* [CSM] add screenshot api lua
1 parent b662a45 commit 19960e2

File tree

4 files changed

+14
-0
lines changed

4 files changed

+14
-0
lines changed
 

‎doc/client_lua_api.md

+2
Original file line numberDiff line numberDiff line change
@@ -703,6 +703,8 @@ Call these functions only at load time!
703703
* `minetest.get_protocol_version()`
704704
* Returns the protocol version of the server.
705705
* 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.
706+
* `minetest.take_screenshot()`
707+
* Take a screenshot.
706708

707709
### Misc.
708710
* `minetest.parse_json(string[, nullvalue])`: returns something

‎src/client.h

+2
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,8 @@ class Client : public con::PeerHandler, public InventoryManager, public IGameDef
509509
void showGameFog(const bool show = true);
510510
void showGameDebug(const bool show = true);
511511

512+
IrrlichtDevice *getDevice() const { return m_device; }
513+
512514
private:
513515

514516
// Virtual methods from con::PeerHandler

‎src/script/lua_api/l_client.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,13 @@ int ModApiClient::l_get_protocol_version(lua_State *L)
241241
return 1;
242242
}
243243

244+
int ModApiClient::l_take_screenshot(lua_State *L)
245+
{
246+
Client *client = getClient(L);
247+
client->makeScreenshot(client->getDevice());
248+
return 0;
249+
}
250+
244251
void ModApiClient::Initialize(lua_State *L, int top)
245252
{
246253
API_FCT(get_current_modname);
@@ -259,4 +266,5 @@ void ModApiClient::Initialize(lua_State *L, int top)
259266
API_FCT(sound_play);
260267
API_FCT(sound_stop);
261268
API_FCT(get_protocol_version);
269+
API_FCT(take_screenshot);
262270
}

‎src/script/lua_api/l_client.h

+2
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ class ModApiClient : public ModApiBase
7272
// get_protocol_version()
7373
static int l_get_protocol_version(lua_State *L);
7474

75+
static int l_take_screenshot(lua_State *L);
76+
7577
public:
7678
static void Initialize(lua_State *L, int top);
7779
};

0 commit comments

Comments
 (0)
Please sign in to comment.