Get_tile should return the tile type as well as the ID


I notice get_tile for tilemap only returns the ID. However, what if we want to add some metadata to our tiles via the tile types in the tilesource editor? I don’t see a way to use this data in the API in the documentation here:



If/when we add that feature to the tilemaps, then we’ll probably add new functions to access that data. But until then, I think the simplest way of doing it is a separate Lua table with entries for each tile type.
I would also argue that it’s even easier to edit and overview than clicking on each tile type in the editor.

1 Like


That’s what I’m doing now, however there are some issues for me. I have a very large master tileset for my maps, so if I go down a row it adds a large amount to the number which requires a calculator for me to accurately calculate. Also, if I update the tileset I must go through and update my scripts to include new entities that weren’t there previously instead of just checking if the tile is of a certain type which would make it only one place to change to add more content.

1 Like


I have found this easiest by simply storing metadata in a global Lua table, where each key corresponds to a tile id:

local data = { [1] = { metadata_entry_1 = <info>, ... }, ... }

I do not believe Defold should hold responsibility for storing tile metadata in the editor since this would cause all sorts of organizational problems which could be mitigated with a global Lua table.

For example, for each metadata entry, a new field would have to show in the editor. And how does the editor know what type of data the metadata will be? Since metadata can be anything you want and you may store as much of it as you wish, the editor is not a good place for this. Additionally, this sounds like a lot of work for the dev team for such little payoff. I also think adding a supplemental feature like this one would go somewhat against Defold’s philosophy of minimalism.

Of course I may not be understanding the suggestion properly. :grimacing:

1 Like


I’m referring to this list of tileset types:


Since the tilesource is a convenient place to specify the root type of a tile, it seems like we should be able to retrieve this data. I don’t think it goes against the minimalism, having only one type like you said is extremely minimal anyways. Plus we must set this data for the collision masks to work properly. Might as well be able to get that data along with the tiles so that we can easily modify tile types in the editor with one click.



I see what you mean now, and my initial thought is that I think it would be a good addition. Please add a feature request in the github issues!



This would be a great feature. I’m currently hard coding a table of “ranges” for the tile types in my game, which is a bit clunky when working with designers.