Refactor button registration
This commit is contained in:
parent
6efddc833c
commit
a2fefb264b
|
@ -82,138 +82,96 @@ local on_button_place = function(itemstack, placer, pointed_thing)
|
||||||
end
|
end
|
||||||
|
|
||||||
local buttonuse = "Rightclick the button to push it."
|
local buttonuse = "Rightclick the button to push it."
|
||||||
minetest.register_node("mesecons_button:button_stone_off", {
|
|
||||||
drawtype = "nodebox",
|
|
||||||
tiles = {"default_stone.png"},
|
|
||||||
wield_image = "mesecons_button_wield_mask.png^default_stone.png^mesecons_button_wield_mask.png^[makealpha:255,126,126",
|
|
||||||
-- FIXME: Use proper 3D inventory image
|
|
||||||
inventory_image = "mesecons_button_wield_mask.png^default_stone.png^mesecons_button_wield_mask.png^[makealpha:255,126,126",
|
|
||||||
wield_scale = { x=1, y=1, z=1},
|
|
||||||
paramtype = "light",
|
|
||||||
paramtype2 = "wallmounted",
|
|
||||||
is_ground_content = false,
|
|
||||||
walkable = false,
|
|
||||||
sunlight_propagates = true,
|
|
||||||
node_box = boxes_off,
|
|
||||||
groups = {handy=1,pickaxey=1, attached_node=1, dig_by_water=1,destroy_by_lava_flow=1, dig_by_piston=1},
|
|
||||||
description = "Stone Button",
|
|
||||||
_doc_items_longdesc = "A stone button is a redstone component made out of stone which can be pushed to provide redstone power. When pushed, it powers adjacent redstone components for 1 second. It can only be placed on solid opaque full cubes (like cobblestone).",
|
|
||||||
_doc_items_usagehelp = buttonuse,
|
|
||||||
on_place = on_button_place,
|
|
||||||
node_placement_prediction = "",
|
|
||||||
on_rightclick = function (pos, node)
|
|
||||||
minetest.swap_node(pos, {name="mesecons_button:button_stone_on", param2=node.param2})
|
|
||||||
mesecon.receptor_on(pos, button_get_output_rules(node))
|
|
||||||
minetest.sound_play("mesecons_button_push", {pos=pos})
|
|
||||||
minetest.after(1, mesecon.button_turnoff, pos)
|
|
||||||
end,
|
|
||||||
sounds = mcl_sounds.node_sound_stone_defaults(),
|
|
||||||
mesecons = {receptor = {
|
|
||||||
state = mesecon.state.off,
|
|
||||||
rules = button_get_output_rules,
|
|
||||||
}},
|
|
||||||
_mcl_blast_resistance = 2.5,
|
|
||||||
_mcl_hardness = 0.5,
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_node("mesecons_button:button_stone_on", {
|
mesecon.register_button = function(basename, description, texture, recipeitem, sounds, plusgroups, button_timer, longdesc)
|
||||||
drawtype = "nodebox",
|
local groups_off = {handy=1,pickaxey=1, attached_node=1, dig_by_water=1,destroy_by_lava_flow=1, dig_by_piston=1}
|
||||||
tiles = {"default_stone.png"},
|
local groups_on = table.copy(groups_off)
|
||||||
wield_image = "mesecons_button_wield_mask.png^default_stone.png^mesecons_button_wield_mask.png^[makealpha:255,126,126",
|
groups_on.not_in_creative_inventory=1
|
||||||
inventory_image = "mesecons_button_wield_mask.png^default_stone.png^mesecons_button_wield_mask.png^[makealpha:255,126,126",
|
|
||||||
wield_scale = { x=1, y=1, z=0.5},
|
|
||||||
paramtype = "light",
|
|
||||||
paramtype2 = "wallmounted",
|
|
||||||
is_ground_content = false,
|
|
||||||
walkable = false,
|
|
||||||
sunlight_propagates = true,
|
|
||||||
node_box = boxes_on,
|
|
||||||
groups = {handy=1,pickaxey=1, not_in_creative_inventory=1, attached_node=1, dig_by_water=1,destroy_by_lava_flow=1, dig_by_piston=1},
|
|
||||||
drop = 'mesecons_button:button_stone_off',
|
|
||||||
description = "Stone Button",
|
|
||||||
_doc_items_create_entry = false,
|
|
||||||
node_placement_prediction = "",
|
|
||||||
sounds = mcl_sounds.node_sound_stone_defaults(),
|
|
||||||
mesecons = {receptor = {
|
|
||||||
state = mesecon.state.on,
|
|
||||||
rules = button_get_output_rules
|
|
||||||
}},
|
|
||||||
_mcl_blast_resistance = 2.5,
|
|
||||||
_mcl_hardness = 0.5,
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_node("mesecons_button:button_wood_off", {
|
minetest.register_node("mesecons_button:button_"..basename.."_off", {
|
||||||
drawtype = "nodebox",
|
drawtype = "nodebox",
|
||||||
tiles = {"default_wood.png"},
|
tiles = {texture},
|
||||||
wield_image = "mesecons_button_wield_mask.png^default_wood.png^mesecons_button_wield_mask.png^[makealpha:255,126,126",
|
wield_image = "mesecons_button_wield_mask.png^"..texture.."^mesecons_button_wield_mask.png^[makealpha:255,126,126",
|
||||||
inventory_image = "mesecons_button_wield_mask.png^default_wood.png^mesecons_button_wield_mask.png^[makealpha:255,126,126",
|
-- FIXME: Use proper 3D inventory image
|
||||||
wield_scale = { x=1, y=1, z=1},
|
inventory_image = "mesecons_button_wield_mask.png^"..texture.."^mesecons_button_wield_mask.png^[makealpha:255,126,126",
|
||||||
paramtype = "light",
|
wield_scale = { x=1, y=1, z=1},
|
||||||
paramtype2 = "wallmounted",
|
paramtype = "light",
|
||||||
is_ground_content = false,
|
paramtype2 = "wallmounted",
|
||||||
walkable = false,
|
is_ground_content = false,
|
||||||
sunlight_propagates = true,
|
walkable = false,
|
||||||
node_box = boxes_off,
|
sunlight_propagates = true,
|
||||||
groups = {handy=1,axey=1, attached_node=1, dig_by_water=1,destroy_by_lava_flow=1, dig_by_piston=1},
|
node_box = boxes_off,
|
||||||
description = "Wooden Button",
|
groups = groups_off,
|
||||||
_doc_items_longdesc = "A wooden button is a redstone component made out of wood which can be pushed to provide redstone power. When pushed, it powers adjacent redstone components for 1.5 seconds. It can only be placed on solid opaque full cubes (like cobblestone).",
|
description = description,
|
||||||
_doc_items_usagehelp = buttonuse,
|
_doc_items_longdesc = longdesc,
|
||||||
on_place = on_button_place,
|
_doc_items_usagehelp = buttonuse,
|
||||||
node_placement_prediction = "",
|
on_place = on_button_place,
|
||||||
on_rightclick = function (pos, node)
|
node_placement_prediction = "",
|
||||||
minetest.swap_node(pos, {name="mesecons_button:button_wood_on", param2=node.param2})
|
on_rightclick = function (pos, node)
|
||||||
mesecon.receptor_on(pos, button_get_output_rules(node))
|
minetest.swap_node(pos, {name="mesecons_button:button_"..basename.."_on", param2=node.param2})
|
||||||
minetest.sound_play("mesecons_button_push", {pos=pos})
|
mesecon.receptor_on(pos, button_get_output_rules(node))
|
||||||
minetest.after(1.5, mesecon.button_turnoff, pos)
|
minetest.sound_play("mesecons_button_push", {pos=pos})
|
||||||
end,
|
minetest.after(button_timer, mesecon.button_turnoff, pos)
|
||||||
sounds = mcl_sounds.node_sound_wood_defaults(),
|
end,
|
||||||
mesecons = {receptor = {
|
sounds = sounds,
|
||||||
state = mesecon.state.off,
|
mesecons = {receptor = {
|
||||||
rules = button_get_output_rules,
|
state = mesecon.state.off,
|
||||||
}},
|
rules = button_get_output_rules,
|
||||||
_mcl_blast_resistance = 2.5,
|
}},
|
||||||
_mcl_hardness = 0.5,
|
_mcl_blast_resistance = 2.5,
|
||||||
})
|
_mcl_hardness = 0.5,
|
||||||
|
})
|
||||||
|
|
||||||
minetest.register_node("mesecons_button:button_wood_on", {
|
minetest.register_node("mesecons_button:button_"..basename.."_on", {
|
||||||
drawtype = "nodebox",
|
drawtype = "nodebox",
|
||||||
tiles = {"default_wood.png"},
|
tiles = {texture},
|
||||||
wield_image = "mesecons_button_wield_mask.png^default_wood.png^mesecons_button_wield_mask.png^[makealpha:255,126,126",
|
wield_image = "mesecons_button_wield_mask.png^"..texture.."^mesecons_button_wield_mask.png^[makealpha:255,126,126",
|
||||||
inventory_image = "mesecons_button_wield_mask.png^default_wood.png^mesecons_button_wield_mask.png^[makealpha:255,126,126",
|
inventory_image = "mesecons_button_wield_mask.png^"..texture.."^mesecons_button_wield_mask.png^[makealpha:255,126,126",
|
||||||
wield_scale = { x=1, y=1, z=0.5},
|
wield_scale = { x=1, y=1, z=0.5},
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
paramtype2 = "wallmounted",
|
paramtype2 = "wallmounted",
|
||||||
is_ground_content = false,
|
is_ground_content = false,
|
||||||
walkable = false,
|
walkable = false,
|
||||||
sunlight_propagates = true,
|
sunlight_propagates = true,
|
||||||
node_box = boxes_on,
|
node_box = boxes_on,
|
||||||
groups = {handy=1,axey=1, not_in_creative_inventory=1, attached_node=1, dig_by_water=1,destroy_by_lava_flow=1, dig_by_piston=1},
|
groups = groups_on,
|
||||||
drop = 'mesecons_button:button_wood_off',
|
drop = 'mesecons_button:button_'..basename..'_off',
|
||||||
description = "Wooden Button",
|
_doc_items_create_entry = false,
|
||||||
_doc_items_create_entry = false,
|
node_placement_prediction = "",
|
||||||
node_placement_prediction = "",
|
sounds = sounds,
|
||||||
sounds = mcl_sounds.node_sound_wood_defaults(),
|
mesecons = {receptor = {
|
||||||
mesecons = {receptor = {
|
state = mesecon.state.on,
|
||||||
state = mesecon.state.on,
|
rules = button_get_output_rules
|
||||||
rules = button_get_output_rules,
|
}},
|
||||||
}},
|
_mcl_blast_resistance = 2.5,
|
||||||
_mcl_blast_resistance = 2.5,
|
_mcl_hardness = 0.5,
|
||||||
_mcl_hardness = 0.5,
|
})
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = 'mesecons_button:button_stone_off',
|
output = "mesecons_button:button_"..basename.."_off",
|
||||||
recipe = {
|
recipe = {{ recipeitem }},
|
||||||
{'mcl_core:stone'},
|
})
|
||||||
}
|
end
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_craft({
|
mesecon.register_button(
|
||||||
output = 'mesecons_button:button_wood_off',
|
"stone",
|
||||||
recipe = {
|
"Stone Button",
|
||||||
{'group:wood'},
|
"default_stone.png",
|
||||||
}
|
"mcl_core:stone",
|
||||||
})
|
mcl_sounds.node_sound_stone_defaults(),
|
||||||
|
{material_stone=1,handy=1,pickaxey=1},
|
||||||
|
1,
|
||||||
|
"A stone button is a redstone component made out of stone which can be pushed to provide redstone power. When pushed, it powers adjacent redstone components for 1 second. It can only be placed on solid opaque full cubes (like cobblestone).")
|
||||||
|
|
||||||
|
mesecon.register_button(
|
||||||
|
"wood",
|
||||||
|
"Oak Wood Button",
|
||||||
|
"default_wood.png",
|
||||||
|
"mcl_core:wood",
|
||||||
|
mcl_sounds.node_sound_wood_defaults(),
|
||||||
|
{material_wood=1,handy=1,axey=1},
|
||||||
|
1.5,
|
||||||
|
"A wooden button is a redstone component made out of wood which can be pushed to provide redstone power. When pushed, it powers adjacent redstone components for 1.5 seconds. It can only be placed on solid opaque full cubes (like cobblestone).")
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
type = "fuel",
|
type = "fuel",
|
||||||
|
|
Loading…
Reference in New Issue