diff options
Diffstat (limited to 'noteblock.lua')
-rw-r--r-- | noteblock.lua | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/noteblock.lua b/noteblock.lua index 665c201..5bd0883 100644 --- a/noteblock.lua +++ b/noteblock.lua @@ -1,5 +1,5 @@ if not minetest.get_modpath("mesecons_noteblock") then - minetest.log("error","mesecons_noteblock is not installed - digilines noteblock will not be available!") + minetest.log("warning","mesecons_noteblock is not installed - digilines noteblock will not be available!") return end @@ -51,12 +51,23 @@ minetest.register_node("digistuff:noteblock", { if sound then minetest.sound_play(sound,{pos=pos}) end elseif type(msg) == "table" then if type(msg.sound) ~= "string" then return end + for _,i in ipairs({"pitch","speed","volume","gain",}) do + if type(msg[i]) == "string" then + msg[i] = tonumber(msg[i]) + end + end local sound = validnbsounds[msg.sound] + if not msg.volume then msg.volume = msg.gain end local volume = 1 if type(msg.volume) == "number" then volume = math.max(0,math.min(1,msg.volume)) end - if sound then minetest.sound_play({name=sound,gain=volume},{pos=pos}) end + if not msg.pitch then msg.pitch = msg.speed end + local pitch = 1 + if type(msg.pitch) == "number" then + pitch = math.max(0.05,math.min(10,msg.pitch)) + end + if sound then minetest.sound_play({name = sound,gain = volume,},{pos = pos,pitch = pitch,},true) end end end }, |