2015-06-29 20:55:56 +03:00
|
|
|
-- WALL BUTTON
|
|
|
|
-- A button that when pressed emits power for 1 second
|
|
|
|
-- and then turns off again
|
|
|
|
|
|
|
|
mesecon.button_turnoff = function (pos)
|
2017-01-11 20:21:46 +03:00
|
|
|
local node = minetest.get_node(pos)
|
2015-06-29 20:55:56 +03:00
|
|
|
if node.name=="mesecons_button:button_stone_on" then --has not been dug
|
|
|
|
mesecon:swap_node(pos, "mesecons_button:button_stone_off")
|
|
|
|
minetest.sound_play("mesecons_button_pop", {pos=pos})
|
|
|
|
local rules = mesecon.rules.buttonlike_get(node)
|
|
|
|
mesecon:receptor_off(pos, rules)
|
|
|
|
elseif node.name=="mesecons_button:button_wood_on" then --has not been dug
|
|
|
|
mesecon:swap_node(pos, "mesecons_button:button_wood_off")
|
|
|
|
minetest.sound_play("mesecons_button_pop", {pos=pos})
|
|
|
|
local rules = mesecon.rules.buttonlike_get(node)
|
|
|
|
mesecon:receptor_off(pos, rules)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
local boxes_off = { -4/16, -2/16, 8/16, 4/16, 2/16, 6/16 } -- The button
|
|
|
|
local boxes_on = { -4/16, -2/16, 8/16, 4/16, 2/16, 7/16 } -- The button
|
|
|
|
|
|
|
|
minetest.register_node("mesecons_button:button_stone_off", {
|
|
|
|
drawtype = "nodebox",
|
|
|
|
tiles = {"default_stone.png"},
|
2017-03-02 18:58:32 +03:00
|
|
|
wield_image = "default_stone.png^[mask:mesecons_button_wield_mask.png",
|
|
|
|
wield_scale = { x=1, y=1, z=1},
|
2015-06-29 20:55:56 +03:00
|
|
|
paramtype = "light",
|
|
|
|
paramtype2 = "facedir",
|
2017-01-05 00:36:51 +03:00
|
|
|
is_ground_content = false,
|
2015-06-29 20:55:56 +03:00
|
|
|
walkable = false,
|
|
|
|
sunlight_propagates = true,
|
|
|
|
selection_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = boxes_off
|
|
|
|
},
|
|
|
|
node_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = boxes_off -- the button itself
|
|
|
|
},
|
2017-02-27 03:52:24 +03:00
|
|
|
groups = {handy=1,pickaxey=1, attached_node=1, dig_by_water=1},
|
2015-06-29 20:55:56 +03:00
|
|
|
description = "Stone Button",
|
2017-02-05 19:57:33 +03:00
|
|
|
on_rightclick = function (pos, node)
|
2015-06-29 20:55:56 +03:00
|
|
|
mesecon:swap_node(pos, "mesecons_button:button_stone_on")
|
|
|
|
mesecon:receptor_on(pos, mesecon.rules.buttonlike_get(node))
|
|
|
|
minetest.sound_play("mesecons_button_push", {pos=pos})
|
|
|
|
minetest.after(1, mesecon.button_turnoff, pos)
|
|
|
|
end,
|
2017-02-11 20:46:23 +03:00
|
|
|
sounds = mcl_sounds.node_sound_stone_defaults(),
|
2015-06-29 20:55:56 +03:00
|
|
|
mesecons = {receptor = {
|
|
|
|
state = mesecon.state.off,
|
|
|
|
rules = mesecon.rules.buttonlike_get
|
2017-02-22 18:22:28 +03:00
|
|
|
}},
|
|
|
|
_mcl_blast_resistance = 2.5,
|
2017-02-27 03:52:24 +03:00
|
|
|
_mcl_hardness = 0.5,
|
2015-06-29 20:55:56 +03:00
|
|
|
})
|
|
|
|
|
|
|
|
minetest.register_node("mesecons_button:button_stone_on", {
|
|
|
|
drawtype = "nodebox",
|
|
|
|
tiles = {"default_stone.png"},
|
2017-03-02 18:58:32 +03:00
|
|
|
wield_image = "default_stone.png^[mask:mesecons_button_wield_mask.png",
|
|
|
|
wield_scale = { x=1, y=1, z=0.5},
|
2015-06-29 20:55:56 +03:00
|
|
|
paramtype = "light",
|
|
|
|
paramtype2 = "facedir",
|
2017-01-05 00:36:51 +03:00
|
|
|
is_ground_content = false,
|
2015-06-29 20:55:56 +03:00
|
|
|
walkable = false,
|
|
|
|
sunlight_propagates = true,
|
|
|
|
selection_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = boxes_on
|
|
|
|
},
|
|
|
|
node_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = boxes_on -- the button itself
|
|
|
|
},
|
2017-02-27 03:52:24 +03:00
|
|
|
groups = {handy=1,pickaxey=1, not_in_creative_inventory=1, attached_node=1, dig_by_water=1},
|
2015-06-29 20:55:56 +03:00
|
|
|
drop = 'mesecons_button:button_stone_off',
|
|
|
|
description = "Stone Button",
|
2017-02-11 20:46:23 +03:00
|
|
|
sounds = mcl_sounds.node_sound_stone_defaults(),
|
2015-06-29 20:55:56 +03:00
|
|
|
mesecons = {receptor = {
|
|
|
|
state = mesecon.state.on,
|
|
|
|
rules = mesecon.rules.buttonlike_get
|
2017-02-22 18:22:28 +03:00
|
|
|
}},
|
|
|
|
_mcl_blast_resistance = 2.5,
|
2017-02-27 03:52:24 +03:00
|
|
|
_mcl_hardness = 0.5,
|
2015-06-29 20:55:56 +03:00
|
|
|
})
|
|
|
|
|
|
|
|
minetest.register_node("mesecons_button:button_wood_off", {
|
|
|
|
drawtype = "nodebox",
|
|
|
|
tiles = {"default_wood.png"},
|
2017-03-02 18:58:32 +03:00
|
|
|
wield_image = "default_wood.png^[mask:mesecons_button_wield_mask.png",
|
|
|
|
wield_scale = { x=1, y=1, z=1},
|
2015-06-29 20:55:56 +03:00
|
|
|
paramtype = "light",
|
|
|
|
paramtype2 = "facedir",
|
2017-01-05 00:36:51 +03:00
|
|
|
is_ground_content = false,
|
2015-06-29 20:55:56 +03:00
|
|
|
walkable = false,
|
|
|
|
sunlight_propagates = true,
|
|
|
|
selection_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = boxes_off
|
|
|
|
},
|
|
|
|
node_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = boxes_off -- the button itself
|
|
|
|
},
|
2017-02-27 03:52:24 +03:00
|
|
|
groups = {handy=1,axey=1, attached_node=1, dig_by_water=1},
|
2017-01-12 02:27:26 +03:00
|
|
|
description = "Wooden Button",
|
2017-01-12 02:30:28 +03:00
|
|
|
on_rightclick = function (pos, node)
|
2015-06-29 20:55:56 +03:00
|
|
|
mesecon:swap_node(pos, "mesecons_button:button_wood_on")
|
|
|
|
mesecon:receptor_on(pos, mesecon.rules.buttonlike_get(node))
|
|
|
|
minetest.sound_play("mesecons_button_push", {pos=pos})
|
|
|
|
minetest.after(1, mesecon.button_turnoff, pos)
|
|
|
|
end,
|
2017-02-11 20:46:23 +03:00
|
|
|
sounds = mcl_sounds.node_sound_wood_defaults(),
|
2015-06-29 20:55:56 +03:00
|
|
|
mesecons = {receptor = {
|
|
|
|
state = mesecon.state.off,
|
|
|
|
rules = mesecon.rules.buttonlike_get
|
2017-02-22 18:22:28 +03:00
|
|
|
}},
|
|
|
|
_mcl_blast_resistance = 2.5,
|
2017-02-27 03:52:24 +03:00
|
|
|
_mcl_hardness = 0.5,
|
2015-06-29 20:55:56 +03:00
|
|
|
})
|
|
|
|
|
|
|
|
minetest.register_node("mesecons_button:button_wood_on", {
|
|
|
|
drawtype = "nodebox",
|
|
|
|
tiles = {"default_wood.png"},
|
2017-03-02 18:58:32 +03:00
|
|
|
wield_image = "default_wood.png^[mask:mesecons_button_wield_mask.png",
|
|
|
|
wield_scale = { x=1, y=1, z=0.5},
|
2015-06-29 20:55:56 +03:00
|
|
|
paramtype = "light",
|
|
|
|
paramtype2 = "facedir",
|
2017-01-05 00:36:51 +03:00
|
|
|
is_ground_content = false,
|
2015-06-29 20:55:56 +03:00
|
|
|
walkable = false,
|
|
|
|
sunlight_propagates = true,
|
|
|
|
selection_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = boxes_on
|
|
|
|
},
|
|
|
|
node_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = boxes_on -- the button itself
|
|
|
|
},
|
2017-02-27 03:52:24 +03:00
|
|
|
groups = {handy=1,axey=1, not_in_creative_inventory=1, attached_node=1, dig_by_water=1},
|
2015-06-29 20:55:56 +03:00
|
|
|
drop = 'mesecons_button:button_wood_off',
|
2017-01-12 02:27:26 +03:00
|
|
|
description = "Wooden Button",
|
2017-02-11 20:46:23 +03:00
|
|
|
sounds = mcl_sounds.node_sound_wood_defaults(),
|
2015-06-29 20:55:56 +03:00
|
|
|
mesecons = {receptor = {
|
|
|
|
state = mesecon.state.on,
|
|
|
|
rules = mesecon.rules.buttonlike_get
|
2017-02-22 18:22:28 +03:00
|
|
|
}},
|
|
|
|
_mcl_blast_resistance = 2.5,
|
2017-02-27 03:52:24 +03:00
|
|
|
_mcl_hardness = 0.5,
|
2015-06-29 20:55:56 +03:00
|
|
|
})
|
|
|
|
|
|
|
|
minetest.register_craft({
|
|
|
|
output = 'mesecons_button:button_stone_off',
|
|
|
|
recipe = {
|
2017-02-01 01:32:56 +03:00
|
|
|
{'mcl_core:stone'},
|
2015-06-29 20:55:56 +03:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
minetest.register_craft({
|
|
|
|
output = 'mesecons_button:button_wood_off',
|
|
|
|
recipe = {
|
|
|
|
{'group:wood'},
|
|
|
|
}
|
|
|
|
})
|
2017-01-10 08:43:07 +03:00
|
|
|
|
|
|
|
minetest.register_craft({
|
|
|
|
type = "fuel",
|
|
|
|
recipe = 'mesecons_button:button_wood_off',
|
|
|
|
burntime = 5,
|
|
|
|
})
|
|
|
|
|