aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLars Müller <34514239+appgurueu@users.noreply.github.com>2022-01-27 22:22:58 +0100
committerGitHub <noreply@github.com>2022-01-27 22:22:58 +0100
commitfe0b2d02bf07966ce4554578a1efd4b07bbb4734 (patch)
tree9f60414444efb632f6011787279a8aa0cf384f25 /src
parent48e508052ad477eda1142f08990d523c8b9701ea (diff)
downloadminetest-fe0b2d02bf07966ce4554578a1efd4b07bbb4734.tar.gz
minetest-fe0b2d02bf07966ce4554578a1efd4b07bbb4734.tar.bz2
minetest-fe0b2d02bf07966ce4554578a1efd4b07bbb4734.zip
Define control(bits) as "unset" for entities (#11995)
Diffstat (limited to 'src')
-rw-r--r--src/script/lua_api/l_object.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/script/lua_api/l_object.cpp b/src/script/lua_api/l_object.cpp
index b177a9f7e..407b48db0 100644
--- a/src/script/lua_api/l_object.cpp
+++ b/src/script/lua_api/l_object.cpp
@@ -1367,11 +1367,12 @@ int ObjectRef::l_get_player_control(lua_State *L)
NO_MAP_LOCK_REQUIRED;
ObjectRef *ref = checkobject(L, 1);
RemotePlayer *player = getplayer(ref);
- if (player == nullptr)
- return 0;
- const PlayerControl &control = player->getPlayerControl();
lua_newtable(L);
+ if (player == nullptr)
+ return 1;
+
+ const PlayerControl &control = player->getPlayerControl();
lua_pushboolean(L, control.direction_keys & (1 << 0));
lua_setfield(L, -2, "up");
lua_pushboolean(L, control.direction_keys & (1 << 1));
@@ -1406,8 +1407,10 @@ int ObjectRef::l_get_player_control_bits(lua_State *L)
NO_MAP_LOCK_REQUIRED;
ObjectRef *ref = checkobject(L, 1);
RemotePlayer *player = getplayer(ref);
- if (player == nullptr)
- return 0;
+ if (player == nullptr) {
+ lua_pushinteger(L, 0);
+ return 1;
+ }
const auto &c = player->getPlayerControl();