From 41b7d1af3bd2d755bda6f84511ccaf3eb74adda6 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Wed, 15 Mar 2023 16:21:10 +0100 Subject: [PATCH] Some noteblock code cleanup --- mesecons_noteblock/init.lua | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/mesecons_noteblock/init.lua b/mesecons_noteblock/init.lua index 618fa91..43634e0 100644 --- a/mesecons_noteblock/init.lua +++ b/mesecons_noteblock/init.lua @@ -62,6 +62,7 @@ mesecon.noteblock_play = function(pos, param2) pos.y = pos.y-1 local nodeunder = minetest.get_node(pos).name local soundname = node_sounds[nodeunder] + local use_pitch = true local pitch -- Special sounds if not soundname then @@ -74,15 +75,6 @@ mesecon.noteblock_play = function(pos, param2) end end -- Piano - if not soundname then - for k,v in pairs(node_sounds_group) do - local g = minetest.get_item_group(nodeunder, k) - if g ~= 0 then - soundname = v - break - end - end - end if not soundname then soundname = soundnames[param2] if not soundname then @@ -92,16 +84,15 @@ mesecon.noteblock_play = function(pos, param2) if nodeunder == "default:steelblock" then soundname = soundname.. 2 end - pitch = false + use_pitch = false end -- Disable pitch for fire and explode because they'd sound too odd if soundname == "fire_fire" or soundname == "tnt_explode" then - pitch = false + use_pitch = false end - if pitch == false then - pitch = nil - else + if use_pitch then -- Calculate pitch + -- Adding 1 to param2 because param2=11 is *lowest* pitch sound local val = (param2+1)%12 -- All semitones from C to B (analog to piano mode) pitch = 2^((val-6)/12)