Some noteblock code cleanup
This commit is contained in:
parent
6582f1445f
commit
41b7d1af3b
|
@ -62,6 +62,7 @@ mesecon.noteblock_play = function(pos, param2)
|
||||||
pos.y = pos.y-1
|
pos.y = pos.y-1
|
||||||
local nodeunder = minetest.get_node(pos).name
|
local nodeunder = minetest.get_node(pos).name
|
||||||
local soundname = node_sounds[nodeunder]
|
local soundname = node_sounds[nodeunder]
|
||||||
|
local use_pitch = true
|
||||||
local pitch
|
local pitch
|
||||||
-- Special sounds
|
-- Special sounds
|
||||||
if not soundname then
|
if not soundname then
|
||||||
|
@ -74,15 +75,6 @@ mesecon.noteblock_play = function(pos, param2)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
-- Piano
|
-- 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
|
if not soundname then
|
||||||
soundname = soundnames[param2]
|
soundname = soundnames[param2]
|
||||||
if not soundname then
|
if not soundname then
|
||||||
|
@ -92,16 +84,15 @@ mesecon.noteblock_play = function(pos, param2)
|
||||||
if nodeunder == "default:steelblock" then
|
if nodeunder == "default:steelblock" then
|
||||||
soundname = soundname.. 2
|
soundname = soundname.. 2
|
||||||
end
|
end
|
||||||
pitch = false
|
use_pitch = false
|
||||||
end
|
end
|
||||||
-- Disable pitch for fire and explode because they'd sound too odd
|
-- Disable pitch for fire and explode because they'd sound too odd
|
||||||
if soundname == "fire_fire" or soundname == "tnt_explode" then
|
if soundname == "fire_fire" or soundname == "tnt_explode" then
|
||||||
pitch = false
|
use_pitch = false
|
||||||
end
|
end
|
||||||
if pitch == false then
|
if use_pitch then
|
||||||
pitch = nil
|
|
||||||
else
|
|
||||||
-- Calculate pitch
|
-- Calculate pitch
|
||||||
|
-- Adding 1 to param2 because param2=11 is *lowest* pitch sound
|
||||||
local val = (param2+1)%12
|
local val = (param2+1)%12
|
||||||
-- All semitones from C to B (analog to piano mode)
|
-- All semitones from C to B (analog to piano mode)
|
||||||
pitch = 2^((val-6)/12)
|
pitch = 2^((val-6)/12)
|
||||||
|
|
Loading…
Reference in New Issue