summaryrefslogtreecommitdiff
path: root/mesecons_noteblock
diff options
context:
space:
mode:
authorJeija <norrepli@gmail.com>2012-12-11 19:49:55 +0100
committerJeija <norrepli@gmail.com>2012-12-11 19:49:55 +0100
commitde46729b971b5e59394834b8a01d4a7005318114 (patch)
tree5a2cf1f18b485ddefa8e255ac6d6a600ef2e2e12 /mesecons_noteblock
parent31f3c99288355193dc68a6e83dfc63140fd02fa0 (diff)
parent5540fcbcb31eb32003fa0391113ed3b1dea25e47 (diff)
downloadmesecons-de46729b971b5e59394834b8a01d4a7005318114.tar
mesecons-de46729b971b5e59394834b8a01d4a7005318114.tar.gz
mesecons-de46729b971b5e59394834b8a01d4a7005318114.tar.bz2
mesecons-de46729b971b5e59394834b8a01d4a7005318114.tar.xz
mesecons-de46729b971b5e59394834b8a01d4a7005318114.zip
Merge branch 'mesecons_in_nodedef'
Conflicts: mesecons/internal.lua
Diffstat (limited to 'mesecons_noteblock')
-rw-r--r--mesecons_noteblock/init.lua31
1 files changed, 13 insertions, 18 deletions
diff --git a/mesecons_noteblock/init.lua b/mesecons_noteblock/init.lua
index 0b05bbb..073524c 100644
--- a/mesecons_noteblock/init.lua
+++ b/mesecons_noteblock/init.lua
@@ -1,15 +1,25 @@
minetest.register_node("mesecons_noteblock:noteblock", {
description = "Noteblock",
tiles = {"mesecons_noteblock.png"},
- groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2, mesecon = 2},
+ groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
drawtype = "allfaces_optional",
visual_scale = 1.3,
paramtype="light",
after_place_node = function(pos)
minetest.env:add_node(pos, {name="mesecons_noteblock:noteblock", param2=0})
- end
+ end,
+ on_punch = function (pos, node) -- change sound when punched
+ local param2 = node.param2+1
+ if param2==12 then param2=0 end
+ minetest.env:add_node(pos, {name = node.name, param2 = param2})
+ mesecon.noteblock_play(pos, param2)
+ end,
+ mesecons = {effector = { -- play sound when activated
+ action_on = function (pos, node)
+ mesecon.noteblock_play(pos, node.param2)
+ end
+ }}
})
-mesecon:register_effector("mesecons_noteblock:noteblock", "mesecons_noteblock:noteblock")
minetest.register_craft({
output = '"mesecons_noteblock:noteblock" 1',
@@ -20,15 +30,6 @@ minetest.register_craft({
}
})
-minetest.register_on_punchnode(function (pos, node)
- if node.name=="mesecons_noteblock:noteblock" then
- local param2 = node.param2+1
- if param2==12 then param2=0 end
- minetest.env:add_node(pos, {name=node.name, param2=param2})
- mesecon.noteblock_play(pos, param2)
- end
-end)
-
mesecon.noteblock_play = function (pos, param2)
local soundname
if param2==8 then
@@ -75,9 +76,3 @@ mesecon.noteblock_play = function (pos, param2)
minetest.sound_play(soundname,
{pos = pos, gain = 1.0, max_hear_distance = 32,})
end
-
-mesecon:register_on_signal_on(function(pos, node)
- if node.name=="mesecons_noteblock:noteblock" then
- mesecon.noteblock_play(pos, node.param2)
- end
-end)