tiled icon indicating copy to clipboard operation
tiled copied to clipboard

RepeatX, RepeatY and Custom Classes Member properties do not export to Lua file

Open dennisfortin opened this issue 2 years ago • 6 comments

Issue 1

The new RepeatX and RepeatY properties for image layers do not export to Lua files. The value is always set to "false" even when they are set to true in Tiled.

Steps

  1. Create a new map.
  2. Add an Image Layer to the map layers.
  3. Check either of the Repeat X or Repeat Y check boxes in the image layer properties list.
  4. Save and export the map as a Lua file.

Issue 2

The members for new Custom Class properties do not export to Lua files. The property value is exported as an empty Lua table.

Steps

  1. Select View > Property Types Editor.
  2. Click "Add Class".
  3. Click "Add Member", give the member a name and a default value.
  4. For any layer or map, click the + for Custom Properties.
  5. Add a new property type for the new class.
  6. Save and export the map as a Lua file.

Example

export_defect

When exported to a Lua file, these properties will look as follows:

          ...
          repeatx = false,
          repeaty = false,
          properties = {
                ["myprop"] = {}
          }

dennisfortin avatar Mar 27 '22 01:03 dennisfortin

Issue 1 is a duplicate of #3307, as the underlying problem was that Tiled wasn't copying these properties into the copy of the map that gets passed to the various exporters. It'll be fixed in 1.8.3.

eishiya avatar Mar 27 '22 01:03 eishiya

I also had a look at Issue 2 in one of the nightly builds, and that looks fixed too: image

  properties = {
    ["myprop"] = {
      ["int prop"] = 3
    }
  },

Looks like this one was fixed in 1.8.2.

eishiya avatar Mar 27 '22 01:03 eishiya

Issue 1 is a duplicate of #3307

That is correct.

I also had a look at Issue 2 in one of the nightly builds, and that looks fixed too:

No, actually the issue is here, that @dennisfortin didn't set any of the members of that class, and the default values are not written out.

For those that actually need the full classes written out, the plan was to make an export option for this, or to make it part of the "Resolve types and properties" export option. If there's nothing against the latter I can look into doing that as part of Tiled 1.8.3.

bjorn avatar Mar 28 '22 07:03 bjorn

No, actually the issue is here, that @dennisfortin didn't set any of the members of that class, and the default values are not written out.

Ah, good catch. In the screenshot, since the properties were black, I thought they were manually set. Do classes members not have a visual distinction between set and unset/default values?

eishiya avatar Mar 28 '22 12:03 eishiya

Do classes members not have a visual distinction between set and unset/default values?

They do, but it's not graying out, instead the set members have their name displayed in bold.

bjorn avatar Mar 28 '22 12:03 bjorn

They do, but it's not graying out, instead the set members have their name displayed in bold.

Ah. I think that's too subtle, I didn't notice it ): Bold tends to be harder to notice in dark themes. Is there a reason it's done differently for class members? It's not possible for a class member to be unset in both ways at once or to be set in one way but not in another, so I don't think the two different visualisations are necessary. Edit: Well, I guess it's possible for a member to have its value set to something other than the class default as part of an Object Type, so there is that. Bah.

eishiya avatar Mar 28 '22 15:03 eishiya

Hello, seems that in the latest version of Tiled (1.10.2) the above issue is still there. When you export your map to a lua file it does not export Class properties.

Immow avatar Feb 25 '24 14:02 Immow

Are you using the "resolve object types and properties" export setting?

If your class is used as a custom property type, rather than as a class directly on some entity (Object, Tile, Layer, etc), those properties are currently not resolved even if that export setting is used, and this applies to all export types, not just Lua (see #3411).

Edit: Just noticed this issue is still open. This means it has not been addressed yet. So, no wonder that it's still happening.

eishiya avatar Feb 25 '24 14:02 eishiya

image This property gets exported just fine in Tiled 1.9.2 I turned on: image And the issue still persists.

Immow avatar Feb 25 '24 15:02 Immow

@Immow Could it be that you're running in to the fact that, for compatibility reasons, class was renamed back to type for objects? In that case, in your project (creating one if you haven't done so), you should set the "Compatibility version" to 1.9 to get the object's class written out as "class". Or... read in the object's class from the type property, of course.

I made the unfortunate mistake of renaming this property in Tiled 1.9, and it kept tripping people up for months. That's why I renamed it back in Tiled 1.10.

bjorn avatar Mar 12 '24 08:03 bjorn