1 --create torch versions of the nodes
2 for name,def in pairs(minetest.registered_nodes) do
3 if def.drawtype == "normal" and string.match(name, "main:") then
4 local def2 = table.copy(def)
5 def2.groups.redstone_torch = 1
7 def2.mod_origin = "redstone"
8 def2.textures = "dirt.png"
9 local newname = "redstone:"..string.gsub(name, "main:", "")
11 minetest.register_node(newname,def2)
16 --this removes power from node that the switch is powering
17 local function on_lever_destroy(pos)
18 local param2 = minetest.get_node(pos).param2
19 local self = minetest.get_node(pos)
20 local dir = minetest.facedir_to_dir(self.param2)
22 local pos = vector.add(dir,pos)
23 local node = minetest.get_node(pos)
24 local name = node.name
26 local def = minetest.registered_nodes[name]
27 if def.drawtype == "normal" and string.match(name, "redstone:") then
28 name = "main:"..string.gsub(name, "redstone:", "")
29 minetest.set_node(pos, {name=name})
30 redstone.collect_info(pos)
35 minetest.register_node("redstone:switch_off", {
36 description = "Crafting Table",
37 tiles = {"stone.png"},
38 groups = {stone = 1, hard = 1, pickaxe = 1, hand = 4},
39 sounds = main.stoneSound(),
41 paramtype2 = "wallmounted",
42 sunlight_propagates = true,
45 drop="redstone:switch_off",
49 --left front bottom right back top
50 {-0.3, -0.5, -0.4, 0.3, -0.4, 0.4},
51 {-0.1, -0.5, -0.3, 0.1, 0, -0.1},
54 on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
55 minetest.sound_play("lever", {pos=pos})
56 minetest.set_node(pos, {name="redstone:switch_on",param2=node.param2})
57 local dir = minetest.facedir_to_dir(node.param2)
58 local pos = vector.add(dir,pos)
59 local name = minetest.get_node(pos).name
60 local def = minetest.registered_nodes[name]
62 if def.drawtype == "normal" and string.match(name, "main:") then
63 name = "redstone:"..string.gsub(name, "main:", "")
64 minetest.set_node(pos,{name=name})
65 redstone.collect_info(pos)
68 on_destruct = on_lever_destroy,
70 minetest.register_node("redstone:switch_on", {
71 description = "Crafting Table",
72 tiles = {"stone.png"},
73 groups = {stone = 1, hard = 1, pickaxe = 1, hand = 4},
74 sounds = main.stoneSound(),
76 paramtype2 = "wallmounted",
77 sunlight_propagates = true,
80 drop="redstone:switch_off",
84 --left front bottom right back top
85 {-0.3, -0.5, -0.4, 0.3, -0.4, 0.4},
86 {-0.1, -0.5, 0.3, 0.1, 0, 0.1},
89 on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
90 minetest.sound_play("lever", {pos=pos,pitch=0.8})
91 minetest.set_node(pos, {name="redstone:switch_off",param2=node.param2})
94 on_destruct = on_lever_destroy,