Skip to content

Int custom(?) property in Tmx file read as float #80

@jlaumonier

Description

@jlaumonier

Problem

For pytiled_parser v.2.2.7,

When I read an int custom property from a TMX file, the result type is float. Is there any reason for that ? I could cast in int in my code but in that case, what the point of setting an int type in Tiled ?

Possible solution

It seems that the following lines in parser/tmx/properties.py cause the problem :

 elif type_ == "int" or type_ == "float": value = float(value_) 

I think they could be replaced by

 elif type_ == "int": value = int(value_) elif type_ == "float": value = float(value_) 

With my few tests, it seems to resolve the problem but one other modification could be useful also in pytiled_parser/properties.py

Property = Union[float, Path, str, bool, Color] -> Property = Union[float, Path, str, bool, Color, int]

I did not test for Json format.

Thanks for your library

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions