Skip to content

Commit

Permalink
[CSM] add screenshot api lua (#5674)
Browse files Browse the repository at this point in the history
* [CSM] add screenshot api lua
  • Loading branch information
Dumbeldor authored and nerzhul committed Apr 29, 2017
1 parent b662a45 commit 19960e2
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions doc/client_lua_api.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,8 @@ class Client : public con::PeerHandler, public InventoryManager, public IGameDef
void showGameFog(const bool show = true);
void showGameDebug(const bool show = true);

IrrlichtDevice *getDevice() const { return m_device; }

private:

// Virtual methods from con::PeerHandler
Expand Down
8 changes: 8 additions & 0 deletions src/script/lua_api/l_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
}
2 changes: 2 additions & 0 deletions src/script/lua_api/l_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ class ModApiClient : public ModApiBase
// 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);
};
Expand Down

0 comments on commit 19960e2

Please sign in to comment.