Export function for custom exporters

I am adding more (personal) features to the editor and I am having an issue locating the source that handles custom (scripted) exports. Specifically the file(s) that processes API request for object data. I have support for tinting individual objects and access to exporting that data in the form of "tintColor = “#xxxxxx”. My issue lies in the code exporting unset data as #000000. I wish to exclude anything with

if (mapObject->tintColor().isValid())
        writeColor("tintColor", mapObject->tintColor());

This works in Luaplugin.cpp, but for customs, I cannot find the source that handles it. Can anyone please assist? Maybe @bjorn? Thanks.

I can’t help, but here’s a related issue: Unset Color property should not be `#000000` · Issue #3154 · mapeditor/tiled · GitHub
If you find a solution to this, I hope you’ll consider making a PR, as this problem affects all scripts that need to distinguish set and unset colour properties.

1 Like

I found a workaround using the new tiled.color() function that was added in Tiled 1.11:

if (tiled.activeAsset.backgroundColor == tiled.color("invalid"))
    // no background color is set
    ;

I’ve tested this and the comparison is true for unset colors and false when the color is set to black.

(any invalid color name works, but I’d recommend using “invalid” for readability)

2 Likes

Works like a charm! Thanks.

1 Like