Add TileMapLayer.get_cell_custom_data()
#10526
timothyqiu
started this conversation in
2D
Replies: 1 comment 5 replies
-
Did you mean to write: func is_wall(coord: Vector2i) -> bool:
var data := map.get_cell_tile_data(coord)
if not data:
return false
return data.get_custom_data("is_wall") And func get_cell_custom_data(coord: Vector2i, layer_name: String, default: Variant) -> Variant:
var data := get_cell_tile_data(coord)
if not data:
return default
return data.get_custom_data(layer_name) |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
When using custom data layer, it's a nuisance to write this boilerplate code for each layer:
Despite code duplication, the code above is not that robust.
get_custom_data()
could return null on error, and it's not always distinguishable from actual values of the custom data layer.I suggest making this established practice a dedicated method on
TileMapLayer
.Original version
Beta Was this translation helpful? Give feedback.
All reactions