1
0
mirror of https://github.com/luanti-org/luanti.git synced 2025-10-14 17:15:21 +02:00

Define control(bits) as "unset" for entities (#11995)

This commit is contained in:
Lars Müller
2022-01-27 22:22:58 +01:00
committed by GitHub
parent 48e508052a
commit fe0b2d02bf
2 changed files with 22 additions and 16 deletions

View File

@@ -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();