Skip to content

Commit

Permalink
Fix various fire sound bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
PilzAdam committed Dec 3, 2014
1 parent 128f0ad commit 5b7db48
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions mods/fire/init.lua
@@ -1,5 +1,7 @@
-- minetest/fire/init.lua

fire = {}

minetest.register_node("fire:basic_flame", {
description = "Fire",
drawtype = "firelike",
Expand All @@ -14,17 +16,16 @@ minetest.register_node("fire:basic_flame", {
walkable = false,
buildable_to = true,
damage_per_second = 4,
after_place_node = function(pos, placer)
fire.on_flame_add_at(pos)

on_construct = function(pos)
minetest.after(0, fire.on_flame_add_at, pos)
end,
after_dig_node = function(pos, oldnode, oldmetadata, digger)
fire.on_flame_remove_at(pos)

on_destruct = function(pos)
minetest.after(0, fire.on_flame_remove_at, pos)
end,
})

fire = {}
fire.D = 6
-- key: position hash of low corner of area
-- value: {handle=sound handle, name=sound name}
Expand Down Expand Up @@ -81,12 +82,10 @@ function fire.update_sounds_around(pos)
end

function fire.on_flame_add_at(pos)
--print("flame added at "..minetest.pos_to_string(pos))
fire.update_sounds_around(pos)
end

function fire.on_flame_remove_at(pos)
--print("flame removed at "..minetest.pos_to_string(pos))
fire.update_sounds_around(pos)
end

Expand Down Expand Up @@ -117,7 +116,6 @@ minetest.register_abm({
local p = fire.find_pos_for_flame_around(p0)
if p then
minetest.set_node(p, {name="fire:basic_flame"})
fire.on_flame_add_at(p)
end
end,
})
Expand All @@ -143,7 +141,6 @@ minetest.register_abm({
local p2 = fire.find_pos_for_flame_around(p)
if p2 then
minetest.set_node(p2, {name="fire:basic_flame"})
fire.on_flame_add_at(p2)
end
end
end,
Expand All @@ -158,7 +155,6 @@ minetest.register_abm({
-- If there is water or stuff like that around flame, remove flame
if fire.flame_should_extinguish(p0) then
minetest.remove_node(p0)
fire.on_flame_remove_at(p0)
return
end
-- Make the following things rarer
Expand All @@ -168,7 +164,6 @@ minetest.register_abm({
-- 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)
fire.on_flame_remove_at(p0)
return
end
if math.random(1,4) == 1 then
Expand All @@ -185,7 +180,6 @@ minetest.register_abm({
else
-- remove flame
minetest.remove_node(p0)
fire.on_flame_remove_at(p0)
end
end,
})
Expand Down

0 comments on commit 5b7db48

Please sign in to comment.