Skip to content

Add support for pre-1.0 Tiled JSON formats #65

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

rl-starbound
Copy link
Contributor

While attempting to parse Starbound dungeons in Tiled JSON format, I encountered a number of parse errors. These errors appear to be due to pre-1.0 differences in the Tiled JSON map and tileset formats. As far as I can tell, most Starbound dungeon files were created and/or last edited with Tiled 0.15.2.

  • Map object properties were dictionaries rather than lists, with the key being the property name and the value always a string.
  • Tileset tiles were dictionaries rather than lists, with the key being the tile id (integer cast as a string) and the value being a dictionary containing the remainder of the tile definition.
  • Some map and tileset properties did not exist, or were optional.

This patch introduces minimal changes to the code to allow the Starbound files to be parsed. There may be other legacy quirks, but these are the only ones I've noticed in these files.

While attempting to parse Starbound dungeons in Tiled JSON format, I
encountered a number of parse errors. These errors appear to be due to
pre-1.0 differences in the Tiled JSON map and tileset formats. As far as
I can tell, most Starbound dungeon files were created and/or last edited
with Tiled 0.15.2.

* Map object `properties` were dictionaries rather than lists, with the
  key being the property name and the value always a string.
* Tileset `tiles` were dictionaries rather than lists, with the key
  being the tile id (integer cast as a string) and the value being a
  dictionary containing the remainder of the tile definition.
* Some map and tileset properties did not exist, or were optional.

This patch introduces minimal changes to the code to allow the Starbound
files to be parsed. There may be other legacy quirks, but these are the
only ones I've noticed in these files.
@Cleptomania
Copy link
Member

Hey thanks for the PR.

I'm happy to merge this and try to support older versions of Tiled on a sort of best effort approach, but don't think I can ever make a guarantee that older versions will work with every new version of pytiled-parser or anything, it's just infeasible for me to maintain compatibility and build tests for many different versions.

That being said, as long as we don't break compatibility with current versions of Tiled, I'll gladly merge anything that increases compatibility with older versions. As a side note in this regard, our test suite has fairly substantial coverage, so if it doesn't break any tests, we can be pretty reasonably confident that there shouldn't really be any problems.

@Cleptomania Cleptomania merged commit 9bdd769 into pythonarcade:development Jan 16, 2023
@benjamin-kirkbride
Copy link
Collaborator

@rl-starbound If you are willing, we'd love to hear about your specific use case for pytiled-parser. I assume you are not using the Arcade game library as well?

@rl-starbound rl-starbound deleted the support-legacy-starbound branch January 16, 2023 16:53
@rl-starbound
Copy link
Contributor Author

I maintain and/or monitor a bunch of mods for Starbound. Starbound uses the Tiled JSON format for most of its dungeons. It uses Lua as its game asset language, but with a core in C++, which includes the Tiled parsing logic. Based on the Tiled assets, most of its dungeons were written in Tiled 0.15.2, with a handful of the newer dungeons written with Tiled 1.0.2-1.2.2. Mods typically use the latter as well, although many mods have used even newer versions of Tiled.

My main use case for pytiled-parser was that I wanted to update the Starbound wiki with information about where to find various objects in the game. Most of the Wiki content was written by users as they found things organically, but as the game evolved, those reports tended to become inaccurate. By using pytiled-parser to parse the game assets, I was able to definitively state where objects could be found in the game, as well as identify which objects were not actually findable in the game. I've also used it to find which of my modded dungeon pieces contain certain objects, which helps find the pieces I need to edit.

@benjamin-kirkbride
Copy link
Collaborator

@rl-starbound I see, so it sounds like you mostly use it for data-mining type work, is that correct? Cool use case!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants