Add buttons for all woods

This commit is contained in:
Wuzzy 2017-11-22 22:41:43 +01:00
parent a2fefb264b
commit 7fab1ada00
1 changed files with 45 additions and 30 deletions

View File

@ -8,19 +8,6 @@ local button_get_output_rules = function(node)
return rules return rules
end end
mesecon.button_turnoff = function (pos)
local node = minetest.get_node(pos)
if node.name=="mesecons_button:button_stone_on" then --has not been dug
minetest.swap_node(pos, {name="mesecons_button:button_stone_off",param2=node.param2})
minetest.sound_play("mesecons_button_pop", {pos=pos})
mesecon.receptor_off(pos, button_get_output_rules(node))
elseif node.name=="mesecons_button:button_wood_on" then --has not been dug
minetest.swap_node(pos, {name="mesecons_button:button_wood_off",param2=node.param2})
minetest.sound_play("mesecons_button_pop", {pos=pos})
mesecon.receptor_off(pos, button_get_output_rules(node))
end
end
local boxes_off = { local boxes_off = {
type = "wallmounted", type = "wallmounted",
wall_side = { -8/16, -2/16, -4/16, -6/16, 2/16, 4/16 }, wall_side = { -8/16, -2/16, -4/16, -6/16, 2/16, 4/16 },
@ -75,7 +62,7 @@ local on_button_place = function(itemstack, placer, pointed_thing)
if success then if success then
if idef.sounds and idef.sounds.place then if idef.sounds and idef.sounds.place then
--minetest.sound_play(idef.sounds.place, {pos=above, gain=1}) minetest.sound_play(idef.sounds.place, {pos=above, gain=1})
end end
end end
return itemstack return itemstack
@ -84,9 +71,16 @@ end
local buttonuse = "Rightclick the button to push it." local buttonuse = "Rightclick the button to push it."
mesecon.register_button = function(basename, description, texture, recipeitem, sounds, plusgroups, button_timer, longdesc) mesecon.register_button = function(basename, description, texture, recipeitem, sounds, plusgroups, button_timer, longdesc)
local groups_off = {handy=1,pickaxey=1, attached_node=1, dig_by_water=1,destroy_by_lava_flow=1, dig_by_piston=1} local groups_off = table.copy(plusgroups)
groups_off.attached_node=1
groups_off.dig_by_water=1
groups_off.destroy_by_lava_flow=1
groups_off.dig_by_piston=1
groups_off.button=1 -- button (off)
local groups_on = table.copy(groups_off) local groups_on = table.copy(groups_off)
groups_on.not_in_creative_inventory=1 groups_on.not_in_creative_inventory=1
groups_on.button=2 -- button (on)
minetest.register_node("mesecons_button:button_"..basename.."_off", { minetest.register_node("mesecons_button:button_"..basename.."_off", {
drawtype = "nodebox", drawtype = "nodebox",
@ -111,7 +105,17 @@ mesecon.register_button = function(basename, description, texture, recipeitem, s
minetest.swap_node(pos, {name="mesecons_button:button_"..basename.."_on", param2=node.param2}) minetest.swap_node(pos, {name="mesecons_button:button_"..basename.."_on", param2=node.param2})
mesecon.receptor_on(pos, button_get_output_rules(node)) mesecon.receptor_on(pos, button_get_output_rules(node))
minetest.sound_play("mesecons_button_push", {pos=pos}) minetest.sound_play("mesecons_button_push", {pos=pos})
minetest.after(button_timer, mesecon.button_turnoff, pos) local button_turnoff = function(a)
local pos = a.pos
local node = minetest.get_node(pos)
local basename = a.basename
if node.name=="mesecons_button:button_"..basename.."_on" then --has not been dug
minetest.swap_node(pos, {name="mesecons_button:button_"..basename.."_off",param2=node.param2})
minetest.sound_play("mesecons_button_pop", {pos=pos})
mesecon.receptor_off(pos, button_get_output_rules(node))
end
end
minetest.after(button_timer, button_turnoff, {pos=pos, basename=basename})
end, end,
sounds = sounds, sounds = sounds,
mesecons = {receptor = { mesecons = {receptor = {
@ -163,11 +167,21 @@ mesecon.register_button(
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).") "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).")
local woods = {
{ "wood", "mcl_core:wood", "default_wood.png", "Oak Button" },
{ "acaciawood", "mcl_core:acaciawood", "default_acacia_wood.png", "Acacia Button" },
{ "birchwood", "mcl_core:birchwood", "mcl_core_planks_birch.png", "Birch Button" },
{ "darkwood", "mcl_core:darkwood", "mcl_core_planks_big_oak.png", "Dark Oak Button" },
{ "sprucewood", "mcl_core:sprucewood", "mcl_core_planks_spruce.png", "Spruce Button" },
{ "junglewood", "mcl_core:junglewood", "default_junglewood.png", "Jungle Button" },
}
for w=1, #woods do
mesecon.register_button( mesecon.register_button(
"wood", woods[w][1],
"Oak Wood Button", woods[w][4],
"default_wood.png", woods[w][3],
"mcl_core:wood", woods[w][2],
mcl_sounds.node_sound_wood_defaults(), mcl_sounds.node_sound_wood_defaults(),
{material_wood=1,handy=1,axey=1}, {material_wood=1,handy=1,axey=1},
1.5, 1.5,
@ -175,9 +189,10 @@ mesecon.register_button(
minetest.register_craft({ minetest.register_craft({
type = "fuel", type = "fuel",
recipe = 'mesecons_button:button_wood_off', recipe = "mesecons_button:button_"..woods[w][1].."_off",
burntime = 5, burntime = 5,
}) })
end
-- Add entry aliases for the Help -- Add entry aliases for the Help
if minetest.get_modpath("doc") then if minetest.get_modpath("doc") then