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

Scripting: the API for getting PropertyTypes #3419

Closed
finscn opened this issue Jul 21, 2022 · 3 comments · Fixed by #3971
Closed

Scripting: the API for getting PropertyTypes #3419

finscn opened this issue Jul 21, 2022 · 3 comments · Fixed by #3971
Labels
feature It's a feature, not a bug.

Comments

@finscn
Copy link

finscn commented Jul 21, 2022

the 1.9 supplies the feature about PropertyTypes.
Bug there is no API for get the PropertyTypes informations.

And I can't get the display name of a custom Enum-Property.
The value of it is number.

So, I hope there could be some APIs for that work.

@finscn finscn added the feature It's a feature, not a bug. label Jul 21, 2022
@max-carroll-sky
Copy link

Yes would love this feature too, for a work around I'm doing this for the moment

  const projectFile = new TextFile("C:\\Users\\{my name}\\tiled-project\\untitled.tiled-project", TextFile.ReadOnly)
      const pfText = projectFile.readAll()
      const project = JSON.parse(pfText)

     const {propertyTypes} = project

Then I am getting the values later on like this

  const genericEnum = o.resolvedProperty('aiType')
        let aiType = ''
        if (genericEnum) {
            aiType = propertyTypes.find(p=> p.id === genericEnum.typeId).values[genericEnum.value]
        }

@Ishadijcks
Copy link

I would love if editing PropertyTypes was added to the API. I'd like to create an extension which synchronizes Tiled PropertyTypes with TypeScript enums

@bjorn
Copy link
Member

bjorn commented Mar 12, 2025

And I can't get the display name of a custom Enum-Property.
The value of it is number.

@finscn While it's not entirely trivial yet, now there is an API available for this, for example with the biome property being a value from a custom enum, you can get it name as follows:

var biome = tiled.activeAsset.resolvedProperty('biome');
var biomeType = tiled.project.findTypeByName(biome.typeName);
var biomeName = biomeType.nameOf(biome);

I would love if editing PropertyTypes was added to the API. I'd like to create an extension which synchronizes Tiled PropertyTypes with TypeScript enums

@Ishadijcks If you get this to work based on the new API I'd love to see your solution!

We'd in any case welcome any feedback on the APIs added in #3971 before getting to the Tiled 1.12 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature It's a feature, not a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants