Skip to content

Commit 291a6b7

Browse files
ClobberXDsamcaulfield
authored andcommittedAug 15, 2020
Allow binding dig, place actions to keys; remove LMB/RMB hardcoding
Co-authored-by: Sam Caulfield <sam@samcaulfield.com>
1 parent fff0393 commit 291a6b7

14 files changed

+284
-310
lines changed
 

‎builtin/settingtypes.txt

+11-3
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,9 @@ doubletap_jump (Double tap jump for fly) bool false
110110
# enabled.
111111
always_fly_fast (Always fly and fast) bool true
112112

113-
# The time in seconds it takes between repeated right clicks when holding the right
114-
# mouse button.
115-
repeat_rightclick_time (Rightclick repetition interval) float 0.25 0.001
113+
# The time in seconds it takes between repeated node placements when holding
114+
# the place button.
115+
repeat_place_time (Place repetition interval) float 0.25 0.001
116116

117117
# Automatically jump up single-node obstacles.
118118
autojump (Automatic jumping) bool false
@@ -182,6 +182,14 @@ keymap_jump (Jump key) key KEY_SPACE
182182
# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
183183
keymap_sneak (Sneak key) key KEY_LSHIFT
184184

185+
# Key for digging.
186+
# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
187+
keymap_dig (Dig key) key KEY_LBUTTON
188+
189+
# Key for placing.
190+
# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
191+
keymap_place (Place key) key KEY_RBUTTON
192+
185193
# Key for opening the inventory.
186194
# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
187195
keymap_inventory (Inventory key) key KEY_KEY_I

‎doc/client_lua_api.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1100,8 +1100,8 @@ Methods:
11001100
aux1 = boolean,
11011101
sneak = boolean,
11021102
zoom = boolean,
1103-
LMB = boolean,
1104-
RMB = boolean,
1103+
dig = boolean,
1104+
place = boolean,
11051105
}
11061106
```
11071107

‎doc/lua_api.txt

+16-8
Original file line numberDiff line numberDiff line change
@@ -6163,15 +6163,23 @@ object you are working with still exists.
61636163
* Only affects formspecs shown after this is called.
61646164
* `get_formspec_prepend(formspec)`: returns a formspec string.
61656165
* `get_player_control()`: returns table with player pressed keys
6166-
* The table consists of fields with boolean value representing the pressed
6167-
keys, the fields are jump, right, left, LMB, RMB, sneak, aux1, down, up, zoom.
6168-
* example: `{jump=false, right=true, left=false, LMB=false, RMB=false,
6169-
sneak=true, aux1=false, down=false, up=false, zoom=false}`
6170-
* The `zoom` field is available since 5.3
6166+
* The table consists of fields with the following boolean values
6167+
representing the pressed keys: `up`, `down`, `left`, `right`, `jump`,
6168+
`aux1`, `sneak`, `dig`, `place`, `LMB`, `RMB`, and `zoom`.
6169+
* The fields `LMB` and `RMB` are equal to `dig` and `place` respectively,
6170+
and exist only to preserve backwards compatibility.
61716171
* `get_player_control_bits()`: returns integer with bit packed player pressed
6172-
keys.
6173-
* bit nr/meaning: 0/up, 1/down, 2/left, 3/right, 4/jump, 5/aux1, 6/sneak,
6174-
7/LMB, 8/RMB, 9/zoom (zoom available since 5.3)
6172+
keys. Bits:
6173+
* 0 - up
6174+
* 1 - down
6175+
* 2 - left
6176+
* 3 - right
6177+
* 4 - jump
6178+
* 5 - aux1
6179+
* 6 - sneak
6180+
* 7 - dig
6181+
* 8 - place
6182+
* 9 - zoom
61756183
* `set_physics_override(override_table)`
61766184
* `override_table` is a table with the following fields:
61776185
* `speed`: multiplier to default walking speed value (default: `1`)

‎src/client/client.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1307,7 +1307,7 @@ void Client::sendPlayerPos()
13071307
player->last_pitch == player->getPitch() &&
13081308
player->last_yaw == player->getYaw() &&
13091309
player->last_keyPressed == player->keyPressed &&
1310-
player->last_camera_fov == camera_fov &&
1310+
player->last_camera_fov == camera_fov &&
13111311
player->last_wanted_range == wanted_range)
13121312
return;
13131313

‎src/client/content_cao.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -975,13 +975,13 @@ void GenericCAO::step(float dtime, ClientEnvironment *env)
975975
if (controls.sneak && walking)
976976
new_speed /= 2;
977977

978-
if (walking && (controls.LMB || controls.RMB)) {
978+
if (walking && (controls.dig || controls.place)) {
979979
new_anim = player->local_animations[3];
980980
player->last_animation = WD_ANIM;
981-
} else if(walking) {
981+
} else if (walking) {
982982
new_anim = player->local_animations[1];
983983
player->last_animation = WALK_ANIM;
984-
} else if(controls.LMB || controls.RMB) {
984+
} else if (controls.dig || controls.place) {
985985
new_anim = player->local_animations[2];
986986
player->last_animation = DIG_ANIM;
987987
}
@@ -1004,9 +1004,9 @@ void GenericCAO::step(float dtime, ClientEnvironment *env)
10041004

10051005
// Update local player animations
10061006
if ((player->last_animation != old_anim ||
1007-
m_animation_speed != old_anim_speed) &&
1008-
player->last_animation != NO_ANIM && allow_update)
1009-
updateAnimation();
1007+
m_animation_speed != old_anim_speed) &&
1008+
player->last_animation != NO_ANIM && allow_update)
1009+
updateAnimation();
10101010

10111011
}
10121012
}

0 commit comments

Comments
 (0)
Please sign in to comment.