# Easy way to create a "border" of objects?

**URL:** <https://discourse.mapeditor.org/t/easy-way-to-create-a-border-of-objects/645>\
**Category:** Suggestions\
**Created:** [July 16, 2015, 3:11pm UTC](https://discourse.mapeditor.org/t/easy-way-to-create-a-border-of-objects/645 "2015-07-16T15:11:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ferr](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.mapeditor.org/ferr/32/1875_2.png) [@ferr](https://discourse.mapeditor.org/u/ferr)\
**Post date:** [July 16, 2015, 3:11pm UTC](https://discourse.mapeditor.org/t/easy-way-to-create-a-border-of-objects/645/1 "2015-07-16T15:11:10Z")

</div>

(Note that this is on an isometric map) I want to create a border of trees on my map. It seems necessary to put trees next to each other on separate layers so that they overlap correctly (to avoid z-fighting or tile-fighting, if you can call it that in isometric).

In my case, based on the size of my trees, I need to create 3 layers to place my trees to help with overlapping. So at the moment, I select a layer, plop a tree, then select another layer, plop another tree, etc. But in order to produce a nicely sized border (i.e. user cannot see beyond trees within view window) I need it to be at least 3 rows deep, surrounding my entire map. That’s a lot of switching layers and plopping! I tried copy/paste, but that seemed very difficult.

Is there some way to automatically generate a border? It would be cool if I could use the Commands editor, or something similar, to input something like [-foreach tile in row[0].tiles] [-if tile.index % 3 == 0] [-stampFromSelectedTiles layer[0]] and so on.

At the moment, realistically speaking, if I needed to create a border like this on a 500x500 map, I’d need to write some C# code to modify the .tmx file with the border tiles to save myself some pain.

---

<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:** [July 16, 2015, 6:44pm UTC](https://discourse.mapeditor.org/t/easy-way-to-create-a-border-of-objects/645/2 "2015-07-16T18:44:01Z")

</div>

First of all I do not entirely understand the problem with the overlap. Maybe a screenshot would help here. Normally, on an isometric map I would use a single image for the entire tree. This makes it easy to place them in large numbers and it generally works fine regarding the drawing order since tiles are rendered top to bottom, left to right (so in Tiled, there should never be “z-fighting”).

> [@ferr](#):
>
> Is there some way to automatically generate a border? It would be cool if I could use the Commands editor, or something similar, to input something like [-foreach tile in row[0].tiles] [-if tile.index % 3 == 0] [-stampFromSelectedTiles layer[0]] and so on.
> 
> At the moment, realistically speaking, if I needed to create a border like this on a 500x500 map, I’d need to write some C# code to modify the .tmx file with the border tiles to save myself some pain.

If you can’t simplify the operation you should definitely consider automating it, but unfortunately Tiled is not yet scriptable, so you’d have to pick your language of choice with a TMX library that can both read and write. I will eventually add support for scripting such operations, and this is covered by the following issue on github:

> <https://github.com/mapeditor/tiled/issues/949>
>
> Most people are not into C++ / Qt and compiling Tiled themselves, and as such sm…all additions that would benefit their productivity are often not even started on. There should be an easy way to write scripts to perform actions in Tiled. Examples of things that should be possible:
> \- Running some script explicitly that performs some action on the map
> \- Adding a custom tool
> \- Hooking up to events to perform certain actions automatically
> \- Adding a custom map reader / writer
> 
> At the moment I think JavaScript would be the best choice of scripting language, because a JavaScript engine is provided as part of Qt and because having a JavaScript Tiled API should help with the development of a QtQuick based version of Tiled.
> 
> Examples of where scripting would have been useful (also see issues referencing this issue below):
> 
> \* http://discourse.mapeditor.org/t/how-do-i-batch-automapping/3033
> \* http://discourse.mapeditor.org/t/selective-automapping/3093
> \* https://www.patreon.com/posts/22268925

If you want to help me get around to it sooner, please consider [supporting me on Patreon](https://www.patreon.com/bjorn) so I can afford to spend more time on Tiled. Thanks!

---

<div class="post-metadata">

**Author:** ![ferr](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.mapeditor.org/ferr/32/1875_2.png) [@ferr](https://discourse.mapeditor.org/u/ferr)\
**Post date:** [July 16, 2015, 7:12pm UTC](https://discourse.mapeditor.org/t/easy-way-to-create-a-border-of-objects/645/3 "2015-07-16T19:12:54Z")

</div>

Thanks. Re #1, I think the issue was related to my tileset. Using a tileset with a single image for the entire tree made it look perfect.

Glad to see there is already an Issue for scripting. Hope to see it and other cool things added in to further polish Tiled. Keep up the great work!
