Difference between revisions of "minetest.spawn tree"
Jump to navigation
Jump to search
(Add example) |
m (Make sure the name “Minetest Game” is used consistently throughout this page) |
||
Line 12: | Line 12: | ||
== Example == | == Example == | ||
− | This code will spawn an apple tree with its origin at position (0,0,0), assuming that [http://wiki.minetest.net/ | + | This code will spawn an apple tree with its origin at position (0,0,0), assuming that [http://wiki.minetest.net/Subgames/Minetest%20Game Minetest Game] is used: |
<source> | <source> | ||
local treedef = { | local treedef = { |
Revision as of 17:11, 11 October 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.