solarus-games / solarus

This repository was moved to GitLab: https://gitlab.com/solarus-games/solarus
http://www.solarus-games.org
Other
710 stars 133 forks source link

Custom properties of entities #1094

Closed christopho closed 6 years ago

christopho commented 6 years ago

Allow to add any property (key and value) to any type of entity.

https://files.gitter.im/solarus-games/Lobby/vMVf/image.png

Diarandor commented 6 years ago

This is great. I was thinking in a feature like this a few days ago.

I am not sure but, shouldn't this be in the Editor's repo?

christopho commented 6 years ago

Yes but the engine still has to support the updated data file format and to provide a Lua API to get/set properties.

CJBok commented 6 years ago

Awesome stuff!

Diarandor commented 6 years ago

Will these properties appear as a parameter for the creation event? I mean: entity:on_created(properties_list).

Or there will be a specific function to recover the list of properties? I mean: entity:get_initial_properties().

christopho commented 6 years ago

There will be entity:get_property() and entity:set_property(). Or entity:get_field()/entity:set_field(), I am not sure :)

Diarandor commented 6 years ago

I think it could be convenient to allow to recover that list somehow, or at least the list of keys. For instance, if we want to make a script that clones entities (of many types), we cannot know which were the initial properties because we cannot access that info.

CJBok commented 6 years ago

I would vote for entity:get_property() and entity:set_property().

Also can the same be done on the actual map as well? Would be nice to have extra properties on the map as well :)

Diarandor commented 6 years ago

@CJBok: I think so. The issue seems to me not only about the engine, but also about the Map Editor, as it can be seen in the attached image.