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 = {}
-- Default to enabled in singleplayer and disabled in multiplayer
local singleplayer = minetest.is_singleplayer()
local setting = minetest.setting_getbool("enable_tnt")
if (not singleplayer and setting ~= true) or
(singleplayer and setting == false) then
return
-- Default to enabled when in singleplayer
local enable_tnt = minetest.setting_getbool("enable_tnt")
if enable_tnt == nil
enable_tnt = minetest.is_singleplayer()
end
-- loss probabilities array (one in X will be lost)
@ -492,20 +490,13 @@ minetest.register_node("tnt:gunpowder_burning", {
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({
output = "tnt:gunpowder",
type = "shapeless",
recipe = {"default:coal_lump", "default:gravel"}
})
if enable_tnt then
minetest.register_craft({
output = "tnt:tnt",
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)
local name = ""
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"
if not def.damage_radius then def.damage_radius = def.radius * 2 end
if enable_tnt then
minetest.register_node(":" .. name, {
description = def.description,
tiles = {tnt_top, tnt_bottom, tnt_side},
@ -554,6 +555,7 @@ function tnt.register_tnt(def)
}
},
})
end
minetest.register_node(":" .. name .. "_burning", {
tiles = {
@ -590,4 +592,3 @@ tnt.register_tnt({
description = "TNT",
radius = radius,
})