From 4f9797b6e87f62050863f5b17917603290f260c4 Mon Sep 17 00:00:00 2001 From: cora Date: Tue, 27 Oct 2020 15:20:32 +0100 Subject: lua api: add core.take_screenshot() --- src/script/lua_api/l_client.cpp | 10 ++++++++++ src/script/lua_api/l_client.h | 3 +++ 2 files changed, 13 insertions(+) (limited to 'src/script/lua_api') diff --git a/src/script/lua_api/l_client.cpp b/src/script/lua_api/l_client.cpp index 9961471ff..05bfcca52 100644 --- a/src/script/lua_api/l_client.cpp +++ b/src/script/lua_api/l_client.cpp @@ -524,6 +524,14 @@ int ModApiClient::l_get_objects_inside_radius(lua_State *L) return 1; } +//take_screenshot() +int ModApiClient::l_take_screenshot(lua_State *L) +{ + getClient(L)->makeScreenshot(); + lua_pushboolean(L, true); + return 1; +} + void ModApiClient::Initialize(lua_State *L, int top) { API_FCT(get_current_modname); @@ -558,4 +566,6 @@ void ModApiClient::Initialize(lua_State *L, int top) API_FCT(set_keypress); API_FCT(drop_selected_item); API_FCT(get_objects_inside_radius); + API_FCT(take_screenshot); + } diff --git a/src/script/lua_api/l_client.h b/src/script/lua_api/l_client.h index 5863e5717..04cc23041 100644 --- a/src/script/lua_api/l_client.h +++ b/src/script/lua_api/l_client.h @@ -126,6 +126,9 @@ private: // get_objects_inside_radius(pos, radius) static int l_get_objects_inside_radius(lua_State *L); + //take_screenshot() + static int l_take_screenshot(lua_State *L); + public: static void Initialize(lua_State *L, int top); }; -- cgit v1.2.3 From 28f6a79706b088c37268a59d90878220dc4ef9c7 Mon Sep 17 00:00:00 2001 From: corarona Date: Tue, 27 Oct 2020 15:36:07 +0100 Subject: lua api: add set/get_pitch --- src/script/lua_api/l_localplayer.cpp | 26 ++++++++++++++++++++++++++ src/script/lua_api/l_localplayer.h | 6 ++++++ 2 files changed, 32 insertions(+) (limited to 'src/script/lua_api') diff --git a/src/script/lua_api/l_localplayer.cpp b/src/script/lua_api/l_localplayer.cpp index 8057802a4..1d04e62db 100644 --- a/src/script/lua_api/l_localplayer.cpp +++ b/src/script/lua_api/l_localplayer.cpp @@ -95,6 +95,30 @@ int LuaLocalPlayer::l_set_yaw(lua_State *L) return 0; } +int LuaLocalPlayer::l_get_pitch(lua_State *L) +{ + LocalPlayer *player = getobject(L, 1); + + lua_pushinteger(L, player->getPitch()); + return 1; +} + + +int LuaLocalPlayer::l_set_pitch(lua_State *L) +{ + LocalPlayer *player = getobject(L, 1); + + if (lua_isnumber(L, 2)) { + int pitch = lua_tonumber(L, 2); + player->setPitch(pitch); + g_game->cam_view.camera_pitch = pitch; + g_game->cam_view_target.camera_pitch = pitch; + } + + return 0; +} + + int LuaLocalPlayer::l_get_hp(lua_State *L) { LocalPlayer *player = getobject(L, 1); @@ -527,6 +551,8 @@ const luaL_Reg LuaLocalPlayer::methods[] = { luamethod(LuaLocalPlayer, set_velocity), luamethod(LuaLocalPlayer, get_yaw), luamethod(LuaLocalPlayer, set_yaw), + luamethod(LuaLocalPlayer, get_pitch), + luamethod(LuaLocalPlayer, set_pitch), luamethod(LuaLocalPlayer, get_hp), luamethod(LuaLocalPlayer, get_name), luamethod(LuaLocalPlayer, get_wield_index), diff --git a/src/script/lua_api/l_localplayer.h b/src/script/lua_api/l_localplayer.h index 8daa901e0..1d7f9fcbd 100644 --- a/src/script/lua_api/l_localplayer.h +++ b/src/script/lua_api/l_localplayer.h @@ -44,6 +44,12 @@ private: // set_yaw(self, yaw) static int l_set_yaw(lua_State *L); + // get_pitch(self) + static int l_get_pitch(lua_State *L); + + // set_pitch(self,pitch) + static int l_set_pitch(lua_State *L); + // get_hp(self) static int l_get_hp(lua_State *L); -- cgit v1.2.3 From 60a9ff6fff844671164a2e710554a2c782cc6c5a Mon Sep 17 00:00:00 2001 From: corarona Date: Thu, 5 Nov 2020 11:54:23 +0100 Subject: api-screenshot: change function name to make_screenshot --- src/script/lua_api/l_client.cpp | 4 ++-- src/script/lua_api/l_client.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src/script/lua_api') diff --git a/src/script/lua_api/l_client.cpp b/src/script/lua_api/l_client.cpp index 05bfcca52..21fb9b140 100644 --- a/src/script/lua_api/l_client.cpp +++ b/src/script/lua_api/l_client.cpp @@ -524,8 +524,8 @@ int ModApiClient::l_get_objects_inside_radius(lua_State *L) return 1; } -//take_screenshot() -int ModApiClient::l_take_screenshot(lua_State *L) +//make_screenshot() +int ModApiClient::l_make_screenshot(lua_State *L) { getClient(L)->makeScreenshot(); lua_pushboolean(L, true); diff --git a/src/script/lua_api/l_client.h b/src/script/lua_api/l_client.h index 04cc23041..1cac0ec1f 100644 --- a/src/script/lua_api/l_client.h +++ b/src/script/lua_api/l_client.h @@ -126,8 +126,8 @@ private: // get_objects_inside_radius(pos, radius) static int l_get_objects_inside_radius(lua_State *L); - //take_screenshot() - static int l_take_screenshot(lua_State *L); + //make_screenshot() + static int l_make_screenshot(lua_State *L); public: static void Initialize(lua_State *L, int top); -- cgit v1.2.3 From 1bab49049bfc4bf89b4ee69fe734e2a79de0eb9f Mon Sep 17 00:00:00 2001 From: corarona Date: Thu, 5 Nov 2020 12:31:03 +0100 Subject: add LUA_FCT --- src/script/lua_api/l_client.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/script/lua_api') diff --git a/src/script/lua_api/l_client.cpp b/src/script/lua_api/l_client.cpp index 21fb9b140..6c4878873 100644 --- a/src/script/lua_api/l_client.cpp +++ b/src/script/lua_api/l_client.cpp @@ -566,6 +566,6 @@ void ModApiClient::Initialize(lua_State *L, int top) API_FCT(set_keypress); API_FCT(drop_selected_item); API_FCT(get_objects_inside_radius); - API_FCT(take_screenshot); + API_FCT(make_screenshot); } -- cgit v1.2.3