Skip to content

Commit f56c4ce

Browse files
committedJan 2, 2016
Merge branch 'HybridDog-noteblock_update'
2 parents 35b647e + 0ec503f commit f56c4ce

File tree

2 files changed

+47
-65
lines changed

2 files changed

+47
-65
lines changed
 

Diff for: ‎mesecons_noteblock/init.lua

+47-65
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,15 @@
11
minetest.register_node("mesecons_noteblock:noteblock", {
22
description = "Noteblock",
33
tiles = {"mesecons_noteblock.png"},
4-
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
5-
visual_scale = 1.3,
6-
paramtype="light",
7-
after_place_node = function(pos)
8-
minetest.add_node(pos, {name="mesecons_noteblock:noteblock", param2=0})
9-
end,
10-
on_punch = function (pos, node) -- change sound when punched
11-
local param2 = node.param2+1
12-
if param2==12 then param2=0 end
13-
minetest.add_node(pos, {name = node.name, param2 = param2})
14-
mesecon.noteblock_play(pos, param2)
4+
groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2},
5+
on_punch = function(pos, node) -- change sound when punched
6+
node.param2 = (node.param2+1)%12
7+
mesecon.noteblock_play(pos, node.param2)
8+
minetest.add_node(pos, node)
159
end,
1610
sounds = default.node_sound_wood_defaults(),
1711
mesecons = {effector = { -- play sound when activated
18-
action_on = function (pos, node)
12+
action_on = function(pos, node)
1913
mesecon.noteblock_play(pos, node.param2)
2014
end
2115
}}
@@ -30,58 +24,46 @@ minetest.register_craft({
3024
}
3125
})
3226

33-
mesecon.noteblock_play = function (pos, param2)
34-
local soundname
35-
if param2==8 then
36-
soundname="mesecons_noteblock_a"
37-
elseif param2==9 then
38-
soundname="mesecons_noteblock_asharp"
39-
elseif param2==10 then
40-
soundname="mesecons_noteblock_b"
41-
elseif param2==11 then
42-
soundname="mesecons_noteblock_c"
43-
elseif param2==0 then
44-
soundname="mesecons_noteblock_csharp"
45-
elseif param2==1 then
46-
soundname="mesecons_noteblock_d"
47-
elseif param2==2 then
48-
soundname="mesecons_noteblock_dsharp"
49-
elseif param2==3 then
50-
soundname="mesecons_noteblock_e"
51-
elseif param2==4 then
52-
soundname="mesecons_noteblock_f"
53-
elseif param2==5 then
54-
soundname="mesecons_noteblock_fsharp"
55-
elseif param2==6 then
56-
soundname="mesecons_noteblock_g"
57-
elseif param2==7 then
58-
soundname="mesecons_noteblock_gsharp"
59-
end
60-
local block_below_name = minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name
61-
if block_below_name == "default:glass" then
62-
soundname="mesecons_noteblock_hihat"
63-
end
64-
if block_below_name == "default:steelblock" then
65-
soundname=soundname.."2" -- Go up an octave.
66-
end
67-
if block_below_name == "default:stone" then
68-
soundname="mesecons_noteblock_kick"
69-
end
70-
if block_below_name == "default:lava_source" then
71-
soundname="fire_large"
72-
end
73-
if block_below_name == "default:chest" then
74-
soundname="mesecons_noteblock_snare"
75-
end
76-
if block_below_name == "default:tree" then
77-
soundname="mesecons_noteblock_crash"
78-
end
79-
if block_below_name == "default:wood" then
80-
soundname="mesecons_noteblock_litecrash"
81-
end
82-
if block_below_name == "default:coalblock" then
83-
soundname="tnt_explode"
27+
local soundnames = {
28+
[0] = "mesecons_noteblock_csharp",
29+
"mesecons_noteblock_d",
30+
"mesecons_noteblock_dsharp",
31+
"mesecons_noteblock_e",
32+
"mesecons_noteblock_f",
33+
"mesecons_noteblock_fsharp",
34+
"mesecons_noteblock_g",
35+
"mesecons_noteblock_gsharp",
36+
37+
"mesecons_noteblock_a",
38+
"mesecons_noteblock_asharp",
39+
"mesecons_noteblock_b",
40+
"mesecons_noteblock_c"
41+
}
42+
43+
local node_sounds = {
44+
["default:glass"] = "mesecons_noteblock_hihat",
45+
["default:stone"] = "mesecons_noteblock_kick",
46+
["default:lava_source"] = "fire_large",
47+
["default:chest"] = "mesecons_noteblock_snare",
48+
["default:tree"] = "mesecons_noteblock_crash",
49+
["default:wood"] = "mesecons_noteblock_litecrash",
50+
["default:coalblock"] = "tnt_explode",
51+
}
52+
53+
mesecon.noteblock_play = function(pos, param2)
54+
pos.y = pos.y-1
55+
local nodeunder = minetest.get_node(pos).name
56+
local soundname = node_sounds[nodeunder]
57+
if not soundname then
58+
soundname = soundnames[param2]
59+
if not soundname then
60+
minetest.log("error", "[mesecons_noteblock] No soundname found, test param2")
61+
return
62+
end
63+
if nodeunder == "default:steelblock" then
64+
soundname = soundname.. 2
65+
end
8466
end
85-
minetest.sound_play(soundname,
86-
{pos = pos, gain = 1.0, max_hear_distance = 32,})
67+
pos.y = pos.y+1
68+
minetest.sound_play(soundname, {pos = pos})
8769
end

Diff for: ‎mesecons_noteblock/textures/mesecons_noteblock.png

-11 Bytes
Loading

0 commit comments

Comments
 (0)
Please sign in to comment.