tiled icon indicating copy to clipboard operation
tiled copied to clipboard

Scripting: the API for getting PropertyTypes

Open finscn opened this issue 1 year ago • 1 comments

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 avatar Jul 21 '22 11:07 finscn

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]
        }

max-carroll-sky avatar Sep 02 '22 15:09 max-carroll-sky

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 avatar Oct 16 '22 11:10 Ishadijcks