aboutsummaryrefslogtreecommitdiff
path: root/src/script/lua_api/l_localplayer.cpp
diff options
context:
space:
mode:
authorsfan5 <sfan5@live.de>2022-01-09 18:46:36 +0100
committerGitHub <noreply@github.com>2022-01-09 18:46:36 +0100
commit5eb45e1ea03c6104f007efec6dd9c351f310193d (patch)
tree28a40addf99493aedfbf67e4d85fa6cf88723419 /src/script/lua_api/l_localplayer.cpp
parent76dbd0d2d04712dcad4f7c6afecb97fa8d662d6d (diff)
downloadminetest-5eb45e1ea03c6104f007efec6dd9c351f310193d.tar.gz
minetest-5eb45e1ea03c6104f007efec6dd9c351f310193d.tar.bz2
minetest-5eb45e1ea03c6104f007efec6dd9c351f310193d.zip
Restore pass-through of direction keys (#11924)
This moves relevant code into the PlayerControl class and gets rid of separate keyPressed variable.
Diffstat (limited to 'src/script/lua_api/l_localplayer.cpp')
-rw-r--r--src/script/lua_api/l_localplayer.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/script/lua_api/l_localplayer.cpp b/src/script/lua_api/l_localplayer.cpp
index bdbe98cb0..2efb976c7 100644
--- a/src/script/lua_api/l_localplayer.cpp
+++ b/src/script/lua_api/l_localplayer.cpp
@@ -230,13 +230,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;
}