Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Tiled: can I make the properties of the tileset works by default when added on a map?
Started by Loner Cat Jun 12 2018 01:53 AM

2 replies to this topic
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

Loner Cat

[GLOBAL: userInfoPane.html]
Loner Cat
  • Observer

  • 27 posts
  • Corona SDK

Hi.

Sorry for the unclear title, I'm having difficult to explain myself in a few words.

I'm working with Tiled and I'm facing an annoying problem that would be great to fix.

 

In my tilesed I set a few properties (variables) to any tile I use, in order not to have to set it manually any time I put this tile on a map.

But when I put this tile on a map (in a object layer, I'm not using tile layers), the property I set appears in grey, and it does not appear in the exported file. In order to make it work I have to click on it, change something and press enter. In this case it becomes black and works.

This is very annoying: the tileloader I made in corona requires any object to have a "type" property, plus other variables are needed in order to make physics and other scripts work. It is really frustrating to set it manually to any object I put on a map, when it could be a lot easier to set them in the tileset and have them working for any object.



[TOPIC: post.html]
#2

ldurniat

[GLOBAL: userInfoPane.html]
ldurniat
  • Contributor

  • 297 posts
  • Corona SDK

This is sketch. It show you how copy all properties from tileset to objects.  

for i=1, #layers do

    local layer = layers[i]

    -- Object Layer?
    if layer.objects then

        for j=1, #layer.objects do

           local object = layer.objects[j] 

           -- Find tileset based on gid
           local tileset = findTileset( object.gid )

            if tileset then

                tileset.properties = tileset.properties or {}

                -- Copy properties
                inherit( object, tileset.properties )

            end

        end

    end

end

You can find Object Type Editor useful for this task.

 

ldurniat


Edited by ldurniat, 12 June 2018 - 05:08 AM.


[TOPIC: post.html]
#3

Loner Cat

[GLOBAL: userInfoPane.html]
Loner Cat
  • Observer

  • 27 posts
  • Corona SDK

Thanks for your answer, I solved :)

I didn't notice that those properties actually appears in the exported file under the "tilesets" table :) this because the tileloader I made does not use those informations in order to build the level, so I always ignored this table :)




[topic_controls]
[/topic_controls]