[CSM] add screenshot api lua (#5674)

* [CSM] add screenshot api lua
This commit is contained in:
Vincent Glize 2017-04-29 09:16:06 +02:00 committed by Loïc Blot
parent b662a4577d
commit 19960e26c6
4 changed files with 14 additions and 0 deletions

@ -703,6 +703,8 @@ Call these functions only at load time!
* `minetest.get_protocol_version()` * `minetest.get_protocol_version()`
* Returns the protocol version of the server. * 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. * 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. ### Misc.
* `minetest.parse_json(string[, nullvalue])`: returns something * `minetest.parse_json(string[, nullvalue])`: returns something

@ -509,6 +509,8 @@ public:
void showGameFog(const bool show = true); void showGameFog(const bool show = true);
void showGameDebug(const bool show = true); void showGameDebug(const bool show = true);
IrrlichtDevice *getDevice() const { return m_device; }
private: private:
// Virtual methods from con::PeerHandler // Virtual methods from con::PeerHandler

@ -241,6 +241,13 @@ int ModApiClient::l_get_protocol_version(lua_State *L)
return 1; 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) void ModApiClient::Initialize(lua_State *L, int top)
{ {
API_FCT(get_current_modname); API_FCT(get_current_modname);
@ -259,4 +266,5 @@ void ModApiClient::Initialize(lua_State *L, int top)
API_FCT(sound_play); API_FCT(sound_play);
API_FCT(sound_stop); API_FCT(sound_stop);
API_FCT(get_protocol_version); API_FCT(get_protocol_version);
API_FCT(take_screenshot);
} }

@ -72,6 +72,8 @@ private:
// get_protocol_version() // get_protocol_version()
static int l_get_protocol_version(lua_State *L); static int l_get_protocol_version(lua_State *L);
static int l_take_screenshot(lua_State *L);
public: public:
static void Initialize(lua_State *L, int top); static void Initialize(lua_State *L, int top);
}; };