diff options
author | Elias Fleckenstein <54945686+EliasFleckenstein03@users.noreply.github.com> | 2020-11-05 14:08:25 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-05 14:08:25 +0100 |
commit | 91ad0d049706ed2892ba728cb8cad48480908027 (patch) | |
tree | 29dc1b440ab3ce2746fcf9135c7e0969ae002449 /src/script/lua_api/l_localplayer.cpp | |
parent | 6bda686c04e602c7e50d4838632d92c55b228c36 (diff) | |
parent | 1bab49049bfc4bf89b4ee69fe734e2a79de0eb9f (diff) | |
download | dragonfireclient-91ad0d049706ed2892ba728cb8cad48480908027.tar.xz |
Merge pull request #10 from corarona/master
lua api: set_pitch and make_screenshot
Diffstat (limited to 'src/script/lua_api/l_localplayer.cpp')
-rw-r--r-- | src/script/lua_api/l_localplayer.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/script/lua_api/l_localplayer.cpp b/src/script/lua_api/l_localplayer.cpp index e40dd7b37..8cd5d01e4 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), |