Tilemap => How to create re-usable "pieces of tilemaps" templates?


edit: I’m currently using ‘Tiled’ to create and export my tilemaps (both as collections and lua files).

In my “dungeon building” prototype, the player can build their dungeon by adding “rooms” and the dungeon grows vertically. Everything is made with tilemaps for now, but not like a super-advanced tile-based dungeon, far from that…

Not sure about how I should proceed, maybe I’m missing some basics :thinking:

As you can see, the last “room” always ends with a wall at the bottom (which closes the dungeon), and this wall is replaced by an “entrance” when a new “last room” is created.

If I want not to have to update my tiles one by one, I should have templates (or something) that I would insert into my main tilemap… right?

How to create these “pieces of dungeon” templates that I can “insert” into my tilemap to upgrade the dungeon?

1/ Separate tilemaps? (1 block template = 1 tilemap)

2/ One big tilemap including layers (1 block template = 1 layer) with a custom property each like… “type”? (that would let me “identify” and insert them into my tilemap grid)

How would you proceed to create and use templates? Is this even the right approach? :thinking:

Did you try this?

You can pick tiles directly from a layer and use the selection as a brush. Hold Shift and click a tile to pick it up as the current brush. While holding Shift you can also click and drag to select a block of tiles to use as a larger brush.

1 Like

Thanks for your answer!

My issue is not about how to draw the tilemap (super easy in Tiled), nor about how to “read” the .lua exports it to create tables etc.

But how to create “templates” in Tiled that I will be able to insert (as part of a tilemap) into my dungeon to make it evolve.

I feel that my explanations are not clear at all :thinking:

What if you create these sections in Tiled and then export them as json or lua and include these files in your game? You can then read the data from such a segment/room and use the data to tilemap.set_tile()? Also see my answer here: Tilemap => possible to sort z-values of each tile separately? - #9 by britzl