From 4200757ba3ac7f450a6b51592339aa62af905f0e Mon Sep 17 00:00:00 2001 From: Anthony Zhang Date: Mon, 4 Jun 2012 22:20:04 -0400 Subject: Remove deprecated API functions "register_on_placenode" and "register_on_dignode" where possible. --- mesecons_pistons/init.lua | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) (limited to 'mesecons_pistons') diff --git a/mesecons_pistons/init.lua b/mesecons_pistons/init.lua index 0bb391f..87c3fc1 100644 --- a/mesecons_pistons/init.lua +++ b/mesecons_pistons/init.lua @@ -5,6 +5,14 @@ minetest.register_node("mesecons_pistons:piston_normal", { groups = {cracky=3}, paramtype2="facedir", description="Piston", + after_dig_node = function(pos) + local objs = minetest.env:get_objects_inside_radius(pos, 2) + for k, obj in pairs(objs) do + if obj:get_entity_name() == "mesecons_pistons:piston_pusher_normal" then + obj:remove() + end + end + end }) minetest.register_craft({ @@ -22,6 +30,14 @@ minetest.register_node("mesecons_pistons:piston_sticky", { groups = {cracky=3}, paramtype2="facedir", description="Sticky Piston", + after_dig_node = function(pos) + local objs = minetest.env:get_objects_inside_radius(pos, 2) + for k, obj in pairs(objs) do + if obj:get_entity_name() == "mesecons_pistons:piston_pusher_sticky" then + obj:remove() + end + end + end }) minetest.register_craft({ @@ -260,15 +276,3 @@ end minetest.register_entity("mesecons_pistons:piston_pusher_normal", PISTON_PUSHER_NORMAL) minetest.register_entity("mesecons_pistons:piston_pusher_sticky", PISTON_PUSHER_STICKY) - -minetest.register_on_dignode(function(pos, node) - if node.name=="mesecons_pistons:piston_normal" or node.name=="mesecons_pistons:piston_sticky" then - local objs = minetest.env:get_objects_inside_radius(pos, 2) - for k, obj in pairs(objs) do - local obj_name = obj:get_entity_name() - if obj_name == "mesecons_pistons:piston_pusher_normal" or obj_name == "mesecons_pistons:piston_pusher_sticky" then - obj:remove() - end - end - end -end) -- cgit v1.2.3