vnen / godot-tiled-importer

Plugin for Godot Engine to import Tiled Map Editor tilemaps and tilesets
MIT License
835 stars 87 forks source link

add compatibility with tiled 1.9 #158

Open cromerc opened 2 years ago

cromerc commented 2 years ago

This PR adds compatibility with tiled 1.9. A major breaking change is that they changed the type attribute to now be called class.

I left the old type attribute in for now so that it should work with both 1.8 and 1.9.

This fixes the issue #157.

bitbrain commented 2 years ago

I created a setup like this in 1.9 (custom class with object attributes):

Capture

but currently get these errors when loading the tilemap:

 Missing information in custom properties (around line 0).
 res://addons/vnen.tiled_importer/tiled_xml_to_dict.gd:291 - Invalid get index 'properties' (on base: 'int').
 res://addons/vnen.tiled_importer/tiled_map_reader.gd:1151 - Invalid get index 'y' (on base: 'Nil').
 res://addons/vnen.tiled_importer/tiled_map_reader.gd:1151 - Invalid get index 'y' (on base: 'Nil').
 res://addons/vnen.tiled_importer/tiled_map_reader.gd:1151 - Invalid get index 'y' (on base: 'Nil').
 res://addons/vnen.tiled_importer/tiled_map_reader.gd:366 - Invalid operands 'String' and 'Nil' in operator 'in'

Another thing to consider is how we want to store this information of child attributes (those can then again have child attributes in a cascading manner) within Godot. One way could be to create a child node of type Node and configure meta information on those.

cromerc commented 2 years ago

Do you have a demo project I can use to debug the issue?

bitbrain commented 2 years ago

@cromerc there you go. It contains a simple class that contains another class as an attribute. That class then has a bunch of objects it references in the world.

tiled-1.9-demo-project.zip

cromerc commented 2 years ago

I just did some testing, and those errors also appear when using 1.8.6 of tiled as well. So this PR and the 1.9 changes have nothing to do with your problem and should be a separate issue.

Please open a separate issue with your problem to keep this PR clean, and I will try to see what is causing the error once I get a chance.

bitbrain commented 2 years ago

Created https://github.com/vnen/godot-tiled-importer/issues/161 on the back of that!