Leafdecay: Node timer based implementation, API
authorMarkuBu <markus.burrer@gmail.com>
Wed, 8 Feb 2017 00:28:02 +0000 (16:28 -0800)
committerparamat <mat.gregory@virginmedia.com>
Sat, 25 Feb 2017 03:50:15 +0000 (03:50 +0000)
commit60e5b299af564f250af8304b5146f79693c314ff
tree347c92810f12ed46fd49fba623e163f8203f8dc5
parent37dd91074700f1ae662fea784bf98c9a81e0ac1b
Leafdecay: Node timer based implementation, API

This implements a node-timer based leafdecay mechanism, and exposes
an API to use it in mods.

The API is documented in game_api.txt.

`default.register_leafdecay(leafdecaydef)`

`leafdecaydef` is a table, with following members:
{
trunks = { "default:tree"}, -- nodes considered trunks
leaves = { "default:leaves", "default:apple"}, -- nodes considered leaves
radius = 3, -- activates leafdecay this far from the trunk
}

The algorithm will drop `leaves` items in the area if no `trunks` are found
in the `trunk_radius` sized area around the position of the leaf. If a node
listed in `leaves` has a group `leafdecay_drop > 0`, then the item is dropped,
otherwise the item is removed but not dropped.

The algorithm also implements a value `default.leafdecay_speed` (default
15) which can be modified to increase or decrease of the leaf decay. The
algorithm will vary the actual speed a bit to introduce randomness.

Leaf decay is randomized by 0.1 seconds to reduce the chance that
decay happens many times on the same second interval. This requires
nodetimer_interval to be set to values lower than 1.0 to have an
effect.

The leaves will decay between 2 and 10 seconds after digging the trunk,
and happen at non-integer second intervals.

-- The API was added by sofar.
game_api.txt
mods/default/functions.lua
mods/default/nodes.lua