You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There's one major problem with this: tile_data.get_custom_data("is_metal_floor") throws an error if the custom data layer doesn't exist on the current tile. The problem is that there's no way to check via the TileData if a data layer exists on it or not, which is weird and unintuitive.
If this enhancement will not be used often, can it be worked around with a few lines of script?
Yes, but you would need to check if the data layer exists in the TileSet first rather than TileData, which is cumbersome and probably not always accessible. If TileData can get the custom data layer, it should also tell me whether it exists or not.
Describe the project you are working on
A 2D platformer character that checks the tile under it for custom data, for things like having different footstep noises.
Describe the problem or limitation you are having in your project
The way to get a custom data layer from a tile I'm currently touching is by doing this (the final line is the most relevant):
There's one major problem with this:
tile_data.get_custom_data("is_metal_floor")
throws an error if the custom data layer doesn't exist on the current tile. The problem is that there's no way to check via the TileData if a data layer exists on it or not, which is weird and unintuitive.This becomes confusing for people trying to just fetch custom tile data without causing errors. See: https://forum.godotengine.org/t/can-you-determine-if-a-custom-data-layer-exists-for-a-tilemaplayer/85891
Describe the feature / enhancement and how it helps to overcome the problem or limitation
Add a function
has_custom_data(layer_name: String)
which would allow me to check if it exists before trying to get it.Alternatively, maybe the function shouldn't cause an error in the first place and just let me check if it's null or not.
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
If this enhancement will not be used often, can it be worked around with a few lines of script?
Yes, but you would need to check if the data layer exists in the TileSet first rather than TileData, which is cumbersome and probably not always accessible. If TileData can get the custom data layer, it should also tell me whether it exists or not.
See: https://forum.godotengine.org/t/can-you-determine-if-a-custom-data-layer-exists-for-a-tilemaplayer/85891/5
Is there a reason why this should be core and not an add-on in the asset library?
It's core functionality.
The text was updated successfully, but these errors were encountered: