From c536e9ca4e5745795f03ef56a7851b2a2f2a0cb9 Mon Sep 17 00:00:00 2001 From: Vanessa Ezekowitz Date: Fri, 4 Oct 2013 21:11:26 -0400 Subject: [PATCH] always check for air before spawning the display block's crystal, and always check for that crystal before trying to remove it. keeps display blocks from being potentially destructive, reduces mapgen activity to just the moment a block is placed instead of multiple blocks/second. --- init.lua | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/init.lua b/init.lua index de36bdb..24bb1bb 100644 --- a/init.lua +++ b/init.lua @@ -38,21 +38,25 @@ function disp(base, name, light, rec, rp) minetest.register_abm({ nodenames = {"display_blocks:"..base.."_base"}, - interval = 1.0, + interval = 2.0, chance = 1.0, action = function(pos, node, active_object_count, active_object_count_wider) pos.y = pos.y + 1 - minetest.env:add_node(pos, {name="display_blocks:"..base.."_crystal"}) + local n = minetest.get_node(pos) + if n and n.name == "air" then + minetest.env:add_node(pos, {name="display_blocks:"..base.."_crystal"}) + end end }) function remove_crystal(pos, node, active_object_count, active_object_count_wider) - if - node.name == "display_blocks:"..base.."_base" - then - pos.y = pos.y + 1 - minetest.env:remove_node(pos, {name="display_blocks:"..base.."_crystal"}) - end + if node.name == "display_blocks:"..base.."_base" then + pos.y = pos.y + 1 + local n = minetest.get_node(pos) + if n and n.name == "display_blocks:"..base.."_crystal" then + minetest.env:remove_node(pos) + end + end end minetest.register_on_dignode(remove_crystal)