API: ltool.get_tree()
parent
4c8d49f4fe
commit
e0230ac95b
13
API.md
13
API.md
|
@ -24,7 +24,18 @@ The name of the player who created the `tree`. The author is also the “owner
|
|||
|
||||
|
||||
## Functions
|
||||
### `ltool.get_tree_ids`
|
||||
### `ltool.get_tree(tree_id)`
|
||||
Tries to return a `tree` for a given `tree_id`.
|
||||
|
||||
#### Parameter
|
||||
* `tree_id`: Identifier of `tree` to be received.
|
||||
|
||||
#### Return value
|
||||
A `tree` on success, `false` on success (happens if no tree with this `tree_id` exists).
|
||||
|
||||
|
||||
|
||||
### `ltool.get_tree_ids()`
|
||||
Returns a sorted table containing all tree IDs.
|
||||
|
||||
#### Parameters
|
||||
|
|
14
init.lua
14
init.lua
|
@ -220,6 +220,20 @@ function ltool.plant_tree(tree_id, pos)
|
|||
minetest.spawn_tree(pos, tree.treedef)
|
||||
end
|
||||
|
||||
--[[ Tries to return a tree data structure for a given tree_id
|
||||
|
||||
tree_id: ID of tee to be returned
|
||||
|
||||
returns false on failure, a tree otherwise
|
||||
]]
|
||||
function ltool.get_tree(tree_id)
|
||||
local tree = ltool.trees[tree_id]
|
||||
if(tree==nil) then
|
||||
return false
|
||||
end
|
||||
return tree
|
||||
end
|
||||
|
||||
|
||||
ltool.seed = os.time()
|
||||
|
||||
|
|
Loading…
Reference in New Issue