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

Custom Classes Member properties do not export to Lua file #3315

Closed
ghost opened this issue Mar 27, 2022 · 10 comments
Closed

Custom Classes Member properties do not export to Lua file #3315

ghost opened this issue Mar 27, 2022 · 10 comments
Assignees
Labels
missing feature It's not just a feature, it's a feature that really should be there!
Projects

Comments

@ghost
Copy link

ghost commented Mar 27, 2022

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"] = {}
          }
@eishiya
Copy link
Contributor

eishiya commented Mar 27, 2022

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
Copy link
Contributor

eishiya commented Mar 27, 2022

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.

@bjorn
Copy link
Member

bjorn commented Mar 28, 2022

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 bjorn self-assigned this Mar 28, 2022
@bjorn bjorn added the missing feature It's not just a feature, it's a feature that really should be there! label Mar 28, 2022
@bjorn bjorn added this to Bugs in Roadmap Mar 28, 2022
@eishiya
Copy link
Contributor

eishiya commented Mar 28, 2022

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?

@bjorn
Copy link
Member

bjorn commented Mar 28, 2022

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.

@eishiya
Copy link
Contributor

eishiya commented Mar 28, 2022

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.

@bjorn bjorn changed the title RepeatX, RepeatY and Custom Classes Member properties do not export to Lua file Custom Classes Member properties do not export to Lua file Oct 21, 2022
@Immow
Copy link

Immow commented Feb 25, 2024

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.

@eishiya
Copy link
Contributor

eishiya commented Feb 25, 2024

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.

@Immow
Copy link

Immow commented Feb 25, 2024

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

@bjorn
Copy link
Member

bjorn commented Mar 12, 2024

@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 bjorn closed this as completed in d29ef08 Mar 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
missing feature It's not just a feature, it's a feature that really should be there!
Projects
Status: Done
Roadmap
  
Bugs
Development

No branches or pull requests

3 participants