User:LABoyd2/modules from manual 151008

usage
Defining your own module (roughly comparable to a macro or a function in other languages) is a powerful way to reuse procedures.

In this example, passing in the parameters distance, rot, and size allow you to reuse this functionality multiple times, saving many lines of code and rendering your program much easier to read.

You can instantiate the module by passing values (or formulas) for the parameters just like a C function call:

children
The child nodes of the module instantiation can be accessed using the children statement within the module. The number of module children can be accessed using the $children variable.

Parameters


 * empty : select all the children
 * index : integer. select one child, at index value. Index start at 0 and should be less than or equal to $children-1.
 * vector: vector of integer. select children with index in vector. Index should be between 0 and $children-1.
 * range: [ : ] or [ : : ]. select children between to, incremented by (default 1).

Deprecated child module

Up to release 2013.06 the now deprecated  module was used instead. This can be translated to the new children according to the table:

Examples

Transfer all children to another module:

Use the first child, multiple time:

If you need to make your module iterate over all children you will need to make use of the $children variable, e.g.:

arguments
One can specify default values for the arguments:

And then use one of the following ways to supply the arguments