2019-01-05 23:11:38 -05:00
|
|
|
-- LUALOCALS < ---------------------------------------------------------
|
|
|
|
local ipairs, minetest, nodecore
|
|
|
|
= ipairs, minetest, nodecore
|
|
|
|
-- LUALOCALS > ---------------------------------------------------------
|
|
|
|
|
|
|
|
nodecore.register_leaf_drops, nodecore.registered_leaf_drops
|
|
|
|
= nodecore.mkreg()
|
|
|
|
|
2019-08-27 19:14:51 -04:00
|
|
|
function nodecore.leaf_decay(pos, node)
|
2019-01-05 23:11:38 -05:00
|
|
|
node = node or minetest.get_node(pos)
|
|
|
|
local t = {}
|
|
|
|
for i, v in ipairs(nodecore.registered_leaf_drops) do
|
|
|
|
t = v(pos, node, t) or t
|
|
|
|
end
|
|
|
|
local p = nodecore.pickrand(t, function(x) return x.prob end)
|
|
|
|
if not p then return end
|
|
|
|
minetest.set_node(pos, p)
|
2019-01-29 20:41:29 -05:00
|
|
|
if p.item then nodecore.item_eject(pos, p.item) end
|
2019-01-05 23:11:38 -05:00
|
|
|
return minetest.check_for_falling(pos)
|
|
|
|
end
|