Disabling TNT defuses it
This commit is contained in:
parent
5bb5829e86
commit
524aa71aea
@ -13,8 +13,11 @@ tnt = {}
|
|||||||
local singleplayer = minetest.is_singleplayer()
|
local singleplayer = minetest.is_singleplayer()
|
||||||
local setting = minetest.settings:get_bool("tnt_enable")
|
local setting = minetest.settings:get_bool("tnt_enable")
|
||||||
|
|
||||||
|
local tnt_enable
|
||||||
if (not singleplayer and setting ~= true) or (singleplayer and setting == false) then
|
if (not singleplayer and setting ~= true) or (singleplayer and setting == false) then
|
||||||
return
|
tnt_enable = false
|
||||||
|
else
|
||||||
|
tnt_enable = true
|
||||||
end
|
end
|
||||||
|
|
||||||
local tnt_radius = tonumber(minetest.settings:get("tnt_radius") or 3)
|
local tnt_radius = tonumber(minetest.settings:get("tnt_radius") or 3)
|
||||||
@ -155,7 +158,7 @@ end
|
|||||||
|
|
||||||
function tnt.burn(pos)
|
function tnt.burn(pos)
|
||||||
local name = minetest.get_node(pos).name
|
local name = minetest.get_node(pos).name
|
||||||
if name == "tnt:tnt" then
|
if tnt_enable and name == "tnt:tnt" then
|
||||||
minetest.sound_play("tnt_ignite", {pos = pos})
|
minetest.sound_play("tnt_ignite", {pos = pos})
|
||||||
minetest.set_node(pos, {name = "tnt:tnt_burning"})
|
minetest.set_node(pos, {name = "tnt:tnt_burning"})
|
||||||
minetest.get_node_timer(pos):start(2)
|
minetest.get_node_timer(pos):start(2)
|
||||||
@ -212,12 +215,13 @@ end
|
|||||||
|
|
||||||
function tnt.boom(pos)
|
function tnt.boom(pos)
|
||||||
minetest.remove_node(pos)
|
minetest.remove_node(pos)
|
||||||
|
if tnt_enable then
|
||||||
local drops = tnt.explode(pos, tnt_radius, "tnt_explode")
|
local drops = tnt.explode(pos, tnt_radius, "tnt_explode")
|
||||||
entity_physics(pos, tnt_radius)
|
entity_physics(pos, tnt_radius)
|
||||||
eject_drops(drops, pos, tnt_radius)
|
eject_drops(drops, pos, tnt_radius)
|
||||||
add_effects(pos, tnt_radius)
|
add_effects(pos, tnt_radius)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- On load register content IDs
|
-- On load register content IDs
|
||||||
|
|
||||||
@ -235,16 +239,28 @@ minetest.register_on_mods_loaded(on_load)
|
|||||||
|
|
||||||
-- Nodes
|
-- Nodes
|
||||||
|
|
||||||
|
local top_tex, desc
|
||||||
|
if tnt_enable then
|
||||||
|
top_tex = "tnt_top.png"
|
||||||
|
desc = S("TNT")
|
||||||
|
else
|
||||||
|
top_tex = "tnt_top_disabled.png"
|
||||||
|
desc = S("Defused TNT")
|
||||||
|
end
|
||||||
|
|
||||||
minetest.register_node(
|
minetest.register_node(
|
||||||
"tnt:tnt",
|
"tnt:tnt",
|
||||||
{
|
{
|
||||||
description = S("TNT"),
|
description = desc,
|
||||||
tiles = {"tnt_top.png", "tnt_bottom.png", "tnt_sides.png"},
|
tiles = {top_tex, "tnt_bottom.png", "tnt_sides.png"},
|
||||||
is_ground_content = false,
|
is_ground_content = false,
|
||||||
groups = {dig_immediate = 2},
|
groups = {dig_immediate = 2},
|
||||||
sounds = default.node_sound_wood_defaults(),
|
sounds = default.node_sound_wood_defaults(),
|
||||||
|
|
||||||
on_punch = function(pos, node, puncher)
|
on_punch = function(pos, node, puncher)
|
||||||
|
if not tnt_enable then
|
||||||
|
return
|
||||||
|
end
|
||||||
local itemname = puncher:get_wielded_item():get_name()
|
local itemname = puncher:get_wielded_item():get_name()
|
||||||
|
|
||||||
if itemname == "default:flint_and_steel" then
|
if itemname == "default:flint_and_steel" then
|
||||||
@ -252,7 +268,9 @@ minetest.register_node(
|
|||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
on_blast = function(pos, intensity)
|
on_blast = function(pos, intensity)
|
||||||
|
if tnt_enable then
|
||||||
tnt.burn(pos)
|
tnt.burn(pos)
|
||||||
|
end
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -282,6 +300,7 @@ minetest.register_node(
|
|||||||
on_blast = function() end,
|
on_blast = function() end,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
-- Crafting
|
-- Crafting
|
||||||
|
|
||||||
crafting.register_craft(
|
crafting.register_craft(
|
||||||
@ -302,11 +321,20 @@ minetest.register_craft(
|
|||||||
|
|
||||||
-- Achievements
|
-- Achievements
|
||||||
|
|
||||||
|
local title, desc
|
||||||
|
if tnt_enable then
|
||||||
|
title = S("Boom!")
|
||||||
|
desc = S("Craft TNT.")
|
||||||
|
else
|
||||||
|
title = S("Boom?")
|
||||||
|
desc = S("Craft defused TNT.")
|
||||||
|
end
|
||||||
|
|
||||||
achievements.register_achievement(
|
achievements.register_achievement(
|
||||||
"boom",
|
"boom",
|
||||||
{
|
{
|
||||||
title = S("Boom!"),
|
title = title,
|
||||||
description = S("Craft TNT."),
|
description = desc,
|
||||||
times = 1,
|
times = 1,
|
||||||
craftitem = "tnt:tnt",
|
craftitem = "tnt:tnt",
|
||||||
})
|
})
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
# textdomain: tnt
|
# textdomain: tnt
|
||||||
TNT=
|
TNT=
|
||||||
|
Defused TNT=
|
||||||
Boom!=
|
Boom!=
|
||||||
|
Boom?=
|
||||||
Craft TNT.=
|
Craft TNT.=
|
||||||
|
Craft defused TNT.=
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
# textdomain: tnt
|
# textdomain: tnt
|
||||||
TNT=TNT
|
TNT=TNT
|
||||||
|
Defused TNT=Entschärftes TNT
|
||||||
Boom!=Bumm!
|
Boom!=Bumm!
|
||||||
|
Boom?=Bumm?
|
||||||
Craft TNT.=Fertigen Sie TNT.
|
Craft TNT.=Fertigen Sie TNT.
|
||||||
|
Craft defused TNT.=Fertigen Sie entschärftes TNT.
|
||||||
|
BIN
mods/tnt/textures/tnt_top_disabled.png
Normal file
BIN
mods/tnt/textures/tnt_top_disabled.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.9 KiB |
@ -19,10 +19,8 @@ give_initial_items (Initial items) string default:pick_stone,default:torch_weak
|
|||||||
|
|
||||||
## TNT
|
## TNT
|
||||||
|
|
||||||
# This enables TNT. TNT is a block that, if ignited, will explode, deal damage and destroy blocks around it.
|
# This enables TNT. TNT is a block that, when ignited, will explode, deal damage and destroy blocks around it.
|
||||||
# If disabled, TNT will be completely removed from the game.
|
# If disabled, all TNT will be defused and thus unable to explode.
|
||||||
#
|
|
||||||
# Warning: If you disable this setting in a world in which TNT already existed, there will be bugs!
|
|
||||||
tnt_enable (Enable TNT) bool true
|
tnt_enable (Enable TNT) bool true
|
||||||
|
|
||||||
# The radius in which blocks will be destroyed by a TNT explosion.
|
# The radius in which blocks will be destroyed by a TNT explosion.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user