2019-01-06 13:04:07 -05:00
|
|
|
-- LUALOCALS < ---------------------------------------------------------
|
2019-03-31 20:54:38 -04:00
|
|
|
local ipairs, minetest, nodecore, pairs, vector
|
|
|
|
= ipairs, minetest, nodecore, pairs, vector
|
2019-01-06 13:04:07 -05:00
|
|
|
-- LUALOCALS > ---------------------------------------------------------
|
|
|
|
|
|
|
|
local modname = minetest.get_current_modname()
|
|
|
|
|
2019-03-31 20:54:38 -04:00
|
|
|
do
|
|
|
|
local flamedirs = nodecore.dirs()
|
|
|
|
local embers = {}
|
|
|
|
minetest.after(0, function()
|
|
|
|
for k, v in pairs(minetest.registered_items) do
|
|
|
|
if v.groups.ember then
|
|
|
|
embers[k] = true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end)
|
|
|
|
nodecore.register_limited_abm({
|
|
|
|
label = "Fire Requires/Consumes Embers",
|
|
|
|
interval = 1,
|
|
|
|
chance = 1,
|
|
|
|
nodenames = {modname .. ":fire"},
|
|
|
|
action = function(pos)
|
|
|
|
local found = {}
|
|
|
|
for _, dp in ipairs(flamedirs) do
|
|
|
|
local npos = vector.add(pos, dp)
|
|
|
|
local node = minetest.get_node_or_nil(npos)
|
|
|
|
if (not node) or embers[node.name] then
|
|
|
|
found[#found + 1] = npos
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if #found < 1 then
|
|
|
|
return minetest.remove_node(pos)
|
|
|
|
end
|
|
|
|
local picked = nodecore.pickrand(found)
|
|
|
|
return nodecore.fire_check_expend(picked)
|
|
|
|
end
|
|
|
|
})
|
2019-01-23 23:06:06 -05:00
|
|
|
end
|
|
|
|
|
2019-01-06 13:04:07 -05:00
|
|
|
nodecore.register_limited_abm({
|
|
|
|
label = "Flammables Ignite",
|
|
|
|
interval = 5,
|
|
|
|
chance = 1,
|
|
|
|
nodenames = {"group:flammable"},
|
|
|
|
neighbors = {"group:igniter"},
|
2019-04-03 07:40:19 -04:00
|
|
|
action = function(pos, node)
|
|
|
|
return nodecore.fire_check_ignite(pos, node)
|
|
|
|
end
|
2019-01-06 13:04:07 -05:00
|
|
|
})
|
|
|
|
|
|
|
|
nodecore.register_limited_abm({
|
|
|
|
label = "Fuel Burning/Snuffing",
|
|
|
|
interval = 1,
|
|
|
|
chance = 1,
|
2019-01-17 00:01:00 -05:00
|
|
|
nodenames = {"group:ember"},
|
|
|
|
action = function(pos, node)
|
2019-03-31 20:54:38 -04:00
|
|
|
local snuff, vents = nodecore.fire_check_snuff(pos, node)
|
|
|
|
if snuff or not vents then return end
|
|
|
|
for i = 1, #vents do
|
|
|
|
if vents[i].q < 1 then
|
|
|
|
minetest.set_node(vents[i], {name = modname .. ":fire"})
|
|
|
|
end
|
2019-01-06 13:04:07 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
})
|
2019-03-14 22:20:18 -04:00
|
|
|
|
|
|
|
nodecore.register_ambiance({
|
|
|
|
label = "Flame Ambiance",
|
|
|
|
nodenames = {modname .. ":fire"},
|
|
|
|
interval = 1,
|
|
|
|
chance = 1,
|
|
|
|
sound_name = "nc_fire_flamy",
|
|
|
|
sound_gain = 0.3
|
|
|
|
})
|