Trouble understanding set up of Mass Replace Tiles script for Tiled

Hello, this is not a question related directly to Tiled, I may be asking this in the wrong place, but as I see it indirectly related to Tiled, I’m asking it anyway.


====== Setting up your remapping map =======
Before you can use this script, you will need to create a remapping map,
which is a regular Tiled map which will tell this script which old tiles
should be replaced with which new tiles.

The map should have two Tile Layers:
“old” should contain the tiles you’re replacing. The easiest way to make
this layer is to select everything in your old tileset and stamp it
onto the layer. Make sure your map is large enough to fit all that.
Any empty cells on this layer will be ignored.
“new” should contain the replacement tiles. Each replacement tile should be in the same cell as the old tile, but on this layer instead.

The bold part is what troubles me, as I understand it it means that the “new” layer is a copy of the “old” layer, yet it can’t be that way, I’m understanding it wrong, not knowing what is expected from me in the “new” layer. Some visual explanation could help :slight_smile:

1 Like

The “old” layer contains your old tiles. Then for each “old” tile, the “new” layer contains its replacement. Here’s an example showing replacing white doors with brown ones:
“old” layer:
“new” layer:

hmmm in my case, the replacement tiles aren’t new, they are the same, graphically speaking. What is new is that they are rearranged on the grid due to a resizing. Maybe I am using the wrong script for the effect wanted ?

No, this is still the right script, and I’ve used it to “fix” broken tilesets like this. It’s just that instead of having a very easy way to “see” which tile is replaced by which other tile, you’ll have to do it the hard way, through understanding the way the tile IDs shifted when you rearranged your tileset. So if you know tile 1 should be tile 246 now, you put tile 1 in “old” and tile 246 in “new”, even if that’s a visually completely different tile.

1 Like

Understood perfectly, hard way it’s gonna be, thanks again ! :slight_smile:

1 Like

If you want to rearrange a tileset in the future, I recommend making the rearranged version a separate Tileset, using a separate tileset image. Then, you can use this script to replace the old tiles with the new ones in all your maps, with a clear visual mapping between old and new and no need to worry about tile IDs.

For my big WIP tileset that I’m drawing currently, which I know I will have to widen eventually as I will be adding a lot more tiles, I’ve actually already started a remapping map even though I don’t need it yet. I’m arranging the tiles from the narrow old tileset into a more convenient layout on the “old” layer. Then when I’m ready, I can export this map as an image, and make my new tileset out of that image, and plop all the tiles from that onto a “new” layer on top of that one, and quickly update all my hundreds of maps.

This same approach can also be used to split and merge tilesets.

1 Like

Well I thought I understood but… Argh, let me put this into a picture

The way I understand it, for example: tile 0 stays the same tile 0 and tile 394 becomes tile 224, to set up the remapping map, I did stamp tileset A into “old” layer, now I’m a bit lost regarding the “new” layer because tileset A should become B and C, not just B… Also, I’m completely free to arrange the way I want inside tileset B and C and still have access to tileset A

Tileset A goes in “old”.
Tile 6 from Tileset C goes in “new” on top of (i.e. in the same cell, but on the “new” layer instead of “old”) tile 17 from tileset A. Tile 224 from tileset B goes on top of tile 394 from tileset A.

Using separate tilesets makes this very similar to my doors example from the top of the thread: instead of white and brown variants of the same tiles, it’s A and B/C variants of the same tiles. In both cases, you’re placing like tiles on top of like tiles.

Tiles are tiles, it doesn’t matter how many tilesets they’re from or what tilesets they’re from. The tiles you want to replace go in “old”, their replacements go in “new”, that’s all the script cares about.

Also, I’m completely free to arrange the way I want inside tileset B and C and still have access to tileset A

You’re free to change the layouts of B and C all you want, but you should do so before you place any of the tiles in any maps (and that includes the remapping map), since rearranging them after that will mess things up. If you change the layouts after using the tiles, you’ll have to remap them again xP

1 Like

I think I understand now… and I think what lost me in my reasoning is that I didn’t prepare the tsx B and C when I asked for help, I only had them as image aka not loaded into the tmx… I was trying to calculate a match like coordinates or stg, now I (eventually) see that there is nothing to calculate, just a visual match pairs game :sweat_smile:

I’m filling the “new” layer now and I’ll come back after following all steps from your script’s notes

1 Like

I see. From your original thread, it sounded like you didn’t have tileset A and had already messed up your maps, but I see now that’s not the case and your scenario is actually pretty simple :D So, I probably made it sound more complicated than it actually is.

Aaaand it worked the way expected, map is happy with tilesets B and C instead of the rebellious A !!

Phew… I can breathe now :smiley:
Yes, it was a simple scenario I can see that ! Trouble understanding comes mainly from my lack of knowledge about Tiled itself AND my interpretation of what the script does

Thank you really for this script and your guidance :pray:
I really didn’t want to place tiles by hand again, you saved my sanity !