2 The L-System Tree Utility provides a set of simple functions to mess around with the tree database, generate trees from saplings and more.
6 The table `ltool.VERSION` exports version information. This mod uses [Semantic Versioning](http://semver.org/).
7 This information comes in handy if you need to do some compability work.
9 * `ltool.VERSION.STRING`: Full version as string
10 * `ltool.VERSION.MAJOR`: Major (=first) version number, as number
11 * `ltool.VERSION.MINOR`: Minor (=second) version number, as number
12 * `ltool.VERSION.PATCH`: Patch (=third) version number, as number
16 This is identical to the `treedef` parameter of `minetest.spawn_tree`.
19 A `tree` is the basic data structure. It is basically a wrapper around `treedef`, with some additional fields relevant for the L-System-Tree-Utility, which are listed here:
22 A tree ID, an identifier of a `tree`. This is an unique number. Many functions require a tree ID.
24 No identifier is used twice, once an identifier is taken, it won’t be occupied again, even if the `tree` occupying the slot has been deleted.
27 An unique name of the tree, assigned by the user.
30 The name of the player who created the `tree`. The author is also the “owner” of the `tree` and is the only one who can edit it in the mod.
35 ### `ltool.get_tree(tree_id)`
36 Tries to return a `tree` for a given `tree_id`.
39 * `tree_id`: Identifier of `tree` to be received.
42 A `tree` on success, `false` on success (happens if no tree with this `tree_id` exists).
46 ### `ltool.get_tree_ids()`
47 Returns a sorted table containing all tree IDs.
53 A sorted table containing all tree IDs, sorted by ID.
57 ### `ltool.add_tree(name, author, treedef)`
58 Adds a tree to the tree table.
61 * `name`: The tree’s name.
62 * `author`: The author’s / owners’ name
63 * `treedef`: The full tree definition, see `lua_api.txt`
66 The tree ID of the new tree.
70 ### `ltool.remove_tree(tree_id)`
71 Removes a tree from the tree database.
74 * `tree_id`: ID of the tree to be removed
80 ### `ltool.rename_tree(tree_id, new_name)`
81 Renames a tree in the database
84 * `tree_id`: ID of the tree to be renamed
85 * `new_name`: The name of the tree
92 ### `ltool.copy_tree(tree_id)`
93 Creates a copy of a tree in the database.
96 * `tree_id`: ID of the tree to be copied
99 The ID of the copy on success,
100 `false` on failure (tree does not exist).
104 ### `ltool.generate_sapling(tree_id, seed)`
105 Generates a sapling as an `ItemStack` to mess around later with.
108 * `tree_id`: ID of tree the sapling will grow
109 * `seed`: Seed of the tree the sapling will grow (optional, can be nil)
112 An `ItemStack` which contains one sapling of the specified `tree`, on success.
113 Returns `false` on failure (happens if tree does not exist).
117 ### `ltool.give_sapling(tree_id, seed, player_name, ignore_priv)`
118 Gives a L-system tree sapling to a player.
121 * `tree_id`: ID of tree the sapling will grow
122 * `seed`: Seed of the tree (optional; can be nil)
123 * `playername`: name of the player to which
124 * `ignore_priv`: if `true`, player’s `lplant` privilige is not checked (optional argument; default: `false`)
130 * `false, 1` if player does not have `lplant` privilege
131 * `false, 2` if player’s inventory is full
132 * `false, 3` if `tree` does not exist
136 ### `ltool.plant_tree(tree_id, pos, seed)`
137 Plants a tree as the specified position.
140 * `tree_id`: ID of tree to be planted
141 * `pos`: Position of tree, in the format `{x=?, y=?, z=?}`
142 * `seed`: Optional randomness seed, equal seed creates equal trees
145 `false` on failure, `nil` otherwise.
149 ### `ltool.show_treeform(playername)`
150 Shows the main tree form to the given player, starting with the "Edit" tab.
153 * `playername`: Name of the player to whom the formspec should be shown to