ldtk icon indicating copy to clipboard operation
ldtk copied to clipboard

Persist Per-Tile Custom Data to Tiled Export

Open TomMalitz opened this issue 2 years ago • 0 comments

Like many others, I love LDtk but many engines and tools support mature features for Tiled.

The Tiled export works well, but currently the per-tile custom data that is set in LDtk does not persist in the Tiled export. It would be nice to be able to persist a flat JSON object from the LDtk custom data to the custom properties in the tmx tileset data.

As an example, let's assume we have a tileset and for tile 0 we have the following custom data in LDtk:

{
 "bool": true,
 "string": "text",
 "int": 1,
 "float": 10.5
}

Currently in the tmx export this tileset will look like following, losing all custom data:

<tileset firstgid="1" name="TileSet" tilewidth="16" tileheight="16" tilecount="16" columns="4" objectalignment="topleft" margin="0" spacing="0">
  <image source="../path/tileset.png" width="64" height="64"/>
</tileset>

With the proposed change the tmx export tileset would reflect the the following, retaining the custom data from LDtk:

<tileset firstgid="1" name="TileSet" tilewidth="16" tileheight="16" tilecount="16" columns="4" objectalignment="topleft" margin="0" spacing="0">
  <image source="../path/tileset.png" width="64" height="64"/>
  <tile id="0">
   <properties>
    <property name="bool" type="bool" value="true"/>
    <property name="string" value="text"/>
    <property name="int" type="int" value="1"/>
    <property name="float" type="float" value="10.5"/>
   </properties>
  </tile>
</tileset>

Tiled custom properties support additional types, but I think having bool, string, int, and float would cover the majority of use-cases for using custom properties in the Tiled export data.

Let me know what you think, and again, love LDtk!

-- Update --

Actually ended up implementing this and opened a PR - https://github.com/deepnight/ldtk/pull/989

TomMalitz avatar Oct 26 '23 04:10 TomMalitz