Help with editor scripts to get animation ids from atlas

Posted this in the discord already, but then I remembered the forums are much more active :sweat_smile:

Are there any good resources for editor scripts? I still don’t quite understand after reading the info in the manual here… Editor scripts

For context - I’m making a tile based 2D platformer game, and I have custom coded the collision logic to match the methods that are described on resources that go over old-school console methods of tile based platformer collision.

To help the development process, I am making a simple data creation tool for AABB’s which should make it easy to visually define some AABB parameters that need to be hardcoded (for hitboxes for example). I want to make it as a simple loadable collection in Defold simply because the assets are already accessible there and it will be easy to program the output using the engine. I will just set up the collection, set it as my main collection then hit Ctrl+B and I can “play the hitbox maker game” to form the tables I need for the AABB’s. It will just spit out a Lua table containing things like the offset, xradius, yradius, etc. for the AABB, using a gameobject that just uses the draw_line message to visually represent it in respects to the reference during runtime. Then I can just copypaste that output into the places where the hardcoded data is needed.

Since obviously to make it visual, the animation needs to be referenced -what I need to do is get all the animation id’s of the current atlas for a given gameobject within a known collection and write them into a table somewhere that I can access at runtime so that the reference animation can be changed without having to close the build, change the animation, rebuild. This way the only configuration needed to setup the tool is to simply set the display gameobject(s) to the correct atlas in their sprite. Without this ability, the animation id’s will need to be manually entered which is very time consuming to say the least.

Do I even need an editor script for this? The reason I’m asking is because I found this, which seems similar to my problem which @Mathias_Westerdahl answered using an editor script and parsing the atlas could be a solution.

Any help to get me in the right direction is super appreciated.

It might help to take a look at: GitHub - Jerakin/editor-script-atlas: Editor script to add images to an atlas as well as create a new

2 Likes