English (Developer) Chinese (Simplified)
Automapping is an advanced tool to automatically search certain combinations of tiles across layers in a map and to replace these parts by other combination. This allows the user to draw structures with a minimum of time spent and the Automapping will be able to generate a rather complex scenario, which would need lots more time if manually crafted.
So the goal of Automapping is that you only need to draw within one layer and everything else is setup for you. This brings some advantages:
**Less errors** - the main reason is to reduce the error rate. If you have setup the rules properly, there is no hidden error.
`Automapping explained for Tiled 0.9 and later (YouTube) <http://www.youtube.com/watch?v=UUi0lD1pxyQ>`__
The Automapping feature is looking for a text file called 'rules.txt' in the folder where the current map is located. Each line in this text file is either
or a path to another textfile which has the same syntax (i.e. in another directory)
or is a comment which is indicated by **#** or **//**
A **rulefile** is a standard map file, which can be read and written by tiled (\*.tmx). In one rulefile there can be defined multiple rules.
An automapping **rulefile** consists of 4 major parts:
The definition of regions describes which locations of the rulemap are actually used to create Automapping rules.
The definition of inputs describes which kind of pattern the working map will be searched for.
The definition of outputs describes how the working map is changed when an input pattern is found.
The map properties are used to fine-tune the input pattern localization and the output of all rules within this rules file.
There must be either a tile layer called **regions** or there must be the both tile layers **regions\_input** and **regions\_output**. Using the **regions** layer, the region defined for input and output is the same. Using the different layers **regions\_input** and **regions\_output** delivers the possibility to have different regions for the input section and the output section. The region layer(s) are only used to mark regions, where an Automapping rule exists. Therefore it does not matter which tiles are used in this layer, since these tiles are just used to define a region. So either use any tile or no tile at a coordinate to indicate if that coordinate belongs to a rule or if it doesn't.
If multiple rules are defined in one rulemap file, the regions must not be adjacent. That means there must be at least one tile of unused space in between two rules. If the regions are adjacent (coherent) then both regions are interpreted as one rule.
Of course multiple rules are possible in one rulemap. If you want to have the rules applied in a certain sequence, you should use multiple **rulefiles** and define the sequence within the **rules.txt** file. As of now there also is a certain sequence within one rulemapfile. Generally speaking the regions with small y value come first. If there are regions at the same y value, then the x value is taken into account. On orthogonal maps this ordering scheme is the same as for reading in most western countries. (Left to right, top to down). The order within one rulemap may be changed later, once tiled is capable of utilizing multiple threads/processors. So if you want to rely on a certain sequence, use different rulemaps and order these in the rules.txt
Inputs are generally defined by tile layers which name follows this scheme:
where the **[not]** and **[index]** are optional. After the first underscore there will be the name of the input layer. The input layer name can of course include more underscores.
The **name** determines which layer on the working map is examined. So for example the layer *input\_Ground* will check the layer called *Ground* in the working map for this rule. *input\_test\_case* will check the layer *test\_case* in the working map for this rule.