From b03ee0df64087c29ac115e8706a0cf606ea86112 Mon Sep 17 00:00:00 2001 From: LeMagnesium Date: Tue, 22 Sep 2015 20:14:14 +0200 Subject: [PATCH] Revert update of fire --- minetestforfun_game/mods/default/nodes.lua | 2 +- minetestforfun_game/mods/fire/init.lua | 157 ++++++++++----------- 2 files changed, 74 insertions(+), 85 deletions(-) diff --git a/minetestforfun_game/mods/default/nodes.lua b/minetestforfun_game/mods/default/nodes.lua index bad528ce..e09f8d9c 100755 --- a/minetestforfun_game/mods/default/nodes.lua +++ b/minetestforfun_game/mods/default/nodes.lua @@ -906,7 +906,7 @@ minetest.register_node("default:cherry_sapling", { type = "fixed", fixed = {-0.3, -0.5, -0.3, 0.3, 0.35, 0.3} }, - groups = {snappy=2,dig_immediate=3,flammable=2,attached_node=1}, + groups = {snappy=2,dig_immediate=3,flammable=2,attached_node=1,sapling=1}, sounds = default.node_sound_leaves_defaults(), }) diff --git a/minetestforfun_game/mods/fire/init.lua b/minetestforfun_game/mods/fire/init.lua index 7eef94f7..40fa6a6d 100755 --- a/minetestforfun_game/mods/fire/init.lua +++ b/minetestforfun_game/mods/fire/init.lua @@ -37,9 +37,16 @@ minetest.register_node("fire:basic_flame", { }) +-- Fire sounds table +-- key: position hash of low corner of area +-- value: {handle=sound handle, name=sound name} +fire.sounds = {} + + -- Get sound area of position -fire.D = 6 -- size of sound areas +-- size of sound areas +fire.D = 6 function fire.get_area_p0p1(pos) local p0 = { @@ -56,12 +63,6 @@ function fire.get_area_p0p1(pos) end --- Fire sounds table --- key: position hash of low corner of area --- value: {handle=sound handle, name=sound name} -fire.sounds = {} - - -- Update fire sounds in sound area of position function fire.update_sounds_around(pos) @@ -125,90 +126,39 @@ end -- Detect nearby extinguishing nodes function fire.flame_should_extinguish(pos) - return minetest.find_node_near(pos, 1, {"group:puts_out_fire"}) + if minetest.setting_getbool("disable_fire") then return true end + --return minetest.find_node_near(pos, 1, {"group:puts_out_fire"}) + local p0 = {x = pos.x - 1, y = pos.y, z = pos.z - 1} + local p1 = {x = pos.x + 1, y = pos.y + 1, z = pos.z + 1} + local ps = minetest.find_nodes_in_area(p0, p1, {"group:puts_out_fire"}) + return (#ps ~= 0) end --- Enable ABMs according to 'disable fire' setting +-- Ignite neighboring nodes -if minetest.setting_getbool("disable_fire") then - - -- Extinguish flames quickly with dedicated ABM - - minetest.register_abm({ - nodenames = {"fire:basic_flame"}, - interval = 3, - chance = 2, - action = function(p0, node, _, _) - minetest.remove_node(p0) - end, - }) - -else - - -- Extinguish flames quickly with water, snow, ice - - minetest.register_abm({ - nodenames = {"fire:basic_flame"}, - neighbors = {"group:puts_out_fire"}, - interval = 3, - chance = 2, - action = function(p0, node, _, _) - minetest.remove_node(p0) - minetest.sound_play("fire_extinguish_flame", - {pos = p0, max_hear_distance = 16, gain = 0.25}) - end, - }) - - -- Ignite neighboring nodes - - minetest.register_abm({ - nodenames = {"group:flammable"}, - neighbors = {"group:igniter"}, - interval = 7, - chance = 16, - action = function(p0, node, _, _) - -- If there is water or stuff like that around node, don't ignite - if fire.flame_should_extinguish(p0) then - return - end - local p = fire.find_pos_for_flame_around(p0) - if p then - minetest.set_node(p, {name = "fire:basic_flame"}) - end - end, - }) - - -- Remove flames and flammable nodes - - minetest.register_abm({ - nodenames = {"fire:basic_flame"}, - interval = 5, - chance = 16, - action = function(p0, node, _, _) - -- If there are no flammable nodes around flame, remove flame - if not minetest.find_node_near(p0, 1, {"group:flammable"}) then - minetest.remove_node(p0) - return - end - if math.random(1, 4) == 1 then - -- remove flammable nodes around flame - local p = minetest.find_node_near(p0, 1, {"group:flammable"}) - if p then - minetest.remove_node(p) - nodeupdate(p) - end - end - end, - }) - -end +--[[minetest.register_abm({ + nodenames = {"group:flammable"}, + neighbors = {"group:igniter"}, + interval = 7, + chance = 32, + action = function(p0, node, _, _) + -- If there is water or stuff like that around flame, don't ignite + if fire.flame_should_extinguish(p0) then + return + end + local p = fire.find_pos_for_flame_around(p0) + if p then + minetest.set_node(p, {name = "fire:basic_flame"}) + end + end, +}) -- Rarely ignite things from far ---[[ Currently disabled to reduce the chance of uncontrollable spreading - fires that disrupt servers. Also for less lua processing load. +-- Currently disabled to reduce the chance of uncontrollable spreading +-- fires that disrupt servers. Also for less lua processing load. minetest.register_abm({ nodenames = {"group:igniter"}, @@ -233,5 +183,44 @@ minetest.register_abm({ end end end, +})]] + +-- Remove flammable nodes and flame + +minetest.register_abm({ + nodenames = {"fire:basic_flame"}, + interval = 5, + chance = 16, + action = function(p0, node, _, _) + -- If there is water or stuff like that around flame, remove flame + if fire.flame_should_extinguish(p0) then + minetest.remove_node(p0) + return + end + -- Make the following things rarer + if math.random(1, 3) == 1 then + return + end + -- If there are no flammable nodes around flame, remove flame + if not minetest.find_node_near(p0, 1, {"group:flammable"}) then + minetest.remove_node(p0) + return + end + if math.random(1, 4) == 1 then + -- remove a flammable node around flame + local p = minetest.find_node_near(p0, 1, {"group:flammable"}) + if p then + -- If there is water or stuff like that around flame, don't remove + if fire.flame_should_extinguish(p0) then + return + end + minetest.remove_node(p) + nodeupdate(p) + end + else + -- remove flame + minetest.remove_node(p0) + end + end, }) ---]] +