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 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'src/script/lua_api/l_localplayer.cpp') 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), -- cgit v1.2.3