mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-11-14 15:11:05 +01:00
Fix TNT ignition
This commit is contained in:
parent
674a989061
commit
cc119a717c
3 changed files with 22 additions and 22 deletions
|
@ -195,10 +195,10 @@ function get_nodedef_field(nodename, fieldname)
|
||||||
end
|
end
|
||||||
|
|
||||||
function set_fire(pointed_thing)
|
function set_fire(pointed_thing)
|
||||||
local n = minetest.get_node(pointed_thing.above)
|
local n = minetest.get_node(pointed_thing.above)
|
||||||
if n.name ~= "" and n.name == "air" and not minetest.is_protected(pointed_thing.above, "fire") then
|
if n.name ~= "" and n.name == "air" and not minetest.is_protected(pointed_thing.above, "fire") then
|
||||||
minetest.add_node(pointed_thing.above, {name="fire:basic_flame"})
|
minetest.add_node(pointed_thing.above, {name="fire:basic_flame"})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--
|
--
|
||||||
|
|
|
@ -289,9 +289,13 @@ minetest.register_tool("default:flint_and_steel", {
|
||||||
},
|
},
|
||||||
on_use = function(itemstack, user, pointed_thing)
|
on_use = function(itemstack, user, pointed_thing)
|
||||||
if pointed_thing.type == "node" then
|
if pointed_thing.type == "node" then
|
||||||
|
if minetest.get_node(pointed_thing.under).name == "tnt:tnt" then
|
||||||
|
tnt.ignite(pointed_thing.under)
|
||||||
|
else
|
||||||
set_fire(pointed_thing)
|
set_fire(pointed_thing)
|
||||||
itemstack:add_wear(66000/65) -- 65 uses
|
itemstack:add_wear(66000/65) -- 65 uses
|
||||||
return itemstack
|
return itemstack
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
function spawn_tnt(pos, entname)
|
local function spawn_tnt(pos, entname)
|
||||||
minetest.sound_play("tnt_ignite", {pos = pos,gain = 1.0,max_hear_distance = 15,})
|
minetest.sound_play("tnt_ignite", {pos = pos,gain = 1.0,max_hear_distance = 15,})
|
||||||
return minetest.add_entity(pos, entname)
|
return minetest.add_entity(pos, entname)
|
||||||
end
|
end
|
||||||
|
|
||||||
function activate_if_tnt(nname, np, tnt_np, tntr)
|
local function activate_if_tnt(nname, np, tnt_np, tntr)
|
||||||
if nname == "tnt:tnt" then
|
if nname == "tnt:tnt" then
|
||||||
local e = spawn_tnt(np, nname)
|
local e = spawn_tnt(np, nname)
|
||||||
e:setvelocity({x=(np.x - tnt_np.x)*5+(tntr / 4), y=(np.y - tnt_np.y)*5+(tntr / 3), z=(np.z - tnt_np.z)*5+(tntr / 4)})
|
e:setvelocity({x=(np.x - tnt_np.x)*5+(tntr / 4), y=(np.y - tnt_np.y)*5+(tntr / 3), z=(np.z - tnt_np.z)*5+(tntr / 4)})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function do_tnt_physics(tnt_np,tntr)
|
local function do_tnt_physics(tnt_np,tntr)
|
||||||
local objs = minetest.get_objects_inside_radius(tnt_np, tntr)
|
local objs = minetest.get_objects_inside_radius(tnt_np, tntr)
|
||||||
for k, obj in pairs(objs) do
|
for k, obj in pairs(objs) do
|
||||||
local oname = obj:get_entity_name()
|
local oname = obj:get_entity_name()
|
||||||
|
@ -30,6 +30,14 @@ function do_tnt_physics(tnt_np,tntr)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
tnt = {}
|
||||||
|
tnt.ignite = function(pos)
|
||||||
|
minetest.remove_node(pos)
|
||||||
|
spawn_tnt(pos, "tnt:tnt")
|
||||||
|
nodeupdate(pos)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
minetest.register_node("tnt:tnt", {
|
minetest.register_node("tnt:tnt", {
|
||||||
tiles = {"default_tnt_top.png", "default_tnt_bottom.png",
|
tiles = {"default_tnt_top.png", "default_tnt_bottom.png",
|
||||||
"default_tnt_side.png", "default_tnt_side.png",
|
"default_tnt_side.png", "default_tnt_side.png",
|
||||||
|
@ -39,23 +47,11 @@ minetest.register_node("tnt:tnt", {
|
||||||
stack_max = 64,
|
stack_max = 64,
|
||||||
description = "TNT",
|
description = "TNT",
|
||||||
mesecons = {effector = {
|
mesecons = {effector = {
|
||||||
action_on = (function(p, node)
|
action_on = tnt.ignite
|
||||||
minetest.remove_node(p)
|
|
||||||
spawn_tnt(p, "tnt:tnt")
|
|
||||||
nodeupdate(p)
|
|
||||||
end),
|
|
||||||
}},
|
}},
|
||||||
sounds = default.node_sound_wood_defaults(),
|
sounds = default.node_sound_wood_defaults(),
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_on_punchnode(function(p, node)
|
|
||||||
if node.name == "tnt:tnt" then
|
|
||||||
minetest.remove_node(p)
|
|
||||||
spawn_tnt(p, "tnt:tnt")
|
|
||||||
nodeupdate(p)
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
local TNT_RANGE = 3
|
local TNT_RANGE = 3
|
||||||
local TNT = {
|
local TNT = {
|
||||||
-- Static definition
|
-- Static definition
|
||||||
|
|
Loading…
Reference in a new issue