---this removes power from node that the switch is powering
+local minetest,table,vector = minetest,table,vector
+--this removes power from node that the button is powering
local function on_button_destroy(pos)
local param2 = minetest.get_node(pos).param2
- local self = minetest.get_node(pos)
- local dir = minetest.facedir_to_dir(self.param2)
-
+ local dir = minetest.wallmounted_to_dir(param2)
local pos = vector.add(dir,pos)
local node = minetest.get_node(pos)
local name = node.name
-
local def = minetest.registered_nodes[name]
- if def.drawtype == "normal" and string.match(name, "redstone:") then
- name = "main:"..string.gsub(name, "redstone:", "")
+
+ if def.drawtype == "normal" and string.match(name, "redstone:node_activated_") then
+ name = "main:"..string.gsub(name, "redstone:node_activated_", "")
minetest.set_node(pos, {name=name})
redstone.collect_info(pos)
end
minetest.register_node("redstone:button_off", {
- description = "Crafting Table",
+ description = "Button",
tiles = {"stone.png"},
- groups = {stone = 1, hard = 1, pickaxe = 1, hand = 4,attached_node = 1},
+ groups = {stone = 1, hard = 1, pickaxe = 1, hand = 4,attached_node = 1,dig_immediate=1},
sounds = main.stoneSound(),
paramtype = "light",
paramtype2 = "wallmounted",
},
},
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
- minetest.sound_play("lever", {pos=pos})
minetest.set_node(pos, {name="redstone:button_on",param2=node.param2})
- local dir = minetest.facedir_to_dir(node.param2)
+ local dir = minetest.wallmounted_to_dir(node.param2)
local c_pos = table.copy(pos)
local pos = vector.add(dir,pos)
local name = minetest.get_node(pos).name
local def = minetest.registered_nodes[name]
if def.drawtype == "normal" and string.match(name, "main:") then
- name = "redstone:"..string.gsub(name, "main:", "")
+ minetest.sound_play("lever", {pos=pos})
+ name = "redstone:node_activated_"..string.gsub(name, "main:", "")
minetest.set_node(pos,{name=name})
redstone.collect_info(pos)
- local timer = minetest.get_node_timer(c_pos)
- timer:start(1)
+ else
+ minetest.sound_play("lever", {pos=pos,pitch=0.6})
end
+
+ local timer = minetest.get_node_timer(c_pos)
+ timer:start(1)
end,
on_destruct = on_button_destroy,
})
minetest.register_node("redstone:button_on", {
- description = "Crafting Table",
+ description = "Button",
tiles = {"stone.png"},
- groups = {stone = 1, hard = 1, pickaxe = 1, hand = 4,attached_node = 1},
+ groups = {stone = 1, hard = 1, pickaxe = 1, hand = 4,attached_node = 1,dig_immediate=1},
sounds = main.stoneSound(),
paramtype = "light",
paramtype2 = "wallmounted",