API: ltool.get_tree()

master
Wuzzy 2014-10-16 18:04:42 +02:00
parent 4c8d49f4fe
commit e0230ac95b
2 changed files with 26 additions and 1 deletions

13
API.md
View File

@ -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

View File

@ -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()