forked from MineClone5/MineClone5
Wooden buttons stay pushed by arrow
This commit is contained in:
parent
467018128a
commit
af0025debc
|
@ -66,7 +66,7 @@ end
|
|||
|
||||
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, push_by_arrow, longdesc)
|
||||
local groups_off = table.copy(plusgroups)
|
||||
groups_off.attached_node=1
|
||||
groups_off.dig_by_water=1
|
||||
|
@ -78,6 +78,11 @@ mesecon.register_button = function(basename, description, texture, recipeitem, s
|
|||
groups_on.not_in_creative_inventory=1
|
||||
groups_on.button=2 -- button (on)
|
||||
|
||||
if push_by_arrow then
|
||||
groups_off.button_push_by_arrow = 1
|
||||
groups_on.button_push_by_arrow = 1
|
||||
end
|
||||
|
||||
minetest.register_node("mesecons_button:button_"..basename.."_off", {
|
||||
drawtype = "nodebox",
|
||||
tiles = {texture},
|
||||
|
@ -137,6 +142,22 @@ mesecon.register_button = function(basename, description, texture, recipeitem, s
|
|||
on_timer = function(pos, elapsed)
|
||||
local node = minetest.get_node(pos)
|
||||
if node.name=="mesecons_button:button_"..basename.."_on" then --has not been dug
|
||||
-- Is button pushable by arrow?
|
||||
if push_by_arrow then
|
||||
-- If there's an arrow stuck in the button, keep it pressed and check
|
||||
-- it again later.
|
||||
local objs = minetest.get_objects_inside_radius(pos, 1)
|
||||
for o=1, #objs do
|
||||
local entity = objs[o]:get_luaentity()
|
||||
if entity and entity.name == "mcl_bows:arrow_entity" then
|
||||
local timer = minetest.get_node_timer(pos)
|
||||
timer:start(button_timer)
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Normal operation: Un-press the button
|
||||
minetest.set_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))
|
||||
|
@ -160,6 +181,7 @@ mesecon.register_button(
|
|||
mcl_sounds.node_sound_stone_defaults(),
|
||||
{material_stone=1,handy=1,pickaxey=1},
|
||||
1,
|
||||
false,
|
||||
"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 = {
|
||||
|
@ -180,7 +202,8 @@ for w=1, #woods do
|
|||
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).")
|
||||
true,
|
||||
"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). Wooden buttons may also be pushed by arrows.")
|
||||
|
||||
minetest.register_craft({
|
||||
type = "fuel",
|
||||
|
|
Loading…
Reference in New Issue