Skip to content
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

Issue #301 Fix loading tmx tilesets of individual tiles #304

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

benfrussell
Copy link

Fixes issue #301
If a tile element is encountered load_tmx() will attempt to associate the tile properties with an element of tileset as normal unless a KeyError or AttributeError is encountered. If accessing a tileset causes an attribute error (because there was no previous image element that created the tileset with from_atlas()) or if it causes a key error (because there was no tile with the gid expected), then we assume this is a new tile and add it as an individual tile to the tileset.

@nikitalarionov
Copy link

Get this error too, thanks for fix!

@benfrussell
Copy link
Author

No problem!

Just in case you run into it, I also found after this fix that objects didn't properly grab the usertype from the associated tile type in the tileset. I made made an easy fix for it in my fork, but it's not relevant to the main branch until this PR is accepted so it'll just live their for now.

@Intey Intey mentioned this pull request Jun 15, 2018
if value.isdigit():
value = int(value)
tile.properties[name] = value
except (KeyError, AttributeError):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an exceptionally broad try block, those two errors could come from any number of lines above. What specific key and attribute access errors are being caught here?

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

Successfully merging this pull request may close these issues.

4 participants