minetest.create_schematic
From Minetest Developer Wiki
Syntax
minetest.create_schematic(p1, p2, probability_list, filename, slice_prob_list)
Description
 Create a schematic from the volume of map specified by the box formed by
p1
andp2
.  Apply the specified probability values to the specified nodes in
probability_list
.

probability_list
is an array of tables containing two fields,pos
andprob
. 
pos
is the 3d vector specifying the absolute coordinates of the node being modified,  and
prob
is the integer value from 0 to 255 of the probability (see: Schematic specifier).  If there are two or more entries with the same pos value, the last occuring in the array is used.
 If
pos
is not inside the box formed by p1 and p2, it is ignored.  If
probability_list
isnil
, no probabilities are applied.  Slice probability works in the same manner, except takes a field called ypos instead which indicates
 The y position of the slice with a probability applied.
 If slice probability list is
nil
, no slice probabilities are applied.

 Saves schematic in the Minetest Schematic File Format to
filename
This article is missing examples, feel free to add them.