lua_localplayer: add get_pitch(), use floats instead of ints for pitch/yaw

This commit is contained in:
cron 2020-11-03 19:01:13 +00:00 committed by Schmappie Eldress
parent d791294319
commit 481f71967b
2 changed files with 18 additions and 3 deletions

View File

@ -78,7 +78,15 @@ int LuaLocalPlayer::l_get_yaw(lua_State *L)
{
LocalPlayer *player = getobject(L, 1);
lua_pushinteger(L, player->getYaw());
lua_pushnumber(L, player->getYaw());
return 1;
}
int LuaLocalPlayer::l_get_pitch(lua_State *L)
{
LocalPlayer *player = getobject(L, 1);
lua_pushnumber(L, player->getPitch());
return 1;
}
@ -305,7 +313,7 @@ int LuaLocalPlayer::l_set_pos(lua_State *L)
int LuaLocalPlayer::l_set_yaw(lua_State *L)
{
LocalPlayer *player = getobject(L, 1);
f32 p = (float) luaL_checkinteger(L, 2);
f32 p = (float) luaL_checknumber(L, 2);
player->setYaw(p);
//* 0.01745329252f;
g_game->cam_view.camera_yaw = p;
@ -316,7 +324,7 @@ int LuaLocalPlayer::l_set_yaw(lua_State *L)
int LuaLocalPlayer::l_set_pitch(lua_State *L)
{
LocalPlayer *player = getobject(L, 1);
f32 p = (float) luaL_checkinteger(L, 2);
f32 p = (float) luaL_checknumber(L, 2);
player->setPitch(p);
//* 0.01745329252f ;
g_game->cam_view.camera_pitch = p;
@ -583,6 +591,7 @@ const luaL_Reg LuaLocalPlayer::methods[] = {
luamethod(LuaLocalPlayer, set_pos),
luamethod(LuaLocalPlayer, get_yaw),
luamethod(LuaLocalPlayer, set_yaw),
luamethod(LuaLocalPlayer, get_pitch),
luamethod(LuaLocalPlayer, set_pitch),
luamethod(LuaLocalPlayer, get_movement_acceleration),
luamethod(LuaLocalPlayer, get_movement_speed),

View File

@ -85,7 +85,13 @@ private:
// get_yaw(self)
static int l_get_yaw(lua_State *L);
// 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_movement_acceleration(self)