Handle blasts (#356)

This commit is contained in:
DS 2017-10-07 00:44:49 +02:00 committed by Vitaliy
parent 8999597df2
commit 905260c8db
24 changed files with 124 additions and 56 deletions

@ -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)

@ -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"

@ -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({

@ -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,
})

@ -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

@ -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({

@ -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({

@ -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({

@ -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

@ -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({

@ -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}

@ -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,
})

@ -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({

@ -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({

@ -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({

@ -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,
})
------------------------

@ -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

@ -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

@ -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({

@ -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 = "",
})

@ -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({

@ -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,
})

@ -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({

@ -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({