Defining tilesource animations programatically

Say we have a tilesource like this one


where all tiles and character animations are defined at once.

We are indeed using that tilesource, but only a fraction of it, as seen on the outline. So far so good. But now we want to add some variation to our levels. And just to define all the different visual aspects for ground and wall tiles (those seen in the upper-left side of the tilesource) I would need to add around 50 animations… one by one. Clicking here, clicking there, writing in a text field, rinse, repeat.

Is there a faster way of doing this? Programatically, perhaps? Would prefer to edit a text file than clicking around to create a new animation and set values on the editor…

1 Like

All of Defold’s files are text-based, so you can write a script in whatever language you like to automate that. If you want to use Lua, there’s an editor scripting system that lets you add custom menu items to run your code.

3 Likes

I was going to answer the exact same thing as @Potota :slight_smile:
Having our formats in text is a deliberate choice. It helps with resolving conflict in source control (e.g. git), scripting content and also debugging.

It is quite common that studios build their own content pipelines around existing tools, and this is such a case where it would fit very well.

If you want to use the correct file format for generating the data, the file format for the .tilesource is defined here .
It’s a Protobuf file (most of our file formats are), ans is scriptable using e.g. Python and other languages.

Of course, you may do the generation manually, and it should work well for the most time, as we very rarely introduce changes to the format on disc, and even then, it’s easy to regenerate such a file.

2 Likes

Indeed, I had a look at the tilesource file in text mode and thought we could easily do it that way! But didn’t know if it would tamper Defold files in some way.

Good to know, thanks! Will probably do it in text mode :smiley:

3 Likes