Skip to content
Permalink
Browse files

Handle blasts (#356)

  • Loading branch information...
DS-Minetest authored and numberZero committed Oct 6, 2017
1 parent 8999597 commit 905260c8db2d7d4844e3955fa38a79da233b3ab7
@@ -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,28 +20,30 @@ 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 = {
rules = lightstone_rules,
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({
Oops, something went wrong.

0 comments on commit 905260c

Please sign in to comment.
You can’t perform that action at this time.