So, at end the code seems like that:
Code: Select all
local sound = 'no'
minetest.register_tool("headphones:1headphones", {
description = "Headphones Test Song",
inventory_image = "testh.bmp",
on_use = function()
if sound == 'no' then
sound = minetest.sound_play("test") --keep the "reference" of the sound
else
minestes.sound_stop(sound) --stop the sound
sound = 'no'
end
end,
})