From 6386684f3efd07443cc4ae25b0b3da22cfabaa33 Mon Sep 17 00:00:00 2001 From: paramat Date: Thu, 5 May 2016 00:55:56 +0100 Subject: [PATCH] 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 --- mods/fire/depends.txt | 1 + mods/fire/init.lua | 61 +++++++++++++++++++++++++++++++++++-------- 2 files changed, 51 insertions(+), 11 deletions(-) create mode 100644 mods/fire/depends.txt diff --git a/mods/fire/depends.txt b/mods/fire/depends.txt new file mode 100644 index 00000000..4ad96d51 --- /dev/null +++ b/mods/fire/depends.txt @@ -0,0 +1 @@ +default diff --git a/mods/fire/init.lua b/mods/fire/init.lua index 832b7014..08b53a89 100644 --- a/mods/fire/init.lua +++ b/mods/fire/init.lua @@ -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 @@ -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 -- 2.25.1