Aaron Suen 464a0e1d89 Finite fire rework.
- There are now 6 degrees of embers.  Better fuel sources will
  make better embers.
- Embers differ only in lifespan; each class lasts twice as long
  as the previous.  Top-grade fuels may last 15 minutes or
  longer.
- Embers decay stochastically.
- Embers decay 16x as fast when smothered, but still go through
  the same lifecycle.

Also:
- Plain ash now reposes.

There are no infinite fuel sources, nor are any specifically
planned at this time.
2019-01-17 00:01:00 -05:00

28 lines
960 B
Lua

-- LUALOCALS < ---------------------------------------------------------
local math, minetest, nodecore
= math, minetest, nodecore
local math_floor
= math.floor
-- LUALOCALS > ---------------------------------------------------------
local modname = minetest.get_current_modname()
function nodecore.ignite(pos, node)
local fuel = nodecore.node_group("fire_fuel", pos, node) or 0
if fuel < 0 then fuel = 0 end
if fuel > 6 then fuel = 6 end
fuel = math_floor(fuel)
minetest.set_node(pos, {name = modname .. ((fuel > 0)
and (":ember" .. fuel) or ":fire")})
minetest.after(0, function() minetest.check_for_falling(pos) end)
end
function nodecore.snuff(pos, node, groups)
local ember = nodecore.node_group("ember", pos, node)
if not ember then return end
ember = ember - 1
minetest.set_node(pos, {name = modname .. ((ember > 0)
and (":ember" .. ember) or ":ash")})
minetest.after(0, function() minetest.check_for_falling(pos) end)
end