diff options
author | Jeija <norrepli@gmail.com> | 2012-12-09 00:42:30 +0100 |
---|---|---|
committer | Jeija <norrepli@gmail.com> | 2012-12-09 00:42:30 +0100 |
commit | b37bdbf55cf6d3205d5dd7a2491a8bd855cbbd76 (patch) | |
tree | ffc05ac9f096fc635535701cd287d4e5ad6b5073 /mesecons_noteblock/init.lua | |
parent | cf6080f7237af1c55a6d80bea4725dcb5c8cb1eb (diff) |
Port a lot more (basically everything apart from gates, pistons and extrawire crossing) to the new nodedef system. There are some problems with wall button and wall lever (in the way they visually connect to wires)
Diffstat (limited to 'mesecons_noteblock/init.lua')
-rw-r--r-- | mesecons_noteblock/init.lua | 31 |
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) |