mirror of
https://github.com/minetest/minetest_game.git
synced 2024-12-23 07:10:19 +01:00
TNT: When disabled leave some useful functionality enabled
- Only remove the TNT craft recipe, tnt:tnt node and the ABM - Leave tnt:tnt_burning available for explosions in 3rd party mods
This commit is contained in:
parent
98551edd94
commit
497e6f6257
@ -1,10 +1,8 @@
|
|||||||
tnt = {}
|
tnt = {}
|
||||||
-- Default to enabled in singleplayer and disabled in multiplayer
|
-- Default to enabled when in singleplayer
|
||||||
local singleplayer = minetest.is_singleplayer()
|
local enable_tnt = minetest.setting_getbool("enable_tnt")
|
||||||
local setting = minetest.setting_getbool("enable_tnt")
|
if enable_tnt == nil
|
||||||
if (not singleplayer and setting ~= true) or
|
enable_tnt = minetest.is_singleplayer()
|
||||||
(singleplayer and setting == false) then
|
|
||||||
return
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- loss probabilities array (one in X will be lost)
|
-- loss probabilities array (one in X will be lost)
|
||||||
@ -492,28 +490,30 @@ minetest.register_node("tnt:gunpowder_burning", {
|
|||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_abm({
|
|
||||||
nodenames = {"group:tnt", "tnt:gunpowder"},
|
|
||||||
neighbors = {"fire:basic_flame", "default:lava_source", "default:lava_flowing"},
|
|
||||||
interval = 4,
|
|
||||||
chance = 1,
|
|
||||||
action = tnt.burn,
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = "tnt:gunpowder",
|
output = "tnt:gunpowder",
|
||||||
type = "shapeless",
|
type = "shapeless",
|
||||||
recipe = {"default:coal_lump", "default:gravel"}
|
recipe = {"default:coal_lump", "default:gravel"}
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_craft({
|
if enable_tnt then
|
||||||
output = "tnt:tnt",
|
minetest.register_craft({
|
||||||
recipe = {
|
output = "tnt:tnt",
|
||||||
{"", "group:wood", ""},
|
recipe = {
|
||||||
{"group:wood", "tnt:gunpowder", "group:wood"},
|
{"", "group:wood", ""},
|
||||||
{"", "group:wood", ""}
|
{"group:wood", "tnt:gunpowder", "group:wood"},
|
||||||
}
|
{"", "group:wood", ""}
|
||||||
})
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_abm({
|
||||||
|
nodenames = {"group:tnt", "tnt:gunpowder"},
|
||||||
|
neighbors = {"fire:basic_flame", "default:lava_source", "default:lava_flowing"},
|
||||||
|
interval = 4,
|
||||||
|
chance = 1,
|
||||||
|
action = tnt.burn,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
function tnt.register_tnt(def)
|
function tnt.register_tnt(def)
|
||||||
local name = ""
|
local name = ""
|
||||||
@ -530,30 +530,32 @@ function tnt.register_tnt(def)
|
|||||||
local tnt_burning = def.tiles.burning or def.name .. "_top_burning_animated.png"
|
local tnt_burning = def.tiles.burning or def.name .. "_top_burning_animated.png"
|
||||||
if not def.damage_radius then def.damage_radius = def.radius * 2 end
|
if not def.damage_radius then def.damage_radius = def.radius * 2 end
|
||||||
|
|
||||||
minetest.register_node(":" .. name, {
|
if enable_tnt then
|
||||||
description = def.description,
|
minetest.register_node(":" .. name, {
|
||||||
tiles = {tnt_top, tnt_bottom, tnt_side},
|
description = def.description,
|
||||||
is_ground_content = false,
|
tiles = {tnt_top, tnt_bottom, tnt_side},
|
||||||
groups = {dig_immediate = 2, mesecon = 2, tnt = 1},
|
is_ground_content = false,
|
||||||
sounds = default.node_sound_wood_defaults(),
|
groups = {dig_immediate = 2, mesecon = 2, tnt = 1},
|
||||||
on_punch = function(pos, node, puncher)
|
sounds = default.node_sound_wood_defaults(),
|
||||||
if puncher:get_wielded_item():get_name() == "default:torch" then
|
on_punch = function(pos, node, puncher)
|
||||||
minetest.set_node(pos, {name = name .. "_burning"})
|
if puncher:get_wielded_item():get_name() == "default:torch" then
|
||||||
end
|
minetest.set_node(pos, {name = name .. "_burning"})
|
||||||
end,
|
|
||||||
on_blast = function(pos, intensity)
|
|
||||||
minetest.after(0.1, function()
|
|
||||||
tnt.boom(pos, def)
|
|
||||||
end)
|
|
||||||
end,
|
|
||||||
mesecons = {effector =
|
|
||||||
{action_on =
|
|
||||||
function(pos)
|
|
||||||
tnt.boom(pos, def)
|
|
||||||
end
|
end
|
||||||
}
|
end,
|
||||||
},
|
on_blast = function(pos, intensity)
|
||||||
})
|
minetest.after(0.1, function()
|
||||||
|
tnt.boom(pos, def)
|
||||||
|
end)
|
||||||
|
end,
|
||||||
|
mesecons = {effector =
|
||||||
|
{action_on =
|
||||||
|
function(pos)
|
||||||
|
tnt.boom(pos, def)
|
||||||
|
end
|
||||||
|
}
|
||||||
|
},
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
minetest.register_node(":" .. name .. "_burning", {
|
minetest.register_node(":" .. name .. "_burning", {
|
||||||
tiles = {
|
tiles = {
|
||||||
@ -590,4 +592,3 @@ tnt.register_tnt({
|
|||||||
description = "TNT",
|
description = "TNT",
|
||||||
radius = radius,
|
radius = radius,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user