Can someone help me with code below?
This is simple decorative 'fireplace' block. I tried to add sound into 'right click' function. It's working but only when I trigger funcion by right click. If I restart the game, the sound isn't playing anymore.
I tried to study original 'fire' mod from Minitest game but it's a bit complicated.
- Code: Select all
minetest.register_node("my_mod:fireplace", {
description = "Fireplace",
tiles = {"fireplace_top.png", "fireplace_top.png", "fireplace_side.png", "fireplace_top.png", "fireplace_top.png", "fireplace_front.png"},
groups = {snappy=1,choppy=2,oddly_breakable_by_hand=2,flammable=3},
on_rightclick = function(pos,node, player, itemstack, pointed_thing)
minetest.swap_node(pos, {name="my_mod:fireplace_active"})
end
})
minetest.register_node("my_mod:fireplace_active", {
description = "Fireplace",
tiles = {
"fireplace_top.png", "fireplace_top.png", "fireplace_side.png", "fireplace_top.png", "fireplace_top.png",
{
image = "fireplace_active.png",
-- backface_culling = false,
animation = {
type = "vertical_frames",
aspect_w = 16,
aspect_h = 16,
length = 1.5
},
}
},
groups = {snappy=1,choppy=2,oddly_breakable_by_hand=2,flammable=3},
light_source = 8,
minetest.sound_play("fire",
{pos = pos, max_hear_distance = 16, gain = 1, loop = true}),
on_rightclick = function(pos,node, player, itemstack, pointed_thing)
minetest.swap_node(pos, {name="my_mod:fireplace"})
end
})
minetest.register_craft({
output = 'my_mod:fireplace',
recipe = {
{'default:wood', 'default:wood', 'default:wood'},
{'default:stone', 'default:coalblock', 'default:stone'},
{'default:stone', 'default:stone', 'default:stone'},
}
})