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:
tenplus1 2016-06-27 16:45:40 +02:00 committed by paramat
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,20 +490,13 @@ 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"}
}) })
if enable_tnt then
minetest.register_craft({ minetest.register_craft({
output = "tnt:tnt", output = "tnt:tnt",
recipe = { recipe = {
@ -515,6 +506,15 @@ minetest.register_craft({
} }
}) })
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 = ""
if not def.name:find(':') then if not def.name:find(':') then
@ -530,6 +530,7 @@ 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
if enable_tnt then
minetest.register_node(":" .. name, { minetest.register_node(":" .. name, {
description = def.description, description = def.description,
tiles = {tnt_top, tnt_bottom, tnt_side}, tiles = {tnt_top, tnt_bottom, tnt_side},
@ -554,6 +555,7 @@ function tnt.register_tnt(def)
} }
}, },
}) })
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,
}) })