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