Remove deprecated API functions "register_on_placenode" and "register_on_dignode" where possible.

This commit is contained in:
Anthony Zhang 2012-06-04 22:20:04 -04:00
parent 95a84dde46
commit 4200757ba3
13 changed files with 198 additions and 276 deletions

View File

@ -42,8 +42,8 @@
-- --
-- --
--!! If a receptor node is removed, the circuit should be recalculated. This means you have to --!! If a receptor node is removed, the circuit should be recalculated. This means you have to
--send an mesecon:receptor_off signal to the api when the function in minetest.register_on_dignode --send an mesecon:receptor_off signal to the api when the node is dug, using the
--is called. --after_dig_node node property.
-- --
--EFFECTORS --EFFECTORS
-- --

View File

@ -22,6 +22,9 @@ minetest.register_node("mesecons_blinkyplant:blinky_plant_on", {
drop='"mesecons_blinkyplant:blinky_plant_off" 1', drop='"mesecons_blinkyplant:blinky_plant_off" 1',
light_source = LIGHT_MAX-7, light_source = LIGHT_MAX-7,
description = "Blinky Plant", description = "Blinky Plant",
after_dig_node = function(pos)
mesecon:receptor_off(pos)
end
}) })
minetest.register_craft({ minetest.register_craft({
@ -59,11 +62,3 @@ minetest.register_abm({
mesecon:add_receptor_node("mesecons_blinkyplant:blinky_plant_on") mesecon:add_receptor_node("mesecons_blinkyplant:blinky_plant_on")
mesecon:add_receptor_node_off("mesecons_blinkyplant:blinky_plant_off") mesecon:add_receptor_node_off("mesecons_blinkyplant:blinky_plant_off")
minetest.register_on_dignode(
function(pos, oldnode, digger)
if oldnode.name == "mesecons_blinkyplant:blinky_plant_on" then
mesecon:receptor_off(pos)
end
end
)

View File

@ -23,17 +23,13 @@ minetest.register_node("mesecons_button:button_on", {
type = "wallmounted", type = "wallmounted",
}, },
groups = {dig_immediate=2}, groups = {dig_immediate=2},
drop = '"mesecons_button:button_off" 1', drop = 'mesecons_button:button_off',
description = "Button", description = "Button",
after_dig_node = function(pos)
mesecon:receptor_off(pos, mesecon.button_get_rules(minetest.env:get_node(pos).param2))
end
}) })
minetest.register_on_dignode(
function(pos, oldnode, digger)
if oldnode.name == "mesecons_button:button_on" then
mesecon:receptor_off(pos, mesecon.button_get_rules(oldnode.param2))
end
end
)
minetest.register_on_punchnode(function(pos, node, puncher) minetest.register_on_punchnode(function(pos, node, puncher)
if node.name == "mesecons_button:button_off" then if node.name == "mesecons_button:button_off" then
minetest.env:add_node(pos, {name="mesecons_button:button_on",param2=node.param2}) minetest.env:add_node(pos, {name="mesecons_button:button_on",param2=node.param2})

View File

@ -12,12 +12,15 @@ minetest.register_node("mesecons_detector:object_detector_on", {
paramtype = "light", paramtype = "light",
walkable = true, walkable = true,
groups = {cracky=3}, groups = {cracky=3},
drop = '"mesecons_detector:object_detector_off" 1', drop = 'mesecons_detector:object_detector_off',
description="Player Detector", description="Player Detector",
after_dig_node = function(pos)
mesecon:receptor_off(pos, mesecon:get_rules("pressureplate"))
end
}) })
minetest.register_craft({ minetest.register_craft({
output = '"mesecons_detector:object_detector_off" 1', output = 'mesecons_detector:object_detector_off',
recipe = { recipe = {
{"default:steelblock", '', "default:steelblock"}, {"default:steelblock", '', "default:steelblock"},
{"default:steelblock", "mesecons_materials:ic", "default:steelblock"}, {"default:steelblock", "mesecons_materials:ic", "default:steelblock"},
@ -73,13 +76,5 @@ minetest.register_abm(
end, end,
}) })
minetest.register_on_dignode(
function(pos, oldnode, digger)
if oldnode.name == "mesecons_detector:object_detector_on" then
mesecon:receptor_off(pos, mesecon:get_rules("pressureplate"))
end
end
)
mesecon:add_receptor_node("mesecons_detector:object_detector_on") mesecon:add_receptor_node("mesecons_detector:object_detector_on")
mesecon:add_receptor_node_off("mesecons_detector:object_detector_off") mesecon:add_receptor_node_off("mesecons_detector:object_detector_off")

View File

@ -150,6 +150,13 @@ minetest.register_node("mesecons_wireless:wireless_receiver_off", {
inventory_image = minetest.inventorycube("jeija_wireless_receiver_off.png"), inventory_image = minetest.inventorycube("jeija_wireless_receiver_off.png"),
groups = {choppy=2}, groups = {choppy=2},
description="Wireless Receiver", description="Wireless Receiver",
after_place_node = function(pos)
mesecon:register_wireless_receiver(pos, 0)
end,
after_dig_node = function(pos)
mesecon:remove_wireless_receiver(pos)
mesecon:receptor_off(pos)
end
}) })
minetest.register_node("mesecons_wireless:wireless_receiver_on", { minetest.register_node("mesecons_wireless:wireless_receiver_on", {
@ -158,6 +165,12 @@ minetest.register_node("mesecons_wireless:wireless_receiver_on", {
groups = {choppy=2}, groups = {choppy=2},
drop = 'mesecons_wireless:wireless_receiver_off', drop = 'mesecons_wireless:wireless_receiver_off',
description="Wireless Receiver", description="Wireless Receiver",
after_place_node = function(pos)
mesecon:register_wireless_receiver(pos, 0)
end,
after_dig_node = function(pos)
mesecon:remove_wireless_receiver(pos)
end
}) })
minetest.register_craft({ minetest.register_craft({
@ -169,24 +182,6 @@ minetest.register_craft({
} }
}) })
minetest.register_on_placenode(function(pos, newnode, placer)
if newnode.name == "mesecons_wireless:wireless_receiver_off" then
mesecon:register_wireless_receiver(pos, 0)
end
end)
minetest.register_on_dignode(
function(pos, oldnode, digger)
if oldnode.name == "mesecons_wireless:wireless_receiver_on" then
mesecon:remove_wireless_receiver(pos)
mesecon:receptor_off(pos)
end
if oldnode.name == "mesecons_wireless:wireless_receiver_off" then
mesecon:remove_wireless_receiver(pos)
end
end
)
minetest.register_abm( -- SAVE WIRELESS RECEIVERS TO FILE minetest.register_abm( -- SAVE WIRELESS RECEIVERS TO FILE
{nodenames = {"mesecons_wireless:wireless_receiver_off", "mesecons_wireless:wireless_receiver_on", "mesecons_wireless:wireless_inverter_on", "mesecons_wireless:wireless_inverter_off"}, {nodenames = {"mesecons_wireless:wireless_receiver_off", "mesecons_wireless:wireless_receiver_on", "mesecons_wireless:wireless_inverter_on", "mesecons_wireless:wireless_inverter_off"},
interval = 10, interval = 10,
@ -219,6 +214,13 @@ minetest.register_node("mesecons_wireless:wireless_inverter_off", {
groups = {choppy=2}, groups = {choppy=2},
drop = 'mesecons_wireless:wireless_inverter_on', drop = 'mesecons_wireless:wireless_inverter_on',
description = "Wireless Inverter", description = "Wireless Inverter",
after_place_node = function(pos)
mesecon:register_wireless_receiver(pos, 1)
mesecon:receptor_on(pos)
end,
after_dig_node = function(pos)
mesecon:remove_wireless_receiver(pos)
end
}) })
minetest.register_node("mesecons_wireless:wireless_inverter_on", { minetest.register_node("mesecons_wireless:wireless_inverter_on", {
@ -226,6 +228,14 @@ minetest.register_node("mesecons_wireless:wireless_inverter_on", {
inventory_image = minetest.inventorycube("jeija_wireless_inverter_on.png"), inventory_image = minetest.inventorycube("jeija_wireless_inverter_on.png"),
groups = {choppy=2}, groups = {choppy=2},
description = "Wireless Inverter", description = "Wireless Inverter",
after_place_node = function(pos)
mesecon:register_wireless_receiver(pos, 1)
mesecon:receptor_on(pos)
end,
after_dig_node = function(pos)
mesecon:remove_wireless_receiver(pos)
mesecon:receptor_off(pos)
end
}) })
minetest.register_craft({ minetest.register_craft({
@ -237,25 +247,6 @@ minetest.register_craft({
} }
}) })
minetest.register_on_placenode(function(pos, newnode, placer)
if newnode.name == "mesecons_wireless:wireless_inverter_on" then
mesecon:register_wireless_receiver(pos, 1)
mesecon:receptor_on(pos)
end
end)
minetest.register_on_dignode(
function(pos, oldnode, digger)
if oldnode.name == "mesecons_wireless:wireless_inverter_on" then
mesecon:remove_wireless_receiver(pos)
mesecon:receptor_off(pos)
end
if oldnode.name == "mesecons_wireless:wireless_inverter_off" then
mesecon:remove_wireless_receiver(pos)
end
end
)
mesecon:add_receptor_node("mesecons_wireless:wireless_inverter_on") mesecon:add_receptor_node("mesecons_wireless:wireless_inverter_on")
mesecon:add_receptor_node_off("mesecons_wireless:wireless_inverter_off") mesecon:add_receptor_node_off("mesecons_wireless:wireless_inverter_off")

View File

@ -5,13 +5,10 @@ minetest.register_node("mesecons_noteblock:noteblock", {
drawtype = "allfaces_optional", drawtype = "allfaces_optional",
visual_scale = 1.3, visual_scale = 1.3,
paramtype="light", paramtype="light",
}) after_place_node = function(pos)
minetest.env:add_node(pos, {name="mesecons_noteblock:noteblock", param2=0})
minetest.register_on_placenode(function (pos, node)
if node.name=="mesecons_noteblock:noteblock" then
minetest.env:add_node(pos, {name=node.name, param2=0})
end end
end) })
minetest.register_on_punchnode(function (pos, node) minetest.register_on_punchnode(function (pos, node)
if node.name=="mesecons_noteblock:noteblock" then if node.name=="mesecons_noteblock:noteblock" then

View File

@ -5,6 +5,14 @@ minetest.register_node("mesecons_pistons:piston_normal", {
groups = {cracky=3}, groups = {cracky=3},
paramtype2="facedir", paramtype2="facedir",
description="Piston", 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({ minetest.register_craft({
@ -22,6 +30,14 @@ minetest.register_node("mesecons_pistons:piston_sticky", {
groups = {cracky=3}, groups = {cracky=3},
paramtype2="facedir", paramtype2="facedir",
description="Sticky Piston", 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({ 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_normal", PISTON_PUSHER_NORMAL)
minetest.register_entity("mesecons_pistons:piston_pusher_sticky", PISTON_PUSHER_STICKY) 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)

View File

@ -10,6 +10,12 @@ minetest.register_node("mesecons_powerplant:power_plant", {
groups = {snappy=3}, groups = {snappy=3},
light_source = LIGHT_MAX-9, light_source = LIGHT_MAX-9,
description="Power Plant", description="Power Plant",
after_place_node = function(pos)
mesecon:receptor_on(pos)
end,
after_dig_node = function(pos)
mesecon:receptor_off(pos)
end
}) })
minetest.register_craft({ minetest.register_craft({
@ -21,18 +27,4 @@ minetest.register_craft({
} }
}) })
minetest.register_on_placenode(function(pos, newnode, placer)
if newnode.name == "mesecons_powerplant:power_plant" then
mesecon:receptor_on(pos)
end
end)
minetest.register_on_dignode(
function(pos, oldnode, digger)
if oldnode.name == "mesecons_powerplant:power_plant" then
mesecon:receptor_off(pos)
end
end
)
mesecon:add_receptor_node("mesecons_powerplant:power_plant") mesecon:add_receptor_node("mesecons_powerplant:power_plant")

View File

@ -26,6 +26,9 @@ minetest.register_node("mesecons_pressureplates:pressure_plate_wood_on", {
}, },
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=3}, groups = {snappy=2,choppy=2,oddly_breakable_by_hand=3},
drop='"mesecons_pressureplates:pressure_plate_wood_off" 1', drop='"mesecons_pressureplates:pressure_plate_wood_off" 1',
after_dig_node = function(pos)
mesecon:receptor_off(pos, mesecon:get_rules("pressureplate"))
end
}) })
minetest.register_craft({ minetest.register_craft({
@ -64,14 +67,6 @@ minetest.register_abm(
end, end,
}) })
minetest.register_on_dignode(
function(pos, oldnode, digger)
if oldnode.name == "mesecons_pressureplates:pressure_plate_wood_on" then
mesecon:receptor_off(pos, mesecon:get_rules("pressureplate"))
end
end
)
mesecon:add_receptor_node("mesecons_pressureplates:pressure_plate_wood_on") mesecon:add_receptor_node("mesecons_pressureplates:pressure_plate_wood_on")
mesecon:add_receptor_node_off("mesecons_pressureplates:pressure_plate_wood_off") mesecon:add_receptor_node_off("mesecons_pressureplates:pressure_plate_wood_off")
@ -103,6 +98,9 @@ minetest.register_node("mesecons_pressureplates:pressure_plate_stone_on", {
}, },
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=3}, groups = {snappy=2,choppy=2,oddly_breakable_by_hand=3},
drop='"mesecons_pressureplates:pressure_plate_stone_off" 1', drop='"mesecons_pressureplates:pressure_plate_stone_off" 1',
after_dig_node = function(pos)
mesecon:receptor_off(pos, mesecon:get_rules("pressureplate"))
end
}) })
minetest.register_craft({ minetest.register_craft({
@ -141,14 +139,6 @@ minetest.register_abm(
end, end,
}) })
minetest.register_on_dignode(
function(pos, oldnode, digger)
if oldnode.name == "mesecons_pressureplates:pressure_plate_stone_on" then
mesecon:receptor_off(pos, mesecon:get_rules("pressureplate"))
end
end
)
mesecon:add_receptor_node("mesecons_pressureplates:pressure_plate_stone_on") mesecon:add_receptor_node("mesecons_pressureplates:pressure_plate_stone_on")
mesecon:add_receptor_node_off("mesecons_pressureplates:pressure_plate_stone_off") mesecon:add_receptor_node_off("mesecons_pressureplates:pressure_plate_stone_off")

View File

@ -13,6 +13,9 @@ minetest.register_node("mesecons_switch:mesecon_switch_on", {
groups = {dig_immediate=2}, groups = {dig_immediate=2},
drop='"mesecons_switch:mesecon_switch_off" 1', drop='"mesecons_switch:mesecon_switch_off" 1',
description="Switch", description="Switch",
after_dig_node = function(pos)
mesecon:receptor_off(pos)
end
}) })
mesecon:add_receptor_node("mesecons_switch:mesecon_switch_on") mesecon:add_receptor_node("mesecons_switch:mesecon_switch_on")
@ -31,14 +34,6 @@ minetest.register_on_punchnode(function(pos, node, puncher)
end end
end) end)
minetest.register_on_dignode(
function(pos, oldnode, digger)
if oldnode.name == "mesecons_switch:mesecon_switch_on" then
mesecon:receptor_off(pos)
end
end
)
minetest.register_craft({ minetest.register_craft({
output = '"mesecons_switch:mesecon_switch_off" 2', output = '"mesecons_switch:mesecon_switch_off" 2',
recipe = { recipe = {

View File

@ -1,20 +1,5 @@
--TEMPEREST-PLUG --TEMPEREST-PLUG
minetest.register_node("mesecons_temperest:mesecon_plug", {
drawtype = "raillike",
paramtype = "light",
is_ground_content = true,
tile_images = {"jeija_mesecon_plug.png"},
inventory_image = "jeija_mesecon_plug.png",
wield_image = "jeija_mesecon_plug.png",
groups = {dig_immediate=2},
walkable = false,
selection_box = {
type = "fixed",
},
description = "Plug",
})
local set_node_on local set_node_on
local set_node_off local set_node_off
@ -64,7 +49,8 @@ else
end end
end end
local plug_on = function(pos, node) local plug_on = function(pos)
local node = minetest.env:get_node(pos)
if node.name=="mesecons_temperest:mesecon_plug" then if node.name=="mesecons_temperest:mesecon_plug" then
local lnode = minetest.env:get_node({x=pos.x-1, y=pos.y, z=pos.z}) --a node between this node and the one two nodes away local lnode = minetest.env:get_node({x=pos.x-1, y=pos.y, z=pos.z}) --a node between this node and the one two nodes away
if lnode.name=="air" then set_node_on({x=pos.x-2, y=pos.y, z=pos.z}) end if lnode.name=="air" then set_node_on({x=pos.x-2, y=pos.y, z=pos.z}) end
@ -86,7 +72,8 @@ local plug_on = function(pos, node)
end end
end end
local plug_off = function(pos, node) local plug_off = function(pos)
local node = minetest.env:get_node(pos)
if node.name=="mesecons_temperest:mesecon_plug" then if node.name=="mesecons_temperest:mesecon_plug" then
lnode = minetest.env:get_node({x=pos.x-1, y=pos.y, z=pos.z}) --a node between this node and the one two nodes away lnode = minetest.env:get_node({x=pos.x-1, y=pos.y, z=pos.z}) --a node between this node and the one two nodes away
if lnode.name=="air" then set_node_off({x=pos.x-2, y=pos.y, z=pos.z}) end if lnode.name=="air" then set_node_off({x=pos.x-2, y=pos.y, z=pos.z}) end
@ -111,15 +98,29 @@ end
mesecon:register_on_signal_on(plug_on) mesecon:register_on_signal_on(plug_on)
mesecon:register_on_signal_off(plug_off) mesecon:register_on_signal_off(plug_off)
minetest.register_on_placenode(plug_off) minetest.register_node("mesecons_temperest:mesecon_plug", {
minetest.register_on_dignode(plug_off) drawtype = "raillike",
paramtype = "light",
is_ground_content = true,
tile_images = {"jeija_mesecon_plug.png"},
inventory_image = "jeija_mesecon_plug.png",
wield_image = "jeija_mesecon_plug.png",
groups = {dig_immediate=2},
walkable = false,
selection_box = {
type = "fixed",
},
description = "Plug",
after_place_node = plug_off,
after_dig_node = plug_off
})
minetest.register_craft({ minetest.register_craft({
output = 'node "mesecons_temperest:mesecon_plug" 2', output = '"mesecons_temperest:mesecon_plug" 2',
recipe = { recipe = {
{'', 'node "mesecons:mesecon_off"', ''}, {'', '"mesecons:mesecon_off"', ''},
{'node "mesecons:mesecon_off"', 'craft "default:steel_ingot"', 'node "mesecons:mesecon_off"'}, {'"mesecons:mesecon_off"', '"default:steel_ingot"', '"mesecons:mesecon_off"'},
{'', 'node "mesecons:mesecon_off"', ''}, {'', '"mesecons:mesecon_off"', ''},
} }
}) })
@ -151,25 +152,20 @@ minetest.register_node("mesecons_temperest:mesecon_socket_on", {
type = "fixed", type = "fixed",
}, },
drop='"mesecons_temperest:mesecon_socket_off" 1', drop='"mesecons_temperest:mesecon_socket_off" 1',
}) after_dig_node = function(pos)
minetest.register_on_dignode(
function(pos, oldnode, digger)
if oldnode.name == "mesecons_temperest:mesecon_socket_on" then
mesecon:receptor_off(pos) mesecon:receptor_off(pos)
end end
end })
)
mesecon:add_receptor_node("mesecons_temperest:mesecon_socket_on") mesecon:add_receptor_node("mesecons_temperest:mesecon_socket_on")
mesecon:add_receptor_node_off("mesecons_temperest:mesecon_socket_off") mesecon:add_receptor_node_off("mesecons_temperest:mesecon_socket_off")
minetest.register_craft({ minetest.register_craft({
output = 'node "mesecons_temperest:mesecon_socket_off" 2', output = '"mesecons_temperest:mesecon_socket_off" 2',
recipe = { recipe = {
{'', 'craft "default:steel_ingot"', ''}, {'', '"default:steel_ingot"', ''},
{'craft "default:steel_ingot"', 'node "mesecons_temperest:mesecon_off"', 'craft "default:steel_ingot"'}, {'"default:steel_ingot"', '"mesecons_temperest:mesecon_off"', '"default:steel_ingot"'},
{'', 'craft "default:steel_ingot"', ''}, {'', '"default:steel_ingot"', ''},
} }
}) })
@ -201,32 +197,23 @@ if ENABLE_TEMPEREST==1 then
selection_box = { selection_box = {
type = "fixed", type = "fixed",
}, },
}) after_place_node = function(pos)
minetest.register_on_placenode(function(pos, node)
if node.name=="mesecons_temperest:mesecon_inverter_on" then
mesecon:receptor_on(pos) mesecon:receptor_on(pos)
end end,
end after_dig_node = function(pos)
)
minetest.register_on_dignode(
function(pos, oldnode, digger)
if oldnode.name == "mesecons_temperest:mesecon_inverter_on" then
mesecon:receptor_off(pos) mesecon:receptor_off(pos)
end end
end })
)
mesecon:add_receptor_node("mesecons_temperest:mesecon_inverter_on") mesecon:add_receptor_node("mesecons_temperest:mesecon_inverter_on")
mesecon:add_receptor_node_off("mesecons_temperest:mesecon_inverter_off") mesecon:add_receptor_node_off("mesecons_temperest:mesecon_inverter_off")
minetest.register_craft({ minetest.register_craft({
output = 'node "mesecons_temperest:mesecon_inverter_on" 2', output = '"mesecons_temperest:mesecon_inverter_on" 2',
recipe = { recipe = {
{'node "mesecons_temperest:mesecon_off"', 'craft "default:steel_ingot"', 'node "mesecons:mesecon_off"'}, {'"mesecons_temperest:mesecon_off"', '"default:steel_ingot"', '"mesecons:mesecon_off"'},
{'craft "default:steel_ingot"', '', 'craft "default:steel_ingot"'}, {'"default:steel_ingot"', '', '"default:steel_ingot"'},
{'node "mesecons:mesecon_off"', 'craft "default:steel_ingot"', 'node "mesecons:mesecon_off"'}, {'"mesecons:mesecon_off"', '"default:steel_ingot"', '"mesecons:mesecon_off"'},
} }
}) })
end end

View File

@ -34,15 +34,14 @@ minetest.register_node("mesecons_torch:mesecon_torch_on", {
groups = {dig_immediate=2}, groups = {dig_immediate=2},
light_source = LIGHT_MAX-5, light_source = LIGHT_MAX-5,
description="Mesecon Torch", description="Mesecon Torch",
}) after_place_node = function(pos)
local rules = mesecon.torch_get_rules(minetest.env:get_node(pos).param2)
--[[minetest.register_on_placenode(function(pos, newnode, placer) mesecon:receptor_on(pos, rules)
if (newnode.name=="mesecons_torch:mesecon_torch_off" or newnode.name=="mesecons_torch:mesecon_torch_on") end,
and (newnode.param2==8 or newnode.param2==4) then after_dig_node = function(pos)
minetest.env:remove_node(pos) mesecon:receptor_off(pos)
--minetest.env:add_item(pos, "'mesecons_torch:mesecon_torch_on' 1")
end end
end)]] })
minetest.register_abm({ minetest.register_abm({
nodenames = {"mesecons_torch:mesecon_torch_off","mesecons_torch:mesecon_torch_on"}, nodenames = {"mesecons_torch:mesecon_torch_off","mesecons_torch:mesecon_torch_on"},
@ -81,21 +80,6 @@ minetest.register_abm({
end end
}) })
minetest.register_on_dignode(
function(pos, oldnode, digger)
if oldnode.name == "mesecons_torch:mesecon_torch_on" then
mesecon:receptor_off(pos)
end
end
)
minetest.register_on_placenode(function(pos, node, placer)
if node.name == "mesecons_torch:mesecon_torch_on" then
local rules=mesecon.torch_get_rules(minetest.env:get_node(pos).param2)
mesecon:receptor_on(pos, rules)
end
end)
mesecon.torch_get_rules = function(param2) mesecon.torch_get_rules = function(param2)
local rules=mesecon:get_rules("mesecontorch") local rules=mesecon:get_rules("mesecontorch")
if param2 == 5 then if param2 == 5 then

View File

@ -28,15 +28,11 @@ minetest.register_node("mesecons_walllever:wall_lever_on", {
groups = {dig_immediate=2}, groups = {dig_immediate=2},
drop = '"mesecons_walllever:wall_lever_off" 1', drop = '"mesecons_walllever:wall_lever_off" 1',
description="Lever", description="Lever",
after_dig_node = function(pos)
mesecon:receptor_off(pos, mesecon.button_get_rules(minetest.env:get_node(pos).param2))
end
}) })
minetest.register_on_dignode(
function(pos, oldnode, digger)
if oldnode.name == "mesecons_walllever:wall_lever_on" then
mesecon:receptor_off(pos, mesecon.button_get_rules(oldnode.param2))
end
end
)
minetest.register_on_punchnode(function(pos, node, puncher) minetest.register_on_punchnode(function(pos, node, puncher)
if node.name == "mesecons_walllever:wall_lever_off" then if node.name == "mesecons_walllever:wall_lever_off" then
minetest.env:add_node(pos, {name="mesecons_walllever:wall_lever_on",param2=node.param2}) minetest.env:add_node(pos, {name="mesecons_walllever:wall_lever_on",param2=node.param2})