Fire: Ignite tnt, gunpowder, permanent flame above coalblock

Enable ignition of tnt, gunpowder and permanent
flame above coalblock using flint and steel
Override coalblock to remove flame above when dug
Add depends.txt for default mod
This commit is contained in:
paramat 2016-05-05 00:55:56 +01:00
parent ba33639887
commit 6386684f3e
2 changed files with 51 additions and 11 deletions

1
mods/fire/depends.txt Normal file
View File

@ -0,0 +1 @@
default

View File

@ -80,26 +80,51 @@ minetest.register_node("fire:permanent_flame", {
end, end,
}) })
-- Flint and steel
minetest.register_tool("fire:flint_and_steel", { minetest.register_tool("fire:flint_and_steel", {
description = "Flint and Steel", description = "Flint and Steel",
inventory_image = "fire_flint_steel.png", inventory_image = "fire_flint_steel.png",
on_use = function(itemstack, user, pointed_thing) on_use = function(itemstack, user, pointed_thing)
local player_name = user:get_player_name()
local pt = pointed_thing
if pt.type == "node" and minetest.get_node(pt.above).name == "air" then
itemstack:add_wear(1000) itemstack:add_wear(1000)
local pt = pointed_thing
if pt.type == "node" then
local node_under = minetest.get_node(pt.under).name local node_under = minetest.get_node(pt.under).name
local is_coalblock = node_under == "default:coalblock"
if minetest.get_item_group(node_under, "flammable") >= 1 then local is_tnt = node_under == "tnt:tnt"
if not minetest.is_protected(pt.above, player_name) then local is_gunpowder = node_under == "tnt:gunpowder"
minetest.set_node(pt.above, {name = "fire:basic_flame"}) if minetest.get_item_group(node_under, "flammable") >= 1 or
is_coalblock or is_tnt or is_gunpowder then
local flame_pos = pt.above
if is_coalblock then
flame_pos = {x = pt.under.x, y = pt.under.y + 1, z = pt.under.z}
elseif is_tnt or is_gunpowder then
flame_pos = pt.under
end
if minetest.get_node(flame_pos).name == "air" or
is_tnt or is_gunpowder then
local player_name = user:get_player_name()
if not minetest.is_protected(flame_pos, player_name) then
if is_coalblock then
minetest.set_node(flame_pos,
{name = "fire:permanent_flame"})
elseif is_tnt then
minetest.set_node(flame_pos,
{name = "tnt:tnt_burning"})
elseif is_gunpowder then
minetest.set_node(flame_pos,
{name = "tnt:gunpowder_burning"})
else
minetest.set_node(flame_pos,
{name = "fire:basic_flame"})
end
else else
minetest.chat_send_player(player_name, "This area is protected") minetest.chat_send_player(player_name, "This area is protected")
end end
end end
end end
end
if not minetest.setting_getbool("creative_mode") then if not minetest.setting_getbool("creative_mode") then
return itemstack return itemstack
end end
@ -113,6 +138,20 @@ minetest.register_craft({
} }
}) })
-- Override coalblock to enable permanent flame above
-- Coalblock is non-flammable to avoid unwanted basic_flame nodes
minetest.override_item("default:coalblock", {
after_destruct = function(pos, oldnode)
pos.y = pos.y + 1
if minetest.get_node(pos).name == "fire:permanent_flame" then
minetest.remove_node(pos)
end
end,
})
-- Get sound area of position -- Get sound area of position
fire.D = 6 -- size of sound areas fire.D = 6 -- size of sound areas