tnt: redo faulty merge, add infomessage for when privilege missing
This commit is contained in:
parent
5ec33282d3
commit
d2ef1a0af2
@ -1,6 +1,12 @@
|
||||
tnt = {}
|
||||
core.register_privilege("trusted_player", "special grantings, used for tnt for example")
|
||||
|
||||
-- Default to enabled when in singleplayer
|
||||
local enable_tnt = minetest.settings:get_bool("enable_tnt")
|
||||
if enable_tnt == nil then
|
||||
enable_tnt = minetest.is_singleplayer()
|
||||
end
|
||||
|
||||
-- loss probabilities array (one in X will be lost)
|
||||
local loss_prob = {}
|
||||
|
||||
@ -78,7 +84,6 @@ local function add_drop(drops, item)
|
||||
end
|
||||
end
|
||||
|
||||
=======
|
||||
local basic_flame_on_construct -- cached value
|
||||
local function destroy(drops, npos, cid, c_air, c_fire,
|
||||
on_blast_queue, on_construct_queue,
|
||||
@ -92,9 +97,16 @@ local function destroy(drops, npos, cid, c_air, c_fire,
|
||||
if not def then
|
||||
return c_air
|
||||
elseif not ignore_on_blast and def.on_blast then
|
||||
on_blast_queue[#on_blast_queue + 1] = {pos = vector.new(npos), on_blast = def.on_blast}
|
||||
on_blast_queue[#on_blast_queue + 1] = {
|
||||
pos = vector.new(npos),
|
||||
on_blast = def.on_blast
|
||||
}
|
||||
return cid
|
||||
elseif def.flammable then
|
||||
on_construct_queue[#on_construct_queue + 1] = {
|
||||
fn = basic_flame_on_construct,
|
||||
pos = vector.new(npos)
|
||||
}
|
||||
return c_fire
|
||||
else
|
||||
local node_drops = minetest.get_node_drops(def.name, "")
|
||||
@ -307,6 +319,8 @@ local function tnt_explode(pos, radius, ignore_protection, ignore_on_blast, owne
|
||||
|
||||
local drops = {}
|
||||
local on_blast_queue = {}
|
||||
local on_construct_queue = {}
|
||||
basic_flame_on_construct = minetest.registered_nodes["fire:basic_flame"].on_construct
|
||||
|
||||
local c_fire = minetest.get_content_id("fire:basic_flame")
|
||||
for z = -radius, radius do
|
||||
@ -428,13 +442,14 @@ minetest.register_node("tnt:gunpowder", {
|
||||
on_punch = function(pos, node, puncher)
|
||||
if puncher:get_wielded_item():get_name() == "default:torch" then
|
||||
if(minetest.check_player_privs(puncher:get_player_name(), {trusted_player=true})) then
|
||||
--tnt.burn(pos)
|
||||
minetest.set_node(pos, {name = "tnt:gunpowder_burning"})
|
||||
minetest.log("action", puncher:get_player_name() ..
|
||||
" ignites tnt:gunpowder at " ..
|
||||
minetest.pos_to_string(pos))
|
||||
end
|
||||
end
|
||||
" ignites tnt:gunpowder at " ..
|
||||
minetest.pos_to_string(pos))
|
||||
else
|
||||
minetest.chat_send_player(puncher, "missing privilege trusted_player")
|
||||
end
|
||||
end
|
||||
end,
|
||||
on_blast = function(pos, intensity)
|
||||
minetest.set_node(pos, {name = "tnt:gunpowder_burning"})
|
||||
@ -527,29 +542,30 @@ minetest.register_node("tnt:gunpowder_burning", {
|
||||
minetest.register_craft({
|
||||
output = "tnt:gunpowder 5",
|
||||
type = "shapeless",
|
||||
groups = {gunpowder = 1},
|
||||
recipe = {"default:coal_lump", "default:gravel"}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "tnt:tnt",
|
||||
recipe = {
|
||||
{"group:wood", "tnt:gunpowder", "group:wood"},
|
||||
{"tnt:gunpowder", "tnt:gunpowder", "tnt:gunpowder"},
|
||||
{"group:wood", "tnt:gunpowder", "group:wood"}
|
||||
}
|
||||
})
|
||||
if enable_tnt then
|
||||
minetest.register_craft({
|
||||
output = "tnt:tnt",
|
||||
recipe = {
|
||||
{"group:wood", "tnt:gunpowder", "group:wood"},
|
||||
{"tnt:gunpowder", "tnt:gunpowder", "tnt:gunpowder"},
|
||||
{"group:wood", "tnt:gunpowder", "group:wood"}
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_abm({
|
||||
label = "TNT ignition",
|
||||
nodenames = {"group:tnt", "tnt:gunpowder"},
|
||||
neighbors = {"fire:basic_flame", "default:lava_source", "default:lava_flowing"},
|
||||
interval = 4,
|
||||
chance = 1,
|
||||
action = function(pos, node)
|
||||
tnt.burn(pos, node.name)
|
||||
end,
|
||||
})
|
||||
minetest.register_abm({
|
||||
label = "TNT ignition",
|
||||
nodenames = {"group:tnt", "tnt:gunpowder"},
|
||||
neighbors = {"fire:basic_flame", "default:lava_source", "default:lava_flowing"},
|
||||
interval = 4,
|
||||
chance = 1,
|
||||
action = function(pos, node)
|
||||
tnt.burn(pos, node.name)
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
function tnt.register_tnt(def)
|
||||
local name
|
||||
@ -566,7 +582,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
|
||||
if enable_tnt then
|
||||
minetest.register_node(":" .. name, {
|
||||
description = def.description,
|
||||
tiles = {tnt_top, tnt_bottom, tnt_side},
|
||||
@ -609,7 +625,7 @@ function tnt.register_tnt(def)
|
||||
minetest.registered_nodes[name .. "_burning"].on_construct(pos)
|
||||
end,
|
||||
})
|
||||
--end
|
||||
end
|
||||
|
||||
minetest.register_node(":" .. name .. "_burning", {
|
||||
tiles = {
|
||||
@ -635,7 +651,7 @@ function tnt.register_tnt(def)
|
||||
on_blast = function() end,
|
||||
on_construct = function(pos)
|
||||
minetest.sound_play("tnt_ignite", {pos = pos})
|
||||
minetest.get_node_timer(pos):start(6)
|
||||
minetest.get_node_timer(pos):start(4)
|
||||
minetest.check_for_falling(pos)
|
||||
end,
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user