Skip to content

Commit c10e188

Browse files
committedFeb 1, 2020
Let node 'place' and 'dug' sounds be heard by other players
1 parent ace3c76 commit c10e188

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed
 

Diff for: ‎builtin/game/item.lua

+20-4
Original file line numberDiff line numberDiff line change
@@ -305,9 +305,6 @@ function core.item_place_node(itemstack, placer, pointed_thing, param2,
305305
return itemstack, nil
306306
end
307307

308-
log("action", playername .. " places node "
309-
.. def.name .. " at " .. core.pos_to_string(place_to))
310-
311308
local oldnode = core.get_node(place_to)
312309
local newnode = {name = def.name, param1 = 0, param2 = param2 or 0}
313310

@@ -333,7 +330,7 @@ function core.item_place_node(itemstack, placer, pointed_thing, param2,
333330
z = above.z - placer_pos.z
334331
}
335332
newnode.param2 = core.dir_to_facedir(dir)
336-
log("action", "facedir: " .. newnode.param2)
333+
log("info", "facedir: " .. newnode.param2)
337334
end
338335
end
339336

@@ -364,9 +361,20 @@ function core.item_place_node(itemstack, placer, pointed_thing, param2,
364361
return itemstack, nil
365362
end
366363

364+
log("action", playername .. " places node "
365+
.. def.name .. " at " .. core.pos_to_string(place_to))
366+
367367
-- Add node and update
368368
core.add_node(place_to, newnode)
369369

370+
-- Play sound if it was done by a player
371+
if playername ~= "" and def.sounds and def.sounds.place then
372+
core.sound_play(def.sounds.place, {
373+
pos = place_to,
374+
exclude_player = playername,
375+
}, true)
376+
end
377+
370378
local take_item = true
371379

372380
-- Run callback
@@ -606,6 +614,14 @@ function core.node_dig(pos, node, digger)
606614
-- Remove node and update
607615
core.remove_node(pos)
608616

617+
-- Play sound if it was done by a player
618+
if diggername ~= "" and def.sounds and def.sounds.dug then
619+
core.sound_play(def.sounds.dug, {
620+
pos = pos,
621+
exclude_player = diggername,
622+
}, true)
623+
end
624+
609625
-- Run callback
610626
if def and def.after_dig_node then
611627
-- Copy pos and node because callback can modify them

0 commit comments

Comments
 (0)
Please sign in to comment.