Possible to read/write extra metadata on map load/save via script?

I may have a use for a script that processes tile information and creates extra metadata whenever a tmx is saved, then likewise reads this data when a tmx is opened. I’m not sure if this is even possible, and if it is, can it save the data into the tmx itself, or needs to make some auxiliary file?

I didn’t have success finding example scripts that run on map load and save, if they exist. I suspect if I had an example I could ask more specific questions.

This should definitely be possible with the existing API. Custom properties can be used to set metadata on maps (see related methods on TiledObject) and the following signals are available for responding to load and save respectively:

You can find an example using such a signal on the documentation for Signal. If the code should only apply to maps, check the assetType of the asset parameter (or just use isTileMap).

Thanks, this gives me a really good starting place!!

1 Like