summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLars Müller <34514239+appgurueu@users.noreply.github.com>2020-06-13 22:46:20 +0200
committerGitHub <noreply@github.com>2020-06-13 22:46:20 +0200
commite7e065f553b430173e9112ad55c7046cfc02f2c5 (patch)
treeea144e57f6753da91a4acd2efb1839e864dc5627 /src
parent2424dfe007e451bb02f87884c2b272cf307d6e7c (diff)
downloadminetest-e7e065f553b430173e9112ad55c7046cfc02f2c5.tar.gz
minetest-e7e065f553b430173e9112ad55c7046cfc02f2c5.tar.bz2
minetest-e7e065f553b430173e9112ad55c7046cfc02f2c5.zip
Exposing the zoom key to Lua API (#9903)
Co-authored-by: Raul Ferriz <raul.ferriz@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/client/game.cpp5
-rw-r--r--src/network/serverpackethandler.cpp1
-rw-r--r--src/script/lua_api/l_object.cpp2
3 files changed, 6 insertions, 2 deletions
diff --git a/src/client/game.cpp b/src/client/game.cpp
index 139742cec..069c482ca 100644
--- a/src/client/game.cpp
+++ b/src/client/game.cpp
@@ -2490,7 +2490,7 @@ void Game::updatePlayerControl(const CameraOrientation &cam)
input->joystick.getAxisWithoutDead(JA_FORWARD_MOVE)
);
- u32 keypress_bits =
+ u32 keypress_bits = (
( (u32)(isKeyDown(KeyType::FORWARD) & 0x1) << 0) |
( (u32)(isKeyDown(KeyType::BACKWARD) & 0x1) << 1) |
( (u32)(isKeyDown(KeyType::LEFT) & 0x1) << 2) |
@@ -2499,7 +2499,8 @@ void Game::updatePlayerControl(const CameraOrientation &cam)
( (u32)(isKeyDown(KeyType::SPECIAL1) & 0x1) << 5) |
( (u32)(isKeyDown(KeyType::SNEAK) & 0x1) << 6) |
( (u32)(input->getLeftState() & 0x1) << 7) |
- ( (u32)(input->getRightState() & 0x1) << 8
+ ( (u32)(input->getRightState() & 0x1) << 8) |
+ ( (u32)(isKeyDown(KeyType::ZOOM) & 0x1) << 9)
);
#ifdef ANDROID
diff --git a/src/network/serverpackethandler.cpp b/src/network/serverpackethandler.cpp
index fed3b6f85..b3008bb50 100644
--- a/src/network/serverpackethandler.cpp
+++ b/src/network/serverpackethandler.cpp
@@ -501,6 +501,7 @@ void Server::process_PlayerPos(RemotePlayer *player, PlayerSAO *playersao,
player->control.sneak = (keyPressed & 64);
player->control.LMB = (keyPressed & 128);
player->control.RMB = (keyPressed & 256);
+ player->control.zoom = (keyPressed & 512);
if (playersao->checkMovementCheat()) {
// Call callbacks
diff --git a/src/script/lua_api/l_object.cpp b/src/script/lua_api/l_object.cpp
index 0a9f3117b..e7394133a 100644
--- a/src/script/lua_api/l_object.cpp
+++ b/src/script/lua_api/l_object.cpp
@@ -1459,6 +1459,8 @@ int ObjectRef::l_get_player_control(lua_State *L)
lua_setfield(L, -2, "LMB");
lua_pushboolean(L, control.RMB);
lua_setfield(L, -2, "RMB");
+ lua_pushboolean(L, control.zoom);
+ lua_setfield(L, -2, "zoom");
return 1;
}