# Automapping: Check for empty tile?

**URL:** <https://discourse.mapeditor.org/t/automapping-check-for-empty-tile/965>\
**Category:** Questions\
**Created:** [December 7, 2015, 7:43pm UTC](https://discourse.mapeditor.org/t/automapping-check-for-empty-tile/965 "2015-12-07T19:43:32Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Red\_Eagle\_LXIX](https://avatars.discourse-cdn.com/v4/letter/r/b5ac83/32.png) [@Red\_Eagle\_LXIX](https://discourse.mapeditor.org/u/Red_Eagle_LXIX)\
**Post date:** [December 7, 2015, 7:43pm UTC](https://discourse.mapeditor.org/t/automapping-check-for-empty-tile/965/1 "2015-12-07T19:43:32Z")

</div>

Is there a way to structure a rule such that it only activates if one of the tiles defined in the region is actually empty?

I have a rule file with a 2x2 area in my **regions** :  
 ![](https://canada1.discourse-cdn.com/flex035/uploads/mapeditor/original/1X/e3902b14cb482bab9b305818209008c43df2598a.jpg)  
On the input I have 2 diagonal blocks using the top left and bottom right corner for **input\_Ground** :  
 ![](https://canada1.discourse-cdn.com/flex035/uploads/mapeditor/original/1X/1eafa07a16b4050a99ec7b7a3b73adde6a1a7589.jpg)  
On the output I have a 2x2 output set of tiles for my **output\_Ground** :  
 ![](https://canada1.discourse-cdn.com/flex035/uploads/mapeditor/original/1X/3d5627d6e7f4e2a1fb7c5e559c2c31957e85c285.jpg)  
I know the rule will work and replace the 2 corners correctly if the 2 empty spots are populated with any other tile from any tile set. However, I want to create a rule that says those 2 spots must be empty and have no tile at all.

Perhaps a variant on inputNOT\_Ground could be used? Something like inputEMPTY\_Ground where one could specify certain tiles as part of a defined region as being required to be empty? Since by default a defined region is inputANY unless a specific tile is placed in one of the input layers.

---

<div class="post-metadata">

**Author:** ![Red\_Eagle\_LXIX](https://avatars.discourse-cdn.com/v4/letter/r/b5ac83/32.png) [@Red\_Eagle\_LXIX](https://discourse.mapeditor.org/u/Red_Eagle_LXIX)\
**Post date:** [December 7, 2015, 7:53pm UTC](https://discourse.mapeditor.org/t/automapping-check-for-empty-tile/965/2 "2015-12-07T19:53:57Z")

</div>

Example of the inputEMPTY\_Ground (if such existed).  
 ![](https://canada1.discourse-cdn.com/flex035/uploads/mapeditor/original/1X/50ff907b4c34cd75aad71828c73485aaae3fdb6e.jpg)

Below is an example of a map to demonstrate:  
 ![](https://canada1.discourse-cdn.com/flex035/uploads/mapeditor/original/1X/d48719e4b3e8ffc686a53969dfa3f17c81f79568.jpg)

With the above rule currently the output is as follows:  
 ![](https://canada1.discourse-cdn.com/flex035/uploads/mapeditor/original/1X/0d1e37fcca0a4cea492a01fd03bf920a540a8904.jpg)

However this is the output I desire (hence the question about checking for a tile being empty):  
 ![](https://canada1.discourse-cdn.com/flex035/uploads/mapeditor/original/1X/3f4cf413df90f5c444ad90b92c0f867b8fb2a05a.jpg)

---

<div class="post-metadata">

**Author:** ![stefanbeller](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.mapeditor.org/stefanbeller/32/5_2.png) [@stefanbeller](https://discourse.mapeditor.org/u/stefanbeller)\
**Post date:** [December 8, 2015, 7:29am UTC](https://discourse.mapeditor.org/t/automapping-check-for-empty-tile/965/3 "2015-12-08T07:29:32Z")

</div>

@Red_Eagle_LXIX

The Automapping was originally designed to only work in places where there are tiles, such that you can apply that to a very small region of a map.

---

<div class="post-metadata">

**Author:** ![think1st](https://avatars.discourse-cdn.com/v4/letter/t/db5fbb/32.png) [@think1st](https://discourse.mapeditor.org/u/think1st)\
**Post date:** [January 12, 2016, 6:42pm UTC](https://discourse.mapeditor.org/t/automapping-check-for-empty-tile/965/4 "2016-01-12T18:42:56Z")

</div>

Bumping this. Did some update actually break automapping here? The official example of automapping here [https://github.com/bjorn/tiled/wiki/Automapping](https://github.com/bjorn/tiled/wiki/Automapping) requires the feature OP is mentioniong. In the very first example, after the “basic shoreline” headline, an input rule is defined where the bottom part is empty, and an output rule is defined where the top part is empty. But if you actually try out this rule in the editor, it doesn’t even work since Tiled doesn’t seem to match empty regions anymore. If you try to work around it by having different input and output regions, it messes up the map because it will place the bottom shoreline below any point where the water tile is detected.

edit: it appears it actually still works, but you just have to have non empty tiles in the place where there are empty tiles in the rule definition.

---

<div class="post-metadata">

**Author:** ![rwols](https://avatars.discourse-cdn.com/v4/letter/r/919ad9/32.png) [@rwols](https://discourse.mapeditor.org/u/rwols)\
**Post date:** [October 2, 2016, 9:17am UTC](https://discourse.mapeditor.org/t/automapping-check-for-empty-tile/965/5 "2016-10-02T09:17:28Z")

</div>

Bumping this again. I too need Automap regions to be able to detect truly “null” tiles. Right now, a workaround for me is to fill the whole input layer with a fully transparent tile, which feels very hacky.

---

<div class="post-metadata">

**Author:** ![Ablu](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.mapeditor.org/ablu/32/1496_2.png) [@Ablu](https://discourse.mapeditor.org/u/Ablu)\
**Post date:** [October 2, 2016, 9:38am UTC](https://discourse.mapeditor.org/t/automapping-check-for-empty-tile/965/6 "2016-10-02T09:38:22Z")

</div>

For deleting a tile go into your rule file. Open the Map Properties there and create a propert `DeleteTiles` with the value `true`. Make sure that this property is of the type `string` (apparently it does not work with a `bool` property currently). All tiles which are are matches by the output region are deleted then if there is no tile in the output layer.

Regards,  
Ablu

---

<div class="post-metadata">

**Author:** ![Alan](https://avatars.discourse-cdn.com/v4/letter/a/a87d85/32.png) [@Alan](https://discourse.mapeditor.org/u/Alan)\
**Post date:** [October 15, 2017, 5:36am UTC](https://discourse.mapeditor.org/t/automapping-check-for-empty-tile/965/7 "2017-10-15T05:36:02Z")

</div>

This is still happening on latest tiled.  
Autotile won’t match ‘null’ tile when the rule has a null tile, it matches any tile except when it’s null, so the example in the documentation doesn’t work with the latest tiled.

---

<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:** [December 31, 2017, 6:36pm UTC](https://discourse.mapeditor.org/t/automapping-check-for-empty-tile/965/8 "2017-12-31T18:36:00Z")

</div>

> [@Alan](#):
>
> This is still happening on latest Tiled.
> 
> Autotile won’t match ‘null’ tile when the rule has a null tile, it matches any tile except when it’s null, so the example in the documentation doesn’t work with the latest tiled.

The example does work, because in the example there are no empty tiles in the set layer.

However, in general the issue described in this topic is valid in that there was no way to have either an “input” or an “inputnot” layer check against an empty tile. I’ve tried to address this by adding a “StrictEmpty” option to input layers:

> <https://github.com/mapeditor/tiled/commit/eb1e85044f309d1cd9132a15baf7eaab1be6d4a5>
>
> In "StrictEmpty" mode, empty tiles in the input region match empty tiles
> in the …set layer. So when an "input" layer contains an empty tile within
> the input region, this means an empty tile is allowed at that location.
> And when an "inputnot" layer contains an empty tile within the input
> region, it means an empty tile is not allowed at that location.
> 
> Without the "StrictEmpty" option, when no "input" layer specifies any
> tile for a given location, and no "inputnot" layers exist, any tile that
> isn't used elsewhere on any input layer is considered valid. Also, when
> an "inputnot" layer contains an empty tile, it is simply ignored. This
> behavior can be convenient, but it is not always desired.
> 
> The "StrictEmpty" mode can be enabled per input layer by adding a custom
> boolean property named "StrictEmpty" with the value "true".
> 
> See also the following discussion on the forum:
> http://discourse.mapeditor.org/t/automapping-check-for-empty-tile/965

If anybody here would still benefit from such a change, I welcome you to try it out and let me know if this approach works for your rules.
