mapeditor/tiled

Do you want to work on this issue?

You can request for a bounty in order to promote it!

Being able to have an array custom property #1493

issy123 posted onGitHub

Request

It would be nice if we could add a custom property of type array. Mostly an array of strings.

I can't really see use for other datatypes, so just add array as option (which would be an array of strings)

Example

image

Reason

We currently use a comma seperated list to write down which doors a button would open. But this is prone to errors and prefer an array list.


Just adding my two cents but array property types would be very useful for me. I'm currently storing more complex data as JSON in a string image

Whilst this works. It's fiddly to edit and completely bypassess all the niceties of Tiled's other properties. I.e. I can't use a color type or an object inside the JSON. In those cases, my vote would be for heterogenous arrays, not just string types.

posted by joereynolds over 1 year ago

I'm currently storing more complex data as JSON in a string

I'm curious, why do you not use custom types in Tiled for this? JSON seems unnecessary here, you can have e.g. component[0]: property of type "animatable", component[1]: property of type "plays_sound_on_event" with sub-properties "sound" and "event", component[2] of type "dies_on_event" with sub-property "event", and so on.

Untyped arrays would certainly be useful for lists of components though, so I support the request for those.

posted by eishiya over 1 year ago

I'll be honest, the only reason is because I haven't started looking into custom properties yet and this was a quick way to get me up and running.

I'll take the suggestion on board and have a look though, thanks!

posted by joereynolds over 1 year ago

A first possible implementation of arrays, which shouldn't have too much impact, would be when the user copies and pastes a property, to check whether this property already exists. If so, we add a number that we increment each time we copy. PropertyName0 property PropertyName1 etc

posted by ironpowertga over 1 year ago

A first possible implementation of arrays, which shouldn't have too much impact, would be when the user copies and pastes a property, to check whether this property already exists. If so, we add a number that we increment each time we copy. PropertyName0 property PropertyName1 etc

This would interfere with modifying properties through copy+pasting and would only be an array in name only, something you can already do in Tiled without any additional features in Tiled. To aid in making "propertyName[N]"-style faux arrays, one could write a Tiled script that lets you put a name in and the number of values to add (and perhaps a starting index, to help with adding more indices to an existing "array".

I don't think there's a need for Tiled to "officially" support faux arrays and muddy the waters for later when real arrays are added.

posted by eishiya over 1 year ago

bumpy bump. 👍 +1 in support of adding an array type as a custom property.

(I ran into this limitation when wanting to make a list of candles 🕯️ that will light up when a lever is activated.)

Consequently, after reading through the issue, I'm in support of the untyped arrays. Same as:

However, I do think untyped will be easier to implement since that's just adding one new property type "array", which could probably use a QVariantList and instantiate a QtVariantProperty for each entry, which will automatically pick the right widget.

The end user's importer would likely be the place to validate the consistent types if that's what they want. Untyped arrays already exist in the objects, for instance.

posted by MarkOates about 1 year ago

Bump.

I was searching for this feature and it was said 3 years ago that it was planned for the upcoming release: https://discourse.mapeditor.org/t/array-custom-property-type/4933

Please add it soon, it would be very helpful for lots of people, including me.

posted by GabrielBigardi 12 months ago

Fund this Issue

$0.00
Funded
Only logged in users can fund an issue

Pull requests