Match multiple layers with Automapping

Hi. I have a question regarding automapping across multiple layers.

I got several tilesets with automapping set up for each, to achieve autotiling paths that I wouldn’t be able to use the terrain feature for. I can pick one key tile from each tileset and simply paint paths, which works great as long as I stick to the one named layer I set the automapping up for. But if I define it for Layer01, and I switch to Layer02, the automapping obviously doesn’t apply there.

My question now is whether it’s possible to match an input layer to a series of layers, as if using a wildcard. For example: input_Layer*. I realize it probably wouldn’t be that simple, because there’d be questions about differently named output layers and stuff, but perhaps there is a solution other than copying the rules for layers 1 through X that I missed :sweat_smile:

I’m guessing that generally giving the layers the same name might work, but I am currently using a differently named output layer (eg Layer01Auto) because I’m using a key tile as the “brush”, and I haven’t found a way to match each tile from only one specific tileset inside the automapping rule map. Hope this makes sense.

TLDR: Ideally I’d like to use multiple tilesets and automapping rule maps, each with the layers input_Layer* and output_Layer*Auto, and for that to just work with any number of Layer...s on my various maps. Is there anything that would allow this? :sweat_smile:

No, this is not possible. You’d need to make a copies of your rules with input_Layer02, and so on. A quick way to do this would be to File > Save As your rules as another map, and then use a script like my Replace In Layer Name script to quickly rename the input/output layers to the new targets. Don’t forget to add the new map(s) to your rules.txt.

Naming multiple layers the same thing would not work, Tiled will look at only the first matching layer it finds.

Edit: You could write a script that renames your layers and applies Automapping repeatedly to make sure it gets all the layers, but that would not work with Automap While Drawing. I think multiple sets of rules would be better, though it would make maintaining the rules more difficult.

1 Like

Alright, I guess I’ll just copy the layers then and create a couple in advance, like layers 1 through X. Since the rules are the same for each of my tilesets, I can just create one rule map, copy it, and switch out the image for each one.

But perhaps this is something that could be added in the future :slightly_smiling_face: Thanks for the quick response!

There is an issue for pattern-matching that should be less ambiguous than some of the other multi-layer-matching feature requests, perhaps we might see that eventually: Allow pattern matching on automap input and output. · Issue #4097 · mapeditor/tiled · GitHub

1 Like

Hi again. I have a follow up question. I just tried duplicating the input and output layers in one rule map to handle automapping on multiple layers, assuming Tiled would go through all uniquely named layers and handle them. But after looking at this, I realize the system probably wouldn’t know which output layer to use.

output_Layer02A
input_Layer02
output_Layer01A
input_Layer01

I then tried to use only one output layer, with multiple input layers, but that didn’t seem to work either. My question then is, do I have to create a dedicated rule map for every layer I might want to automap on?

tileset_01_layer01.tmx
- output_Layer01A
- input_Layer01

tileset_01_layer02.tmx
- output_Layer02A
- input_Layer02

...

The easiest way to duplicate rules is to copy the entire map, as I said. If you want them in the same map, you need to make sure you move the contents of the layers (with cut+paste, not with Offset Layers) so that they’re separate rules and not additional conditions and outputs for the old rules.

1 Like

Ah, sorry. It didn’t quite register with me that you meant copying the entire map. Alright, thanks :sweat_smile: I hope someone will look into implementing pattern matching :slightly_smiling_face: