From acabb3c9575d97f6ffa7d557421327b87028e318 Mon Sep 17 00:00:00 2001 From: red-001 Date: Tue, 26 Jan 2016 23:36:07 +0000 Subject: [PATCH] Add `strength` to `register_blast_resistant` to support diffrent blast resistant blocks to have diffrent strengths --- init.lua | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/init.lua b/init.lua index 7bf17ae..1a6a4e2 100644 --- a/init.lua +++ b/init.lua @@ -23,8 +23,8 @@ local function sand_on_blast(pos) end end -local function blast_resistant(pos) - if math.random(1, damage_blast_resistant) == 1 then +local function blast_resistant(pos, strength) + if math.random(1, damage_blast_resistant * strength) == 1 then minetest.remove_node(pos) end end @@ -41,9 +41,11 @@ function tnt_extras.register_sand(name) }) end -function tnt_extras.register_blast_resistant(name) +function tnt_extras.register_blast_resistant(name, strength) minetest.override_item(name, { - on_blast = blast_resistant + on_blast = function(pos) + blast_resistant(pos, strength) + end }) end @@ -63,9 +65,9 @@ tnt_extras.register_sand("default:sand") tnt_extras.register_sand("default:desert_sand") -- Register blast resistant nodes -tnt_extras.register_blast_resistant("default:diamondblock") -tnt_extras.register_blast_resistant("default:obsidian") -tnt_extras.register_blast_resistant("default:obsidianbrick") -tnt_extras.register_blast_resistant("default:mese") -tnt_extras.register_blast_resistant("default:nyancat") -tnt_extras.register_blast_resistant("default:nyancat_rainbow") \ No newline at end of file +tnt_extras.register_blast_resistant("default:diamondblock" ,2) +tnt_extras.register_blast_resistant("default:obsidian" ,1) +tnt_extras.register_blast_resistant("default:obsidianbrick" ,.9) +tnt_extras.register_blast_resistant("default:mese" ,.6) +tnt_extras.register_blast_resistant("default:nyancat" ,.8) +tnt_extras.register_blast_resistant("default:nyancat_rainbow" ,.8) \ No newline at end of file