1 --this removes power from node that the switch is powering
2 local function on_button_destroy(pos)
3 local param2 = minetest.get_node(pos).param2
4 local self = minetest.get_node(pos)
5 local dir = minetest.wallmounted_to_dir(self.param2)
7 local pos = vector.add(dir,pos)
8 local node = minetest.get_node(pos)
11 local def = minetest.registered_nodes[name]
12 if def.drawtype == "normal" and string.match(name, "redstone:") then
13 name = "main:"..string.gsub(name, "redstone:", "")
14 minetest.set_node(pos, {name=name})
15 redstone.collect_info(pos)
20 minetest.register_node("redstone:button_off", {
21 description = "Crafting Table",
22 tiles = {"stone.png"},
23 groups = {stone = 1, hard = 1, pickaxe = 1, hand = 4,attached_node = 1},
24 sounds = main.stoneSound(),
26 paramtype2 = "wallmounted",
27 sunlight_propagates = true,
30 drop="redstone:button_off",
34 --left front bottom right back top
35 {-0.25, -0.5, -0.15, 0.25, -0.3, 0.15},
38 on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
39 minetest.sound_play("lever", {pos=pos})
40 minetest.set_node(pos, {name="redstone:button_on",param2=node.param2})
41 local dir = minetest.wallmounted_to_dir(node.param2)
42 local c_pos = table.copy(pos)
43 local pos = vector.add(dir,pos)
44 local name = minetest.get_node(pos).name
45 local def = minetest.registered_nodes[name]
47 if def.drawtype == "normal" and string.match(name, "main:") then
48 name = "redstone:"..string.gsub(name, "main:", "")
49 minetest.set_node(pos,{name=name})
50 redstone.collect_info(pos)
51 local timer = minetest.get_node_timer(c_pos)
55 on_destruct = on_button_destroy,
57 minetest.register_node("redstone:button_on", {
58 description = "Crafting Table",
59 tiles = {"stone.png"},
60 groups = {stone = 1, hard = 1, pickaxe = 1, hand = 4,attached_node = 1},
61 sounds = main.stoneSound(),
63 paramtype2 = "wallmounted",
64 sunlight_propagates = true,
67 drop="redstone:button_off",
71 --left front bottom right back top
72 {-0.25, -0.5, -0.15, 0.25, -0.45, 0.15},
75 on_timer = function(pos, elapsed)
76 minetest.sound_play("lever", {pos=pos,pitch=0.8})
77 local node = minetest.get_node(pos)
78 minetest.set_node(pos, {name="redstone:button_off",param2=node.param2})
79 on_button_destroy(pos)
81 on_destruct = on_button_destroy,