Giter Site home page Giter Site logo

Comments (6)

Kiamo2 avatar Kiamo2 commented on August 26, 2024

Maybe setting the "Add class as metadata" option is useful for you.
You could then set the class attribute to e.g. "TeleporterEntry" and after import it should show up in the metadata.
Would this be an acceptable solution for you?

Besides that you can always add a custom property e.g. "object_id" and set it to some value to identify it.
Every custom property which is not a godot internal one is added to the metadata.

PS ok, I now have understood the problem, the 3 is coming from Tiled internally.
I have yet to think about that.

from yati.

Kiamo2 avatar Kiamo2 commented on August 26, 2024

Ok, I'll implement it in a future release.

In the meantime I see two possible workarounds:

  1. Change the custom property 'exit' to type string and give it the value 'TeleporterExit'.

or

  1. Add to TeleporterExit a custom property of name 'object_id' and of type object and link it to itself.
    This way a change of the id in Tiled should be automatically be reflected in a change of this value.

from yati.

LoraHart avatar LoraHart commented on August 26, 2024

Ok, I'll implement it in a future release.

Very good, thank you! I have "hacked" a workaround until then. In the beginning of the function handle_object (in TilemapCreator.gd) I remember the object id:

func handle_object(obj: Dictionary, layer_node: Node, tileset: TileSet, offset: Vector2) -> void:
var obj_id = obj.get("id", null)

Further down every time the "class" metadata is set I also set the object id. For instance:

if _add_class_as_metadata and class_string != "":
obj_sprite.set_meta("class", class_string)
if obj_id != null:
obj_sprite.set_meta("id", obj_id)

I'm not remotely sure if that is correct but it works for my use case for now.

Maybe setting the "Add class as metadata" option is useful for you.

This is an indication for me that I might have picked the right places :)

Add to TeleporterExit a custom property of name 'object_id' and of type object and link it to itself.
This way a change of the id in Tiled should be automatically be reflected in a change of this value.

That is very clever! This even works when you copy/paste the object. The property becomes a self reference of the new object.

from yati.

Kiamo2 avatar Kiamo2 commented on August 26, 2024

Just released v1.6.2 where I added a new option 'add_id_as_metadata' working similar like 'add_class_as_metadata'.
I choose to guard it by that option because you never know if someone might not like that.

from yati.

LoraHart avatar LoraHart commented on August 26, 2024

Thank you very much! I plan to integrate the new release during this week.

from yati.

LoraHart avatar LoraHart commented on August 26, 2024

Works perfectly for me. The issue can be closed as far as I'm concerned.

from yati.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.