From 75ad945534885a13e9f5bf388d2632f9d9cf1800 Mon Sep 17 00:00:00 2001 From: Auke Kok Date: Sun, 21 Feb 2016 15:13:42 -0800 Subject: [PATCH] Change flame effect to a temporary flame. - reduce chance of actual fire by 10. - reduce chance of nodes getting modified - adds a "dying flame" node that does not ignite - lightning by default places the "dying flame" - "dying flame" node destroys itself within a short period --- init.lua | 50 +++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 47 insertions(+), 3 deletions(-) diff --git a/init.lua b/init.lua index 1c95471..5f170ba 100644 --- a/init.lua +++ b/init.lua @@ -117,16 +117,19 @@ lightning.strike = function() if rng:next(1,4) > 1 then return end - -- very rarely, cause a massive forest fire (100*4*250 = 1/100000 seconds) - if rng:next(1,100) == 1 then + -- very rarely, potentially cause a fire + if rng:next(1,1000) == 1 then minetest.set_node(pos2, {name = "fire:basic_flame"}) else - minetest.set_node(pos2, {name = "fire:permanent_flame"}) + minetest.set_node(pos2, {name = "lightning:dying_flame"}) end end end -- perform block modifications + if rng:next(1,10) > 1 then + return + end pos2.y = pos2.y - 1 local n = minetest.get_node(pos2) if minetest.get_item_group(n.name, "tree") > 0 then @@ -138,4 +141,45 @@ lightning.strike = function() end end +-- a special fire node that doesn't burn anything, and automatically disappears +minetest.register_node("lightning:dying_flame", { + description = "Dying Flame", + drawtype = "firelike", + tiles = { + { + name = "fire_basic_flame_animated.png", + animation = { + type = "vertical_frames", + aspect_w = 16, + aspect_h = 16, + length = 1 + }, + }, + }, + inventory_image = "fire_basic_flame.png", + paramtype = "light", + light_source = 14, + walkable = false, + buildable_to = true, + sunlight_propagates = true, + damage_per_second = 4, + groups = {dig_immediate = 3}, + drop = "", + + on_construct = function(pos) + minetest.after(0, fire.on_flame_add_at, pos) + minetest.after(rng:next(20, 40), minetest.remove_node, pos) + end, + + on_destruct = function(pos) + minetest.after(0, fire.on_flame_remove_at, pos) + minetest.after(rng:next(20, 40), minetest.remove_node, pos) + end, + + on_blast = function() + end, -- unaffected by explosions +}) + + + minetest.after(rng:next(lightning.interval_low, lightning.interval_high), lightning.strike)