1 --this removes power from node that the button is powering
2 local function on_button_destroy(pos)
3 local param2 = minetest.get_node(pos).param2
4 local dir = minetest.wallmounted_to_dir(param2)
5 local pos = vector.add(dir,pos)
6 local node = minetest.get_node(pos)
8 local def = minetest.registered_nodes[name]
10 if def.drawtype == "normal" and string.match(name, "redstone:node_activated_") then
11 name = "main:"..string.gsub(name, "redstone:node_activated_", "")
12 minetest.set_node(pos, {name=name})
13 redstone.collect_info(pos)
18 minetest.register_node("redstone:button_off", {
19 description = "Crafting Table",
20 tiles = {"stone.png"},
21 groups = {stone = 1, hard = 1, pickaxe = 1, hand = 4,attached_node = 1,dig_immediate=1},
22 sounds = main.stoneSound(),
24 paramtype2 = "wallmounted",
25 sunlight_propagates = true,
28 drop="redstone:button_off",
32 --left front bottom right back top
33 {-0.25, -0.5, -0.15, 0.25, -0.3, 0.15},
36 on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
37 minetest.set_node(pos, {name="redstone:button_on",param2=node.param2})
38 local dir = minetest.wallmounted_to_dir(node.param2)
39 local c_pos = table.copy(pos)
40 local pos = vector.add(dir,pos)
41 local name = minetest.get_node(pos).name
42 local def = minetest.registered_nodes[name]
44 if def.drawtype == "normal" and string.match(name, "main:") then
45 minetest.sound_play("lever", {pos=pos})
46 name = "redstone:node_activated_"..string.gsub(name, "main:", "")
47 minetest.set_node(pos,{name=name})
48 redstone.collect_info(pos)
50 minetest.sound_play("lever", {pos=pos,pitch=0.6})
53 local timer = minetest.get_node_timer(c_pos)
56 on_destruct = on_button_destroy,
58 minetest.register_node("redstone:button_on", {
59 description = "Crafting Table",
60 tiles = {"stone.png"},
61 groups = {stone = 1, hard = 1, pickaxe = 1, hand = 4,attached_node = 1,dig_immediate=1},
62 sounds = main.stoneSound(),
64 paramtype2 = "wallmounted",
65 sunlight_propagates = true,
68 drop="redstone:button_off",
72 --left front bottom right back top
73 {-0.25, -0.5, -0.15, 0.25, -0.45, 0.15},
76 on_timer = function(pos, elapsed)
77 minetest.sound_play("lever", {pos=pos,pitch=0.8})
78 local node = minetest.get_node(pos)
79 minetest.set_node(pos, {name="redstone:button_off",param2=node.param2})
80 on_button_destroy(pos)
82 on_destruct = on_button_destroy,