Fix double lantern sound if placing

This commit is contained in:
Wuzzy 2023-07-03 16:00:49 +02:00
parent 469fc6b1f8
commit c010f33465

View File

@ -504,10 +504,15 @@ xdecor.register("lantern", {
local down = vector.new(pointed_thing.above.x, pointed_thing.above.y-1, pointed_thing.above.z) local down = vector.new(pointed_thing.above.x, pointed_thing.above.y-1, pointed_thing.above.z)
local downnode = minetest.get_node(down) local downnode = minetest.get_node(down)
local downdef = minetest.registered_nodes[downnode.name] local downdef = minetest.registered_nodes[downnode.name]
local sound_play = false
if pointed_thing.under.y > pointed_thing.above.y then if pointed_thing.under.y > pointed_thing.above.y then
nodename = "xdecor:lantern_hanging" nodename = "xdecor:lantern_hanging"
if downdef and not downdef.walkable then
sound_play = true
end
elseif downdef and not downdef.walkable and updef and updef.walkable then elseif downdef and not downdef.walkable and updef and updef.walkable then
nodename = "xdecor:lantern_hanging" nodename = "xdecor:lantern_hanging"
sound_play = true
else else
nodename = "xdecor:lantern" nodename = "xdecor:lantern"
end end
@ -520,8 +525,7 @@ xdecor.register("lantern", {
itemstack:take_item() itemstack:take_item()
end end
-- Play 'place' sound manually if needed if sound_play then
if nodename == "xdecor:lantern_hanging" then
minetest.sound_play(default.node_sound_metal_defaults().place, {pos=place_pos}, true) minetest.sound_play(default.node_sound_metal_defaults().place, {pos=place_pos}, true)
end end