For Minetest 0.4.13 and later
Depends default
Licenses: Code WTFPL. Schematics CC BY-SA
Download https://github.com/paramat/saveschems/archive/master.zip rename to 'saveschems'
Code https://github.com/paramat/saveschems
Example of how to use the recently added 'minetest.serialize_schematic' function to convert a lua-table defined schematic to a .mts file saved in a mod folder.
Create your schematic in lua table form, edit the names used in the code below the table, then just run the mod in any world, when the mod loads at game startup the .mts files are written to the schematics folder.
If using globally force-placed schematics you will often need to make sure air nodes are not force-placed, otherwise they will eat chunks out of the terrain, do this by using "air" with prob1 = 0 (probability zero).
This uses the recently added 'per-node force-place' feature of Minetest schematic format v4. This is used for tree trunk nodes so they replace the leaves of any other close trees they pass through, without the tree's leaves also being force-placed and replacing trunk nodes of any other close trees. Until now close-packed trees would inevitably have chopped trunks.
The lua tables have been simplified by removing any optional parameters that have these default values:
param2 = 0 (normal rotation).
force_place = false.
The format of the lua tables is:
Vertical slices of the structure in order of increasing z (here labelled -2, -1, 0, 1, 2), composed of ..
Horizontal lines of nodes in order of increasing y, composed of ..
Nodes in order of increasing x.