Extra properties for tile types in TileSet?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Aaron
:warning: Old Version Published before Godot 3 was released.

I want to attach different properties to the tile types in a TileSet. Things like “defence bonus” or “movement penalty”.

I imagine I can create a separate script with a dictionary of “tile data” objects keyed by the tile indices in a TileSet. But I can’t think of a way to populate this dictionary other than by hand, and making sure I fix the index keys should I change the corresponding TileSet significantly.

:bust_in_silhouette: Reply From: The_Duskitty

The only thing i can think of if you’re gonna do it for each individual tile would be to put a script inside of each individual tile and possibly attach them to globals, but if somebody has a better answer then i’d sudgest you do what they say

:bust_in_silhouette: Reply From: dc1a0

This is shooting from the hip from what little I do know about tiles.

That said, since you can name individual tiles, there should also be a way to check the name of a certain tile in relation to your character. It would have to be able to check relation of choice if it is possible, due to the difference in relevant tile between a top-down and side scrolling game.

Providing this assumption holds true, You can check the relevant tile’s name and apply your own effects against that.

:bust_in_silhouette: Reply From: Bojidar Marinov

I think you should go with your original idea, but use tile names instead of indices, and TileMap::get_tileset() and TileSet::tile_get_name.

:bust_in_silhouette: Reply From: TotCac

As already discussed, I use it by giving name to tile:
type_name_iterator

Then I will have “floor _ carpet _ 1”, “wall _ brick _ 4”, etc… Then you have to spit name according to “_” separator to retrieve informations.
This is the only way of doing this easily.

If you want more data like price, walking aptitude, armor, you will need some separate dictionnary.

:bust_in_silhouette: Reply From: puppetmaster-

In my game I have a separate tilemap and tileset for game logical tile.

StartPosition is tile with index = 0
Enemy1StartPosition is tile with index = 1
and so on…

With this code you can find the index and position:

var elements_tilemap = get_node("elements")
var elementscells = elements_tilemap.get_used_cells()

for cell in elementscells:
	var cell_tile_id = elements_tilemap.get_cell(cell.x,cell.y)
	var tmp_pos = elements_tilemap.map_to_world(cell)

You can add then the enemy scene to the position of Enemy1StartPosition.