aboutsummaryrefslogtreecommitdiff
path: root/src/script/lua_api/l_localplayer.cpp
diff options
context:
space:
mode:
authorElias Fleckenstein <54945686+EliasFleckenstein03@users.noreply.github.com>2020-11-04 16:44:42 +0100
committerGitHub <noreply@github.com>2020-11-04 16:44:42 +0100
commit5d9ae5a91c544fc7fbd475decf47cef7e09ef8fc (patch)
treec980d614fec4a5495798be3e79e033229062c3cd /src/script/lua_api/l_localplayer.cpp
parent28f6a79706b088c37268a59d90878220dc4ef9c7 (diff)
parent3af10766fd2b58b068e970266724d7eb10e9316b (diff)
downloaddragonfireclient-5d9ae5a91c544fc7fbd475decf47cef7e09ef8fc.tar.xz
Merge branch 'master' into master
Diffstat (limited to 'src/script/lua_api/l_localplayer.cpp')
-rw-r--r--src/script/lua_api/l_localplayer.cpp31
1 files changed, 13 insertions, 18 deletions
diff --git a/src/script/lua_api/l_localplayer.cpp b/src/script/lua_api/l_localplayer.cpp
index 1d04e62db..d94668ed4 100644
--- a/src/script/lua_api/l_localplayer.cpp
+++ b/src/script/lua_api/l_localplayer.cpp
@@ -66,10 +66,10 @@ int LuaLocalPlayer::l_get_velocity(lua_State *L)
int LuaLocalPlayer::l_set_velocity(lua_State *L)
{
LocalPlayer *player = getobject(L, 1);
-
+
v3f pos = checkFloatPos(L, 2);
player->setSpeed(pos);
-
+
return 0;
}
@@ -91,7 +91,7 @@ int LuaLocalPlayer::l_set_yaw(lua_State *L)
g_game->cam_view.camera_yaw = yaw;
g_game->cam_view_target.camera_yaw = yaw;
}
-
+
return 0;
}
@@ -140,7 +140,7 @@ int LuaLocalPlayer::l_get_wield_index(lua_State *L)
{
LocalPlayer *player = getobject(L, 1);
- lua_pushinteger(L, player->getWieldIndex());
+ lua_pushinteger(L, player->getWieldIndex() + 1);
return 1;
}
@@ -148,8 +148,8 @@ int LuaLocalPlayer::l_get_wield_index(lua_State *L)
int LuaLocalPlayer::l_set_wield_index(lua_State *L)
{
LocalPlayer *player = getobject(L, 1);
- u32 index = luaL_checkinteger(L, 2);
-
+ u32 index = luaL_checkinteger(L, 2) - 1;
+
player->setWieldIndex(index);
g_game->processItemSelection(&g_game->runData.new_playeritem);
ItemStack selected_item, hand_item;
@@ -290,7 +290,7 @@ int LuaLocalPlayer::l_get_control(lua_State *L)
LocalPlayer *player = getobject(L, 1);
const PlayerControl &c = player->getPlayerControl();
- auto set = [L] (const char *name, bool value) {
+ auto set = [L](const char *name, bool value) {
lua_pushboolean(L, value);
lua_setfield(L, -2, name);
};
@@ -332,7 +332,7 @@ int LuaLocalPlayer::l_get_pos(lua_State *L)
int LuaLocalPlayer::l_set_pos(lua_State *L)
{
LocalPlayer *player = getobject(L, 1);
-
+
v3f pos = checkFloatPos(L, 2);
player->setPosition(pos);
getClient(L)->sendPlayerPos();
@@ -546,8 +546,7 @@ void LuaLocalPlayer::Register(lua_State *L)
}
const char LuaLocalPlayer::className[] = "LocalPlayer";
-const luaL_Reg LuaLocalPlayer::methods[] = {
- luamethod(LuaLocalPlayer, get_velocity),
+const luaL_Reg LuaLocalPlayer::methods[] = {luamethod(LuaLocalPlayer, get_velocity),
luamethod(LuaLocalPlayer, set_velocity),
luamethod(LuaLocalPlayer, get_yaw),
luamethod(LuaLocalPlayer, set_yaw),
@@ -573,18 +572,14 @@ const luaL_Reg LuaLocalPlayer::methods[] = {
luamethod(LuaLocalPlayer, get_last_look_vertical),
//
luamethod(LuaLocalPlayer, get_control),
- luamethod(LuaLocalPlayer, get_breath),
- luamethod(LuaLocalPlayer, get_pos),
+ luamethod(LuaLocalPlayer, get_breath), luamethod(LuaLocalPlayer, get_pos),
luamethod(LuaLocalPlayer, set_pos),
luamethod(LuaLocalPlayer, get_movement_acceleration),
luamethod(LuaLocalPlayer, get_movement_speed),
luamethod(LuaLocalPlayer, get_movement),
luamethod(LuaLocalPlayer, get_armor_groups),
- luamethod(LuaLocalPlayer, hud_add),
- luamethod(LuaLocalPlayer, hud_remove),
- luamethod(LuaLocalPlayer, hud_change),
- luamethod(LuaLocalPlayer, hud_get),
+ luamethod(LuaLocalPlayer, hud_add), luamethod(LuaLocalPlayer, hud_remove),
+ luamethod(LuaLocalPlayer, hud_change), luamethod(LuaLocalPlayer, hud_get),
luamethod(LuaLocalPlayer, get_object),
- {0, 0}
-};
+ {0, 0}};