Difference between revisions of "minetest.spawn tree"
Jump to navigation
Jump to search
(→Description: Update link) |
(Add example) |
||
Line 10: | Line 10: | ||
See [[Introduction to L-system trees]] for a description of L-system trees. | See [[Introduction to L-system trees]] for a description of L-system trees. | ||
+ | |||
+ | == Example == | ||
+ | This code will spawn an apple tree with its origin at position (0,0,0), assuming that [http://wiki.minetest.net/Games/Minetest minetest_game] is used: | ||
+ | <source> | ||
+ | local treedef = { | ||
+ | axiom="FFFFFAFFBF", | ||
+ | rules_a="[&&&FFFFF&&FFFF][&&&++++FFFFF&&FFFF][&&&----FFFFF&&FFFF]", | ||
+ | rules_b="[&&&++FFFFF&&FFFF][&&&--FFFFF&&FFFF][&&&------FFFFF&&FFFF]", | ||
+ | trunk="default:tree", | ||
+ | leaves="default:leaves", | ||
+ | angle=30, | ||
+ | iterations=2, | ||
+ | random_level=0, | ||
+ | trunk_type="single", | ||
+ | thin_branches=true, | ||
+ | fruit_chance=10, | ||
+ | fruit="default:apple" | ||
+ | } | ||
+ | |||
+ | local pos = { x=0, y=0, z=0 } | ||
+ | |||
+ | minetest.spawn_tree(pos, treedef) | ||
+ | </source> | ||
+ | |||
+ | The resulting tree may look like this: | ||
+ | |||
+ | [[File:Apple Tree.png|420px]] | ||
+ | |||
== Notes == | == Notes == | ||
Line 17: | Line 45: | ||
provides functions to register L-system trees to be spawned during map generation, | provides functions to register L-system trees to be spawned during map generation, | ||
and finds places for them to spawn based on the map seed and biome. | and finds places for them to spawn based on the map seed and biome. | ||
− | |||
− | |||
[[Category:Methods]] | [[Category:Methods]] |
Revision as of 18:14, 6 February 2015
Syntax
minetest.spawn_tree(pos, tree)
Description
Spawns an L-system tree at position pos
, using the tree definition tree
.
See Introduction to L-system trees for a description of L-system trees.
Example
This code will spawn an apple tree with its origin at position (0,0,0), assuming that minetest_game is used:
local treedef = {
axiom="FFFFFAFFBF",
rules_a="[&&&FFFFF&&FFFF][&&&++++FFFFF&&FFFF][&&&----FFFFF&&FFFF]",
rules_b="[&&&++FFFFF&&FFFF][&&&--FFFFF&&FFFF][&&&------FFFFF&&FFFF]",
trunk="default:tree",
leaves="default:leaves",
angle=30,
iterations=2,
random_level=0,
trunk_type="single",
thin_branches=true,
fruit_chance=10,
fruit="default:apple"
}
local pos = { x=0, y=0, z=0 }
minetest.spawn_tree(pos, treedef)
The resulting tree may look like this:
Notes
VanessaE's plants_lib mod (github) provides functions to register L-system trees to be spawned during map generation, and finds places for them to spawn based on the map seed and biome.