Skip to content

Commit

Permalink
TNT: When disabled leave some useful functionality enabled
Browse files Browse the repository at this point in the history
- Only remove the TNT craft recipe, tnt:tnt node and the ABM
- Leave tnt:tnt_burning available for explosions in 3rd party mods
  • Loading branch information
tenplus1 authored and paramat committed Jul 7, 2016
1 parent 98551ed commit 497e6f6
Showing 1 changed file with 47 additions and 46 deletions.
93 changes: 47 additions & 46 deletions mods/tnt/init.lua
@@ -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)
Expand Down Expand Up @@ -492,28 +490,30 @@ 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"}
})

minetest.register_craft({
output = "tnt:tnt",
recipe = {
{"", "group:wood", ""},
{"group:wood", "tnt:gunpowder", "group:wood"},
{"", "group:wood", ""}
}
})
if enable_tnt then
minetest.register_craft({
output = "tnt:tnt",
recipe = {
{"", "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)
local name = ""
Expand All @@ -530,30 +530,32 @@ 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

minetest.register_node(":" .. name, {
description = def.description,
tiles = {tnt_top, tnt_bottom, tnt_side},
is_ground_content = false,
groups = {dig_immediate = 2, mesecon = 2, tnt = 1},
sounds = default.node_sound_wood_defaults(),
on_punch = function(pos, node, puncher)
if puncher:get_wielded_item():get_name() == "default:torch" then
minetest.set_node(pos, {name = name .. "_burning"})
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)
if enable_tnt then
minetest.register_node(":" .. name, {
description = def.description,
tiles = {tnt_top, tnt_bottom, tnt_side},
is_ground_content = false,
groups = {dig_immediate = 2, mesecon = 2, tnt = 1},
sounds = default.node_sound_wood_defaults(),
on_punch = function(pos, node, puncher)
if puncher:get_wielded_item():get_name() == "default:torch" then
minetest.set_node(pos, {name = name .. "_burning"})
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", {
tiles = {
Expand Down Expand Up @@ -590,4 +592,3 @@ tnt.register_tnt({
description = "TNT",
radius = radius,
})

0 comments on commit 497e6f6

Please sign in to comment.