mirror of
https://github.com/minetest-mods/mesecons.git
synced 2024-11-14 14:20:33 +01:00
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
|
||||
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)
|
||||
|
|
Loading…
Reference in New Issue
Block a user