Player-World Interaction

From Minetest Developer Wiki
Jump to navigation Jump to search

TODO





Digging a node

Preconditions are a node somewhere in the world. This node is pointable, has a selection box, and can be dug by the hand or the tool the player is wearing. The player has interact priv and the tool has a tool range that the node can be pointed. The node is not stuck somewhere the player can't point it.

  • First look at the node, it becomes pointed.
Note that on android the node is pointed without looking (referring to the cross position) at it.
  • Then LMB is pressed down while holding an item which does not have on_use.
This makes the client send a punch event (client->interact(4, pointed), see game.cpp:3657 (28.02.2017)).
On server side the punch event is passed to mods, see on_punch and the deprecated register_on_punchnode.
  • Now continue looking at the node, i.e. keep pointing it, and hold down LMB.
Periodically client-side digging particles are spawned (if not disabled in the settings) and the node dig sound is played.
The dig sound is either the "dig" field in the "sounds" table in the nodedef
or, if it's not present, the client uses the sound "default_dig_${groupname}" (file name extension omitted here), where $groupname is one of the groups the node has, see (I forgot where in the source code it was).
The default_dig_ thing should be banned from source code in my opinion.