Skip to content

Commit

Permalink
Fire: Ignite tnt, gunpowder, permanent flame above coalblock
Browse files Browse the repository at this point in the history
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
  • Loading branch information
paramat committed Jun 4, 2016
1 parent ba33639 commit 6386684
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 11 deletions.
1 change: 1 addition & 0 deletions mods/fire/depends.txt
@@ -0,0 +1 @@
default
61 changes: 50 additions & 11 deletions mods/fire/init.lua
Expand Up @@ -80,26 +80,51 @@ minetest.register_node("fire:permanent_flame", {
end,
})


-- Flint and steel

minetest.register_tool("fire:flint_and_steel", {
description = "Flint and Steel",
inventory_image = "fire_flint_steel.png",
on_use = function(itemstack, user, pointed_thing)
local player_name = user:get_player_name()
itemstack:add_wear(1000)
local pt = pointed_thing

if pt.type == "node" and minetest.get_node(pt.above).name == "air" then
itemstack:add_wear(1000)
if pt.type == "node" then
local node_under = minetest.get_node(pt.under).name

if minetest.get_item_group(node_under, "flammable") >= 1 then
if not minetest.is_protected(pt.above, player_name) then
minetest.set_node(pt.above, {name = "fire:basic_flame"})
else
minetest.chat_send_player(player_name, "This area is protected")
local is_coalblock = node_under == "default:coalblock"
local is_tnt = node_under == "tnt:tnt"
local is_gunpowder = node_under == "tnt:gunpowder"
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
minetest.chat_send_player(player_name, "This area is protected")
end
end
end
end

if not minetest.setting_getbool("creative_mode") then
return itemstack
end
Expand All @@ -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

fire.D = 6 -- size of sound areas
Expand Down

0 comments on commit 6386684

Please sign in to comment.