diff options
author | Elias Fleckenstein <eliasfleckenstein@web.de> | 2022-05-17 22:12:00 +0200 |
---|---|---|
committer | Elias Fleckenstein <eliasfleckenstein@web.de> | 2022-05-17 22:12:00 +0200 |
commit | 21df26984da91143c15587f5a03c98d68c3adc4e (patch) | |
tree | aaa707a628ad331f67890023dffe1b4f60dd01d3 /src/script/lua_api/l_localplayer.cpp | |
parent | b09fc5de5cdb021f43ad32b7e3f50dc75c0bc622 (diff) | |
parent | eabf05758e3ba5f6f4bb1b8d1d1f02179b84e410 (diff) | |
download | dragonfireclient-21df26984da91143c15587f5a03c98d68c3adc4e.tar.xz |
Merge branch 'master' of https://github.com/minetest/minetest
Diffstat (limited to 'src/script/lua_api/l_localplayer.cpp')
-rw-r--r-- | src/script/lua_api/l_localplayer.cpp | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/src/script/lua_api/l_localplayer.cpp b/src/script/lua_api/l_localplayer.cpp index 769b3ef2b..1da0679d6 100644 --- a/src/script/lua_api/l_localplayer.cpp +++ b/src/script/lua_api/l_localplayer.cpp @@ -196,11 +196,11 @@ int LuaLocalPlayer::l_is_in_liquid_stable(lua_State *L) return 1; } -int LuaLocalPlayer::l_get_liquid_viscosity(lua_State *L) +int LuaLocalPlayer::l_get_move_resistance(lua_State *L) { LocalPlayer *player = getobject(L, 1); - lua_pushinteger(L, player->liquid_viscosity); + lua_pushinteger(L, player->move_resistance); return 1; } @@ -302,13 +302,15 @@ int LuaLocalPlayer::l_get_control(lua_State *L) set("dig", c.dig); set("place", c.place); // Player movement in polar coordinates and non-binary speed - set("movement_speed", c.movement_speed); - set("movement_direction", c.movement_direction); + lua_pushnumber(L, c.movement_speed); + lua_setfield(L, -2, "movement_speed"); + lua_pushnumber(L, c.movement_direction); + lua_setfield(L, -2, "movement_direction"); // Provide direction keys to ensure compatibility - set("up", player->keyPressed & (1 << 0)); // Up, down, left, and right were removed in favor of - set("down", player->keyPressed & (1 << 1)); // analog direction indicators and are therefore not - set("left", player->keyPressed & (1 << 2)); // available as booleans anymore. The corresponding values - set("right", player->keyPressed & (1 << 3)); // can still be read from the keyPressed bits though. + set("up", c.direction_keys & (1 << 0)); + set("down", c.direction_keys & (1 << 1)); + set("left", c.direction_keys & (1 << 2)); + set("right", c.direction_keys & (1 << 3)); return 1; } @@ -576,7 +578,6 @@ const luaL_Reg LuaLocalPlayer::methods[] = { luamethod(LuaLocalPlayer, is_touching_ground), luamethod(LuaLocalPlayer, is_in_liquid), luamethod(LuaLocalPlayer, is_in_liquid_stable), - luamethod(LuaLocalPlayer, get_liquid_viscosity), luamethod(LuaLocalPlayer, is_climbing), luamethod(LuaLocalPlayer, swimming_vertical), luamethod(LuaLocalPlayer, get_physics_override), @@ -602,5 +603,7 @@ const luaL_Reg LuaLocalPlayer::methods[] = { luamethod(LuaLocalPlayer, get_object), luamethod(LuaLocalPlayer, get_hotbar_size), + luamethod(LuaLocalPlayer, get_move_resistance), + {0, 0} }; |