From ead9f0fac5a177a88e0751d44181c6e906b81344 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20P=C3=A9rez-Cerezo?= Date: Sat, 22 Oct 2016 13:14:14 +0200 Subject: Added Readme and License file, minimum depth can now be configured, gunpowder cannot be lighted above that minimum depth so players are not annoyed. --- init.lua | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'init.lua') diff --git a/init.lua b/init.lua index 66c22d7..fe5d749 100644 --- a/init.lua +++ b/init.lua @@ -3,6 +3,8 @@ tnt = {} local singleplayer = minetest.is_singleplayer() local setting = minetest.setting_getbool("enable_tnt") setting = true -- this mod is multiplayer-safe, so enable it. +local tntmindepth = tonumber(minetest.setting_get("tnt_mindepth")) or -100 + if (not singleplayer and setting ~= true) or (singleplayer and setting == false) then return @@ -364,8 +366,8 @@ local function tnt_explode(pos, radius, ignore_protection, ignore_on_blast) end function tnt.boom(pos, def) - if pos.y > -100 then --- minetest.chat_send_all("TNT can only explode when deeper than -100") + if pos.y > tntmindepth then +-- check if we're deep enough minetest.set_node(pos, {name = "tnt:tnt"}) return end @@ -417,9 +419,10 @@ minetest.register_node("tnt:gunpowder", { sounds = default.node_sound_leaves_defaults(), on_punch = function(pos, node, puncher) - if puncher:get_wielded_item():get_name() == "default:torch" then - tnt.burn(pos) - end + if puncher:get_wielded_item():get_name() == "default:torch" and pos.y < (tntmindepth + 16)then + -- check if we're deep enough, don't annoy people with the air-raid sound. + tnt.burn(pos) + end end, on_blast = function(pos, intensity) tnt.burn(pos) -- cgit v1.2.3