# Automapping empty output

**URL:** <https://discourse.mapeditor.org/t/automapping-empty-output/3463>\
**Category:** Questions\
**Created:** [September 26, 2018, 7:52pm UTC](https://discourse.mapeditor.org/t/automapping-empty-output/3463 "2018-09-26T19:52:39Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![kullboys](https://avatars.discourse-cdn.com/v4/letter/k/cdc98d/32.png) [@kullboys](https://discourse.mapeditor.org/u/kullboys)\
**Post date:** [September 26, 2018, 7:52pm UTC](https://discourse.mapeditor.org/t/automapping-empty-output/3463/1 "2018-09-26T19:52:39Z")

</div>

Hello everyone  
Is there a way to make the output layer in rules empty? This is mainly to prevent the player from putting tiles on the wrong layers. I tried setting the output empty and nothing happens.

Not entirely sure how to use : “DeleteTiles” option if this is the way to check if a tile should\* be on a layer . Where do I specify which tiles to delete and which to keep ? I don’t understand the behavior of “DeleteTiles” , on how to make it keep certain tiles on a certain layer

Also how does automapping fit into groups? How would you select a tile layer inside a group?  
Thanks[.](http://holocaustmusic.org/UserProfile/tabid/57/userId/662346/Default.aspx)

---

<div class="post-metadata">

**Author:** ![bjorn](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.mapeditor.org/bjorn/32/1599_2.png) [@bjorn](https://discourse.mapeditor.org/u/bjorn)\
**Post date:** [September 26, 2018, 8:18pm UTC](https://discourse.mapeditor.org/t/automapping-empty-output/3463/2 "2018-09-26T20:18:48Z")

</div>

> [@kullboys](#):
>
> Is there a way to make the output layer in rules empty? This is mainly to prevent the player from putting tiles on the wrong layers. I tried setting the output empty and nothing happens.

Just so I get this right, you have your players create maps with Tiled, and sometimes they’re putting tiles on the wrong layers, and you’re looking to solve this using AutoMapping rules that will automatically erase stuff? It’s a pretty interesting scenario!

> [@kullboys](#):
>
> Where do I specify which tiles to delete and which to keep ? I don’t understand the behavior of “DeleteTiles” , on how to make it keep certain tiles on a certain layer

**DeleteTiles** seems to erase all tiles from the output layers that are in the same place as any tile in any input layer. I don’t think this makes sense in all cases, but it does what it does and it probably doesn’t help you.

> [@kullboys](#):
>
> Also how does automapping fit into groups? How would you select a tile layer inside a group?

Currently AutoMapping does not at all work with layers in groups. It plainly ignores them. What I could probably do is to make it search the input and output layers by name in the whole hierarchy, but if an output layer is missing it would still always be created at the top-level. It’s slightly tricky because currently the code relies on layer indexes (after finding layers by name), which does not make sense in a hierarchy.

Alternatively, new output layers would be created using the same parent layers as in the rule file, and input layers in a rule file that are in a group may only match with layers that are in a group with the same name. In any case this is an area that still needs work.

> [@kullboys](#):
>
> Is there a way to make the output layer in rules empty?

So, coming back to this question, I think there currently isn’t. However, I don’t see a reason not to allow this. We already specify the output region and the actual output separately, so if you specify some output region but then leave the actual output empty, I think it really should work as an eraser. I think that would just mean getting rid of this line:

> <https://github.com/mapeditor/tiled/blob/52d5fdc52584db9da168187498f678bc52663198/src/tiled/automapper.cpp#L853>

I’ll give it some testing and if it works as expected (and is not going to break too many existing rules), I’ll include that change in Tiled 1.2.1.

---

<div class="post-metadata">

**Author:** ![bjorn](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.mapeditor.org/bjorn/32/1599_2.png) [@bjorn](https://discourse.mapeditor.org/u/bjorn)\
**Post date:** [September 28, 2018, 7:54pm UTC](https://discourse.mapeditor.org/t/automapping-empty-output/3463/3 "2018-09-28T19:54:37Z")

</div>

> [@bjorn](#):
>
> I’ll give it some testing and if it works as expected (and is not going to break too many existing rules), I’ll include that change in Tiled 1.2.1.

Well, in my first test, with the “sewer\_automap” example shipping with Tiled, I unfortunately ran into serious compatibility issues. The rules, and I think those of many, rely on the fact that empty tiles in an output layer do not get drawn. By relying on that the rules could generally share the rule regions between the input and the output layers, even if the output region was technically smaller due to the empty tiles.

I’d still like to support outputting empty tiles, but it’ll have to be added as an option.

---

<div class="post-metadata">

**Author:** ![Jam](https://avatars.discourse-cdn.com/v4/letter/j/f6c823/32.png) [@Jam](https://discourse.mapeditor.org/u/Jam)\
**Post date:** [October 1, 2018, 4:28pm UTC](https://discourse.mapeditor.org/t/automapping-empty-output/3463/4 "2018-10-01T16:28:03Z")

</div>

> [@bjorn](#):
>
> Just so I get this right, you have your players create maps with Tiled, and sometimes they’re putting tiles on the wrong layers, and you’re looking to solve this using AutoMapping rules that will automatically erase stuff? It’s a pretty interesting scenario!

I second this feature! The ability to bind tiles to a certain layer so that players won’t place tiles on the wrong layer is what I’m missing.

---

<div class="post-metadata">

**Author:** ![bjorn](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.mapeditor.org/bjorn/32/1599_2.png) [@bjorn](https://discourse.mapeditor.org/u/bjorn)\
**Post date:** [October 1, 2018, 8:04pm UTC](https://discourse.mapeditor.org/t/automapping-empty-output/3463/5 "2018-10-01T20:04:20Z")

</div>

> [@Jam](#):
>
> The ability to bind tiles to a certain layer so that players won’t place tiles on the wrong layer is what I’m missing.

Right, this is a common request and one I do want to implement as well, but I wouldn’t want to try doing that using the above requested AutoMapping feature. Automatically placing tiles in certain layers is covered by the following issue:

> <https://github.com/mapeditor/tiled/issues/1531>
>
> I'm currently using Tiled to make layouts for a board game. In this game variou…s mini-boards can be placed on the main board and on each other. To keep them displaying correctly I'm using 4 layers, so that the various elevations of board always display on top of each other correctly, and the final layer of tokens is always on top of everything else.  
> 
> What this means is that in the tileset I'm pasting from each tile will always go into a specific layer; raised boards always go into the High Ground layer, for instance, while spawn points always go into the upper Special layer that is always on top. My problem is I keep forgetting to change layer when I go to draw something: I'll pick the tile I want, but forget to switch to the layer it should go into. It's not a big deal, but it would be nice if I could set a layer property (or tileset property) which would tell Tiled to always paste a given tile into a specific layer. I think the simplest way to do this would be to allow each layer to have a tileset mask (you draw it over the tileset and it would tint the selected tiles red or w/e), and whenever the user goes to paste a tile which is under a layers tileset mask then the tile would automatically go into that layer, rather than the currently selected one. You could make each mask exclusive (i.e. no tile can be in more than one layer mask at once) for simplicity, or allow multiple layers to mask a tile and have it go into the topmost masked layer \<= the currently selected layer.
> 
> I'm not sure if this is an extremely niche feature request though; would anyone else find something like this useful?
