Trees

Felling the level's trees, meaning meshes under objects/natural/vegetation/trees/ or added with setSpecies. A blow counts when the player holds an axe, stands within reach and has not landed one in the last swing time. After `hits` blows, the tree falls away from the chopper in the same way on all screens. The standing tree and its collision are hidden for the dimension, and its mesh falls as a prop, turned about its foot by the server along a gravity curve. Blows on the trunk then cut it into `drops`, into the chopper's inventory or onto the ground. It grows back after `regrowMinutes`, once no player is within `regrowClearance` metres. All of this is per dimension and in memory, so a restart restores all trees, unless a script keeps state() and passes it to restore(). Server events are playerTreeChop, playerTreeFell, playerTrunkChop and playerTrunkCut, which can refuse, treeFelled, treeRegrow, which can refuse, and treeRegrown. Client scripts of players in the dimension hear treeChop, treeFalling, treeFelled, trunkCut and treeRegrown.

trees.configure()

Trees.configure(settings)

Changes settings for all trees, leaving out others unchanged, and returns them all. They are `enabled`, default true; `hits`, default 8; `trunkHits`, default 6; `regrowMinutes`, real minutes, default 30; `regrowClearance`, default 10 m; `reach`, from the chopper's feet, default 3.5 m; `swingSeconds`, the shortest time between one player's blows, default 0.4; `height`, trunk length at scale 1, default 15 m; `trunkRadius`, default 0.35 m; `drops`, [{ item, amount }], default 2 bsmt_woodExotic; `dropTo`, 'inventory' or 'ground'; `stump`, a prop model left in place, or null; and `axes`, the item classes that chop, or null for all melee weapons named like an axe. Throws for an unknown setting or wrong value.

trees.settings

settings

A copy of the settings all trees use now.

trees.setSpecies()

Trees.setSpecies(prefix, settings)

Settings for trees whose mesh path starts with `prefix`, in any case and with either slash, on top of configure's: `hits`, `trunkHits`, `regrowMinutes`, `height`, `trunkRadius`, `drops` and `stump`. A prefix outside objects/natural/vegetation/trees/ also makes those meshes trees, such as a resource's own. The last prefix set wins.

trees.isTree()

Trees.isTree(mesh)

Whether a mesh path is a tree that can be felled.

trees.get()

Trees.get(id, dimension)

A tree being chopped, felled or cut, by its id, `<mesh>@<x>,<y>,<z>`. Null for a tree nobody has touched, which stands as the level has it.

trees.of()

Trees.of(levelObject, dimension)

The tree a level object is, for scripts that fell trees themselves. It gives a standing tree, the same object get later returns while touched, or null if the object is not a tree.

trees.at()

Trees.at(position, radius, dimension)

Touched trees, whether chopped, falling, felled or cut, within a radius.

trees.felled()

Trees.felled(dimension)

Trees now down, whether falling, felled or cut.

trees.state()

Trees.state(dimension)

All touched trees as plain JSON data to keep across a restart: id, dimension, species, at, rotation, scale, state ('standing', 'felled' or 'cut', with a falling tree as felled), hits, trunkHits, felledAt and regrowAt in epoch milliseconds, and pose, how its trunk lies.

trees.restore()

Trees.restore(list)

Restores kept trees after a restart. A felled tree lies at once where it lay, with no fall or events, a cut one stays hidden, a chopped one keeps its blows, and regrowth times continue. Entries that are not trees, or trees already touched, are skipped. Returns how many came back, and throws a TypeError for anything except a list.

trees.regrowAll()

Trees.regrowAll(dimension)

Brings back all touched trees at once, with felled ones standing and chopped ones healed, and returns how many were down.