aboutsummaryrefslogtreecommitdiff
path: root/builtin/game
diff options
context:
space:
mode:
authorsfan5 <sfan5@live.de>2020-01-25 21:49:27 +0100
committersfan5 <sfan5@live.de>2020-02-01 20:31:41 +0100
commitc10e188594d445c724de6b11fd70590bbe6b57d7 (patch)
treeb20dd49468b6754da4bb971683c29978838089ca /builtin/game
parentace3c76112a839aaad34f4343cd924412310bbd3 (diff)
downloadminetest-c10e188594d445c724de6b11fd70590bbe6b57d7.tar.gz
minetest-c10e188594d445c724de6b11fd70590bbe6b57d7.tar.bz2
minetest-c10e188594d445c724de6b11fd70590bbe6b57d7.zip
Let node 'place' and 'dug' sounds be heard by other players
Diffstat (limited to 'builtin/game')
-rw-r--r--builtin/game/item.lua24
1 files changed, 20 insertions, 4 deletions
diff --git a/builtin/game/item.lua b/builtin/game/item.lua
index d6c6469b3..3958cb66f 100644
--- a/builtin/game/item.lua
+++ b/builtin/game/item.lua
@@ -305,9 +305,6 @@ function core.item_place_node(itemstack, placer, pointed_thing, param2,
return itemstack, nil
end
- log("action", playername .. " places node "
- .. def.name .. " at " .. core.pos_to_string(place_to))
-
local oldnode = core.get_node(place_to)
local newnode = {name = def.name, param1 = 0, param2 = param2 or 0}
@@ -333,7 +330,7 @@ function core.item_place_node(itemstack, placer, pointed_thing, param2,
z = above.z - placer_pos.z
}
newnode.param2 = core.dir_to_facedir(dir)
- log("action", "facedir: " .. newnode.param2)
+ log("info", "facedir: " .. newnode.param2)
end
end
@@ -364,9 +361,20 @@ function core.item_place_node(itemstack, placer, pointed_thing, param2,
return itemstack, nil
end
+ log("action", playername .. " places node "
+ .. def.name .. " at " .. core.pos_to_string(place_to))
+
-- Add node and update
core.add_node(place_to, newnode)
+ -- Play sound if it was done by a player
+ if playername ~= "" and def.sounds and def.sounds.place then
+ core.sound_play(def.sounds.place, {
+ pos = place_to,
+ exclude_player = playername,
+ }, true)
+ end
+
local take_item = true
-- Run callback
@@ -606,6 +614,14 @@ function core.node_dig(pos, node, digger)
-- Remove node and update
core.remove_node(pos)
+ -- Play sound if it was done by a player
+ if diggername ~= "" and def.sounds and def.sounds.dug then
+ core.sound_play(def.sounds.dug, {
+ pos = pos,
+ exclude_player = diggername,
+ }, true)
+ end
+
-- Run callback
if def and def.after_dig_node then
-- Copy pos and node because callback can modify them