nodecore-cd2025/mods/nc_fire/firestarting.lua
Aaron Suen fbff15e2fe MAJOR fire api/logic rework.
- Expanded fire api, added "check" varieties of things that also
  perform relevant checks for eligibility.  Standardized testing
  for ventilation.
- Snuff embers to coals as fuel.
- Fuel is consumed randomly by flames.  This means that fuel that
  are surrounded by flame burn out quicker, while flames
  surrounded by fuel consume fuel from each node slower.  This
  adds subtlety to furnace design for efficiency.
2019-03-31 20:54:38 -04:00

40 lines
1.1 KiB
Lua

-- LUALOCALS < ---------------------------------------------------------
local ItemStack, math, minetest, nodecore
= ItemStack, math, minetest, nodecore
local math_random
= math.random
-- LUALOCALS > ---------------------------------------------------------
nodecore.register_craft({
label = "stick fire starting",
action = "pummel",
wield = {
groups = {firestick = true}
},
nodes = {
{match = {groups = {firestick = true}}}
},
consumewield = 1,
duration = 5,
before = function(pos, rel, data)
local w = data.wield and ItemStack(data.wield):get_name() or ""
local wd = minetest.registered_items[w] or {}
local wg = wd.groups or {}
local fs = wg.firestick or 1
local nd = minetest.registered_items[data.node.name] or {}
local ng = nd.groups or {}
fs = fs * (ng.firestick or 1)
if math_random(1, 4) > fs then return end
minetest.set_node(pos, {name = "nc_fire:fire"})
if math_random(1, 4) > fs then return end
local dir = nodecore.pickrand(nodecore.dirs())
return nodecore.fire_check_ignite({
x = pos.x + dir.x,
y = pos.y + dir.y,
z = pos.z + dir.z
})
end
})