Ignite air above lava sources

This commit is contained in:
Wuzzy 2017-05-20 03:24:36 +02:00
parent e2e2a99d6b
commit f7b75834f1
2 changed files with 64 additions and 4 deletions

View file

@ -1647,7 +1647,7 @@ minetest.register_node("mcl_core:lava_flowing", {
minetest.register_node("mcl_core:lava_source", { minetest.register_node("mcl_core:lava_source", {
description = "Still Lava", description = "Still Lava",
_doc_items_entry_name = "Lava", _doc_items_entry_name = "Lava",
_doc_items_longdesc = "Lava is found deep underground and rather dangerous. Don't touch it, it will hurt you a lot and once you're in, it is hard to get out. When a lava source meets water, it turns into obsidian. Flowing lava turns into stone instead.", _doc_items_longdesc = "Lava is found deep underground and rather dangerous. Don't touch it, it will hurt you a lot and once you're in, it is hard to get out. When a lava source meets water, it turns into obsidian. Flowing lava turns into stone instead. Lava source blocks set fire to air blocks above when they're next to a flammable block.",
inventory_image = minetest.inventorycube("default_lava.png"), inventory_image = minetest.inventorycube("default_lava.png"),
drawtype = "liquid", drawtype = "liquid",
tiles = { tiles = {

View file

@ -118,6 +118,37 @@ minetest.register_node("mcl_fire:eternal_fire", {
_mcl_blast_resistance = 0, _mcl_blast_resistance = 0,
}) })
-- Also make lava set fire to air blocks above
minetest.override_item("mcl_core:lava_source", {
on_timer = function(pos)
local function try_ignite(airs)
while #airs > 0 do
local r = math.random(1, #airs)
if minetest.find_node_near(airs[r], 1, {"group:flammable", "group:flammable_lava"}) then
minetest.set_node(airs[r], {name="mcl_fire:fire"})
return true
else
table.remove(airs, r)
end
end
return false
end
local airs1 = minetest.find_nodes_in_area({x=pos.x-1, y=pos.y+1, z=pos.z-1}, {x=pos.x+1, y=pos.y+1, z=pos.z+1}, {"air"})
minetest.log("error", dump(airs1))
local ok = try_ignite(airs1)
if not ok then
local airs2 = minetest.find_nodes_in_area({x=pos.x-2, y=pos.y+2, z=pos.z-2}, {x=pos.x+2, y=pos.y+2, z=pos.z+2}, {"air"})
try_ignite(airs2)
end
-- Restart timer
minetest.get_node_timer(pos):start(math.random(5, 10))
end,
on_construct = function(pos)
minetest.get_node_timer(pos):start(math.random(5, 10))
end
})
-- --
-- Sound -- Sound
-- --
@ -267,17 +298,46 @@ end
if not fire_enabled then if not fire_enabled then
-- Remove basic flames only if fire disabled -- Remove fire only if fire disabled
minetest.register_abm({ minetest.register_abm({
label = "Remove disabled fire", label = "Remove disabled fire",
nodenames = {"fire:basic_flame"}, nodenames = {"mcl_fire:fire"},
interval = 7, interval = 7,
chance = 1, chance = 1,
catch_up = false, catch_up = false,
action = minetest.remove_node, action = minetest.remove_node,
}) })
-- Set fire to air nodes (inverse pyramid pattern) above lava source
minetest.register_abm({
label = "Ignite fire by lava",
nodenames = {"mcl_core:lava_source"},
interval = 7,
chance = 2,
catch_up = false,
action = function(pos)
function try_ignite(airs)
while #airs > 0 do
local r = math.random(1, #airs)
if minetest.find_node_near(airs[r], 1, {"group:flammable", "group:flammable_lava"}) then
minetest.set_node(airs[r], {name="mcl_fire:fire"})
return true
else
table.remove(airs, r)
end
end
return false
end
local airs1 = minetest.find_nodes_in_area({x=pos.x-1, y=pos.y+1, z=pos.z-1}, {x=pos.x+1, y=pos.y+1, z=pos.z+1}, {"air"})
minetest.log("error", dump(airs1))
local ok = try_ignite(airs1)
if not ok then
local airs2 = minetest.find_nodes_in_area({x=pos.x-2, y=pos.y+2, z=pos.z-2}, {x=pos.x+2, y=pos.y+2, z=pos.z+2}, {"air"})
try_ignite(airs2)
end
end,
})
else -- Fire enabled else -- Fire enabled
-- Turn flammable nodes around fire into fire -- Turn flammable nodes around fire into fire