diff --git a/mesecons/services.lua b/mesecons/services.lua index 831f6f3..b1388ec 100644 --- a/mesecons/services.lua +++ b/mesecons/services.lua @@ -63,6 +63,13 @@ mesecon.on_dignode = function(pos, node) mesecon.execute_autoconnect_hooks_queue(pos, node) end +function mesecon.on_blastnode(pos, intensity) + local node = minetest.get_node(pos) + minetest.remove_node(pos) + mesecon.on_dignode(pos, node) + return minetest.get_node_drops(node.name, "") +end + minetest.register_on_placenode(mesecon.on_placenode) minetest.register_on_dignode(mesecon.on_dignode) diff --git a/mesecons/util.lua b/mesecons/util.lua index 39f5696..a22d664 100644 --- a/mesecons/util.lua +++ b/mesecons/util.lua @@ -178,6 +178,7 @@ end function mesecon.register_node(name, spec_common, spec_off, spec_on) spec_common.drop = spec_common.drop or name .. "_off" + spec_common.on_blast = spec_common.on_blast or mesecon.on_blastnode spec_common.__mesecon_basename = name spec_on.__mesecon_state = "on" spec_off.__mesecon_state = "off" diff --git a/mesecons_button/init.lua b/mesecons_button/init.lua index c67c149..89f0355 100644 --- a/mesecons_button/init.lua +++ b/mesecons_button/init.lua @@ -52,7 +52,8 @@ minetest.register_node("mesecons_button:button_off", { mesecons = {receptor = { state = mesecon.state.off, rules = mesecon.rules.buttonlike_get - }} + }}, + on_blast = mesecon.on_blastnode, }) minetest.register_node("mesecons_button:button_on", { @@ -92,6 +93,7 @@ minetest.register_node("mesecons_button:button_on", { rules = mesecon.rules.buttonlike_get }}, on_timer = mesecon.button_turnoff, + on_blast = mesecon.on_blastnode, }) minetest.register_craft({ diff --git a/mesecons_commandblock/init.lua b/mesecons_commandblock/init.lua index 6cd0027..e4484f5 100644 --- a/mesecons_commandblock/init.lua +++ b/mesecons_commandblock/init.lua @@ -189,7 +189,8 @@ minetest.register_node("mesecons_commandblock:commandblock_off", { sounds = default.node_sound_stone_defaults(), mesecons = {effector = { action_on = commandblock_action_on - }} + }}, + on_blast = mesecon.on_blastnode, }) minetest.register_node("mesecons_commandblock:commandblock_on", { @@ -204,5 +205,6 @@ minetest.register_node("mesecons_commandblock:commandblock_on", { sounds = default.node_sound_stone_defaults(), mesecons = {effector = { action_off = commandblock_action_off - }} + }}, + on_blast = mesecon.on_blastnode, }) diff --git a/mesecons_delayer/init.lua b/mesecons_delayer/init.lua index 7c480c1..3ae9484 100644 --- a/mesecons_delayer/init.lua +++ b/mesecons_delayer/init.lua @@ -114,7 +114,8 @@ minetest.register_node("mesecons_delayer:delayer_off_"..tostring(i), { rules = delayer_get_input_rules, action_on = delayer_activate } - } + }, + on_blast = mesecon.on_blastnode, }) @@ -168,7 +169,8 @@ minetest.register_node("mesecons_delayer:delayer_on_"..tostring(i), { rules = delayer_get_input_rules, action_off = delayer_deactivate } - } + }, + on_blast = mesecon.on_blastnode, }) end diff --git a/mesecons_detector/init.lua b/mesecons_detector/init.lua index 397543c..a6e729b 100644 --- a/mesecons_detector/init.lua +++ b/mesecons_detector/init.lua @@ -35,7 +35,7 @@ local function object_detector_scan(pos) for _, str in pairs(string.split(scanname:gsub(" ", ""), ",")) do scan_for[str] = true end - + local every_player = scanname == "" for _, obj in pairs(objs) do -- "" is returned if it is not a player; "" ~= nil; so only handle objects with foundname ~= "" @@ -76,7 +76,8 @@ minetest.register_node("mesecons_detector:object_detector_off", { on_construct = object_detector_make_formspec, on_receive_fields = object_detector_on_receive_fields, sounds = default.node_sound_stone_defaults(), - digiline = object_detector_digiline + digiline = object_detector_digiline, + on_blast = mesecon.on_blastnode, }) minetest.register_node("mesecons_detector:object_detector_on", { @@ -92,7 +93,8 @@ minetest.register_node("mesecons_detector:object_detector_on", { on_construct = object_detector_make_formspec, on_receive_fields = object_detector_on_receive_fields, sounds = default.node_sound_stone_defaults(), - digiline = object_detector_digiline + digiline = object_detector_digiline, + on_blast = mesecon.on_blastnode, }) minetest.register_craft({ @@ -181,12 +183,12 @@ local node_detector_digiline = { effector = { action = function(pos, node, channel, msg) local meta = minetest.get_meta(pos) - + local distance = meta:get_int("distance") local distance_max = mesecon.setting("node_detector_distance_max", 10) if distance < 0 then distance = 0 end if distance > distance_max then distance = distance_max end - + if channel ~= meta:get_string("digiline_channel") then return end if msg == GET_COMMAND then @@ -234,7 +236,8 @@ minetest.register_node("mesecons_detector:node_detector_off", { on_construct = node_detector_make_formspec, on_receive_fields = node_detector_on_receive_fields, sounds = default.node_sound_stone_defaults(), - digiline = node_detector_digiline + digiline = node_detector_digiline, + on_blast = mesecon.on_blastnode, }) minetest.register_node("mesecons_detector:node_detector_on", { @@ -250,7 +253,8 @@ minetest.register_node("mesecons_detector:node_detector_on", { on_construct = node_detector_make_formspec, on_receive_fields = node_detector_on_receive_fields, sounds = default.node_sound_stone_defaults(), - digiline = node_detector_digiline + digiline = node_detector_digiline, + on_blast = mesecon.on_blastnode, }) minetest.register_craft({ diff --git a/mesecons_extrawires/corner.lua b/mesecons_extrawires/corner.lua index 6033893..4b90260 100644 --- a/mesecons_extrawires/corner.lua +++ b/mesecons_extrawires/corner.lua @@ -44,7 +44,8 @@ minetest.register_node("mesecons_extrawires:corner_on", { state = mesecon.state.on, rules = corner_get_rules, offstate = "mesecons_extrawires:corner_off" - }} + }}, + on_blast = mesecon.on_blastnode, }) minetest.register_node("mesecons_extrawires:corner_off", { @@ -70,7 +71,8 @@ minetest.register_node("mesecons_extrawires:corner_off", { state = mesecon.state.off, rules = corner_get_rules, onstate = "mesecons_extrawires:corner_on" - }} + }}, + on_blast = mesecon.on_blastnode, }) minetest.register_craft({ diff --git a/mesecons_extrawires/crossover.lua b/mesecons_extrawires/crossover.lua index 8f3b8c2..95aeeaa 100644 --- a/mesecons_extrawires/crossover.lua +++ b/mesecons_extrawires/crossover.lua @@ -39,6 +39,7 @@ minetest.register_node("mesecons_extrawires:crossover_off", { rules = crossover_get_rules(), } }, + on_blast = mesecon.on_blastnode, }) minetest.register_node("mesecons_extrawires:crossover_01", { @@ -63,6 +64,7 @@ minetest.register_node("mesecons_extrawires:crossover_01", { rules = crossover_get_rules(), } }, + on_blast = mesecon.on_blastnode, }) minetest.register_node("mesecons_extrawires:crossover_10", { @@ -87,6 +89,7 @@ minetest.register_node("mesecons_extrawires:crossover_10", { rules = crossover_get_rules(), } }, + on_blast = mesecon.on_blastnode, }) minetest.register_node("mesecons_extrawires:crossover_on", { @@ -111,6 +114,7 @@ minetest.register_node("mesecons_extrawires:crossover_on", { rules = crossover_get_rules(), } }, + on_blast = mesecon.on_blastnode, }) minetest.register_craft({ diff --git a/mesecons_extrawires/mesewire.lua b/mesecons_extrawires/mesewire.lua index 3640de8..455f75f 100644 --- a/mesecons_extrawires/mesewire.lua +++ b/mesecons_extrawires/mesewire.lua @@ -26,7 +26,8 @@ local powered_def = mesecon.mergetable(minetest.registered_nodes["default:mese"] offstate = "default:mese", rules = mesewire_rules }}, - groups = {cracky = 1, not_in_creative_inventory = 1} + groups = {cracky = 1, not_in_creative_inventory = 1}, + on_blast = mesecon.on_blastnode, }) for i, v in pairs(powered_def.tiles) do diff --git a/mesecons_extrawires/tjunction.lua b/mesecons_extrawires/tjunction.lua index 70f343b..1bfc48a 100644 --- a/mesecons_extrawires/tjunction.lua +++ b/mesecons_extrawires/tjunction.lua @@ -45,7 +45,8 @@ minetest.register_node("mesecons_extrawires:tjunction_on", { state = mesecon.state.on, rules = tjunction_get_rules, offstate = "mesecons_extrawires:tjunction_off" - }} + }}, + on_blast = mesecon.on_blastnode, }) minetest.register_node("mesecons_extrawires:tjunction_off", { @@ -71,7 +72,8 @@ minetest.register_node("mesecons_extrawires:tjunction_off", { state = mesecon.state.off, rules = tjunction_get_rules, onstate = "mesecons_extrawires:tjunction_on" - }} + }}, + on_blast = mesecon.on_blastnode, }) minetest.register_craft({ diff --git a/mesecons_fpga/init.lua b/mesecons_fpga/init.lua index 7a78d46..0c56d7d 100644 --- a/mesecons_fpga/init.lua +++ b/mesecons_fpga/init.lua @@ -116,6 +116,7 @@ plg.register_nodes({ after_dig_node = function(pos, node) mesecon.receptor_off(pos, plg.rules[node.name]) end, + on_blast = mesecon.on_blastnode, on_rotate = function(pos, node, user, mode) local abcd1 = {"A", "B", "C", "D"} local abcd2 = {A = 1, B = 2, C = 3, D = 4} diff --git a/mesecons_hydroturbine/init.lua b/mesecons_hydroturbine/init.lua index 409da75..53dedac 100644 --- a/mesecons_hydroturbine/init.lua +++ b/mesecons_hydroturbine/init.lua @@ -24,7 +24,8 @@ minetest.register_node("mesecons_hydroturbine:hydro_turbine_off", { sounds = default.node_sound_stone_defaults(), mesecons = {receptor = { state = mesecon.state.off - }} + }}, + on_blast = mesecon.on_blastnode, }) minetest.register_node("mesecons_hydroturbine:hydro_turbine_on", { @@ -51,7 +52,8 @@ minetest.register_node("mesecons_hydroturbine:hydro_turbine_on", { sounds = default.node_sound_stone_defaults(), mesecons = {receptor = { state = mesecon.state.on - }} + }}, + on_blast = mesecon.on_blastnode, }) diff --git a/mesecons_insulated/init.lua b/mesecons_insulated/init.lua index 891b5d3..b494540 100644 --- a/mesecons_insulated/init.lua +++ b/mesecons_insulated/init.lua @@ -36,7 +36,8 @@ minetest.register_node("mesecons_insulated:insulated_on", { state = mesecon.state.on, offstate = "mesecons_insulated:insulated_off", rules = insulated_wire_get_rules - }} + }}, + on_blast = mesecon.on_blastnode, }) minetest.register_node("mesecons_insulated:insulated_off", { @@ -67,7 +68,8 @@ minetest.register_node("mesecons_insulated:insulated_off", { state = mesecon.state.off, onstate = "mesecons_insulated:insulated_on", rules = insulated_wire_get_rules - }} + }}, + on_blast = mesecon.on_blastnode, }) minetest.register_craft({ diff --git a/mesecons_lamp/init.lua b/mesecons_lamp/init.lua index 6f38b27..15c89ff 100644 --- a/mesecons_lamp/init.lua +++ b/mesecons_lamp/init.lua @@ -27,7 +27,8 @@ minetest.register_node("mesecons_lamp:lamp_on", { action_off = function (pos, node) minetest.swap_node(pos, {name = "mesecons_lamp:lamp_off", param2 = node.param2}) end - }} + }}, + on_blast = mesecon.on_blastnode, }) minetest.register_node("mesecons_lamp:lamp_off", { @@ -48,7 +49,8 @@ minetest.register_node("mesecons_lamp:lamp_off", { action_on = function (pos, node) minetest.swap_node(pos, {name = "mesecons_lamp:lamp_on", param2 = node.param2}) end - }} + }}, + on_blast = mesecon.on_blastnode, }) minetest.register_craft({ diff --git a/mesecons_lightstone/init.lua b/mesecons_lightstone/init.lua index 1b8e222..765c65a 100644 --- a/mesecons_lightstone/init.lua +++ b/mesecons_lightstone/init.lua @@ -20,7 +20,7 @@ function mesecon.lightstone_add(name, base_item, texture_off, texture_on, desc) end minetest.register_node("mesecons_lightstone:lightstone_" .. name .. "_off", { tiles = {texture_off}, - groups = {cracky=2, mesecon_effector_off = 1, mesecon = 2}, + groups = {cracky = 2, mesecon_effector_off = 1, mesecon = 2}, description = desc, sounds = default.node_sound_stone_defaults(), mesecons = {effector = { @@ -28,20 +28,22 @@ function mesecon.lightstone_add(name, base_item, texture_off, texture_on, desc) action_on = function (pos, node) minetest.swap_node(pos, {name = "mesecons_lightstone:lightstone_" .. name .. "_on", param2 = node.param2}) end, - }} + }}, + on_blast = mesecon.on_blastnode, }) minetest.register_node("mesecons_lightstone:lightstone_" .. name .. "_on", { - tiles = {texture_on}, - groups = {cracky=2,not_in_creative_inventory=1, mesecon = 2}, - drop = "mesecons_lightstone:lightstone_" .. name .. "_off", - light_source = default.LIGHT_MAX-2, - sounds = default.node_sound_stone_defaults(), - mesecons = {effector = { - rules = lightstone_rules, - action_off = function (pos, node) - minetest.swap_node(pos, {name = "mesecons_lightstone:lightstone_" .. name .. "_off", param2 = node.param2}) - end, - }} + tiles = {texture_on}, + groups = {cracky = 2, not_in_creative_inventory = 1, mesecon = 2}, + drop = "mesecons_lightstone:lightstone_" .. name .. "_off", + light_source = minetest.LIGHT_MAX - 2, + sounds = default.node_sound_stone_defaults(), + mesecons = {effector = { + rules = lightstone_rules, + action_off = function (pos, node) + minetest.swap_node(pos, {name = "mesecons_lightstone:lightstone_" .. name .. "_off", param2 = node.param2}) + end, + }}, + on_blast = mesecon.on_blastnode, }) minetest.register_craft({ diff --git a/mesecons_luacontroller/init.lua b/mesecons_luacontroller/init.lua index 25273a1..ea285d4 100644 --- a/mesecons_luacontroller/init.lua +++ b/mesecons_luacontroller/init.lua @@ -629,6 +629,7 @@ for d = 0, 1 do mesecon.receptor_off(pos, output_rules) end, is_luacontroller = true, + on_blast = mesecon.on_blastnode, }) end end @@ -669,6 +670,7 @@ minetest.register_node(BASENAME .. "_burnt", { end, }, }, + on_blast = mesecon.on_blastnode, }) ------------------------ diff --git a/mesecons_microcontroller/init.lua b/mesecons_microcontroller/init.lua index ef78f60..4f14240 100644 --- a/mesecons_microcontroller/init.lua +++ b/mesecons_microcontroller/init.lua @@ -138,6 +138,7 @@ minetest.register_node(nodename, { rules = microc_rules[node.name] mesecon.receptor_off(pos, rules) end, + on_blast = mesecon.on_blastnode, }) end end diff --git a/mesecons_movestones/init.lua b/mesecons_movestones/init.lua index f4b6f58..2bba38d 100644 --- a/mesecons_movestones/init.lua +++ b/mesecons_movestones/init.lua @@ -111,6 +111,8 @@ function mesecon.register_movestone(name, def, is_sticky) def.drop = name + def.on_blast = mesecon.on_blastnode + minetest.register_node(name, def) -- active node only diff --git a/mesecons_noteblock/init.lua b/mesecons_noteblock/init.lua index d5e365c..869a2a0 100644 --- a/mesecons_noteblock/init.lua +++ b/mesecons_noteblock/init.lua @@ -12,7 +12,8 @@ minetest.register_node("mesecons_noteblock:noteblock", { action_on = function(pos, node) mesecon.noteblock_play(pos, node.param2) end - }} + }}, + on_blast = mesecon.on_blastnode, }) minetest.register_craft({ diff --git a/mesecons_pistons/init.lua b/mesecons_pistons/init.lua index a52c802..e741855 100644 --- a/mesecons_pistons/init.lua +++ b/mesecons_pistons/init.lua @@ -184,7 +184,8 @@ minetest.register_node("mesecons_pistons:piston_normal_off", { mesecons = {effector={ action_on = piston_on, rules = piston_get_rules - }} + }}, + on_blast = mesecon.on_blastnode, }) -- onstate @@ -212,7 +213,8 @@ minetest.register_node("mesecons_pistons:piston_normal_on", { mesecons = {effector={ action_off = piston_off, rules = piston_get_rules - }} + }}, + on_blast = mesecon.on_blastnode, }) -- pusher @@ -232,6 +234,7 @@ minetest.register_node("mesecons_pistons:piston_pusher_normal", { corresponding_piston = "mesecons_pistons:piston_normal_on", selection_box = piston_pusher_box, node_box = piston_pusher_box, + drop = "", }) -- Sticky ones @@ -265,7 +268,8 @@ minetest.register_node("mesecons_pistons:piston_sticky_off", { mesecons = {effector={ action_on = piston_on, rules = piston_get_rules - }} + }}, + on_blast = mesecon.on_blastnode, }) -- onstate @@ -293,7 +297,8 @@ minetest.register_node("mesecons_pistons:piston_sticky_on", { mesecons = {effector={ action_off = piston_off, rules = piston_get_rules - }} + }}, + on_blast = mesecon.on_blastnode, }) -- pusher @@ -313,6 +318,7 @@ minetest.register_node("mesecons_pistons:piston_pusher_sticky", { corresponding_piston = "mesecons_pistons:piston_sticky_on", selection_box = piston_pusher_box, node_box = piston_pusher_box, + drop = "", }) -- @@ -364,7 +370,8 @@ minetest.register_node("mesecons_pistons:piston_up_normal_off", { mesecons = {effector={ action_on = piston_on, rules = piston_up_rules, - }} + }}, + on_blast = mesecon.on_blastnode, }) -- onstate @@ -392,7 +399,8 @@ minetest.register_node("mesecons_pistons:piston_up_normal_on", { mesecons = {effector={ action_off = piston_off, rules = piston_up_rules, - }} + }}, + on_blast = mesecon.on_blastnode, }) -- pusher @@ -412,6 +420,7 @@ minetest.register_node("mesecons_pistons:piston_up_pusher_normal", { corresponding_piston = "mesecons_pistons:piston_up_normal_on", selection_box = piston_up_pusher_box, node_box = piston_up_pusher_box, + drop = "", }) @@ -448,7 +457,8 @@ minetest.register_node("mesecons_pistons:piston_up_sticky_off", { mesecons = {effector={ action_on = piston_on, rules = piston_up_rules, - }} + }}, + on_blast = mesecon.on_blastnode, }) -- onstate @@ -476,7 +486,8 @@ minetest.register_node("mesecons_pistons:piston_up_sticky_on", { mesecons = {effector={ action_off = piston_off, rules = piston_up_rules, - }} + }}, + on_blast = mesecon.on_blastnode, }) -- pusher @@ -496,6 +507,7 @@ minetest.register_node("mesecons_pistons:piston_up_pusher_sticky", { corresponding_piston = "mesecons_pistons:piston_up_sticky_on", selection_box = piston_up_pusher_box, node_box = piston_up_pusher_box, + drop = "", }) -- @@ -550,7 +562,8 @@ minetest.register_node("mesecons_pistons:piston_down_normal_off", { mesecons = {effector={ action_on = piston_on, rules = piston_down_rules, - }} + }}, + on_blast = mesecon.on_blastnode, }) -- onstate @@ -578,7 +591,8 @@ minetest.register_node("mesecons_pistons:piston_down_normal_on", { mesecons = {effector={ action_off = piston_off, rules = piston_down_rules, - }} + }}, + on_blast = mesecon.on_blastnode, }) -- pusher @@ -598,6 +612,7 @@ minetest.register_node("mesecons_pistons:piston_down_pusher_normal", { corresponding_piston = "mesecons_pistons:piston_down_normal_on", selection_box = piston_down_pusher_box, node_box = piston_down_pusher_box, + drop = "", }) -- Sticky @@ -630,7 +645,8 @@ minetest.register_node("mesecons_pistons:piston_down_sticky_off", { mesecons = {effector={ action_on = piston_on, rules = piston_down_rules, - }} + }}, + on_blast = mesecon.on_blastnode, }) -- onstate @@ -658,7 +674,8 @@ minetest.register_node("mesecons_pistons:piston_down_sticky_on", { mesecons = {effector={ action_off = piston_off, rules = piston_down_rules, - }} + }}, + on_blast = mesecon.on_blastnode, }) -- pusher @@ -678,6 +695,7 @@ minetest.register_node("mesecons_pistons:piston_down_pusher_sticky", { corresponding_piston = "mesecons_pistons:piston_down_sticky_on", selection_box = piston_down_pusher_box, node_box = piston_down_pusher_box, + drop = "", }) diff --git a/mesecons_powerplant/init.lua b/mesecons_powerplant/init.lua index a5e3327..13b9f2c 100644 --- a/mesecons_powerplant/init.lua +++ b/mesecons_powerplant/init.lua @@ -18,7 +18,8 @@ minetest.register_node("mesecons_powerplant:power_plant", { sounds = default.node_sound_leaves_defaults(), mesecons = {receptor = { state = mesecon.state.on - }} + }}, + on_blast = mesecon.on_blastnode, }) minetest.register_craft({ diff --git a/mesecons_random/init.lua b/mesecons_random/init.lua index 326362e..397a995 100644 --- a/mesecons_random/init.lua +++ b/mesecons_random/init.lua @@ -12,7 +12,8 @@ minetest.register_node("mesecons_random:removestone", { mesecon.on_dignode(pos, node) minetest.check_for_falling(vector.add(pos, vector.new(0, 1, 0))) end - }} + }}, + on_blast = mesecon.on_blastnode, }) minetest.register_craft({ @@ -37,7 +38,8 @@ minetest.register_node("mesecons_random:ghoststone", { state = mesecon.state.off, rules = mesecon.rules.alldirs, onstate = "mesecons_random:ghoststone_active" - }} + }}, + on_blast = mesecon.on_blastnode, }) minetest.register_node("mesecons_random:ghoststone_active", { @@ -59,7 +61,8 @@ minetest.register_node("mesecons_random:ghoststone_active", { if (minetest.get_node(shadowpos).name == "air") then minetest.dig_node(shadowpos) end - end + end, + on_blast = mesecon.on_blastnode, }) diff --git a/mesecons_solarpanel/init.lua b/mesecons_solarpanel/init.lua index bc5a408..cbf8878 100644 --- a/mesecons_solarpanel/init.lua +++ b/mesecons_solarpanel/init.lua @@ -25,7 +25,8 @@ minetest.register_node("mesecons_solarpanel:solar_panel_on", { sounds = default.node_sound_glass_defaults(), mesecons = {receptor = { state = mesecon.state.on - }} + }}, + on_blast = mesecon.on_blastnode, }) -- Solar Panel @@ -55,7 +56,8 @@ minetest.register_node("mesecons_solarpanel:solar_panel_off", { sounds = default.node_sound_glass_defaults(), mesecons = {receptor = { state = mesecon.state.off - }} + }}, + on_blast = mesecon.on_blastnode, }) minetest.register_craft({ diff --git a/mesecons_torch/init.lua b/mesecons_torch/init.lua index 8b1632b..de16224 100644 --- a/mesecons_torch/init.lua +++ b/mesecons_torch/init.lua @@ -62,7 +62,8 @@ minetest.register_node("mesecons_torch:mesecon_torch_off", { mesecons = {receptor = { state = mesecon.state.off, rules = torch_get_output_rules - }} + }}, + on_blast = mesecon.on_blastnode, }) minetest.register_node("mesecons_torch:mesecon_torch_on", { @@ -82,6 +83,7 @@ minetest.register_node("mesecons_torch:mesecon_torch_on", { state = mesecon.state.on, rules = torch_get_output_rules }}, + on_blast = mesecon.on_blastnode, }) minetest.register_abm({