I’m pretty sure this isn’t possible right now (correct me if I’m wrong), but I’m making a game where hiding objects inside other objects is a core mechanic (so items in desks, under floor tiles, etc.). Ideally, I’d be able to define objects in Tiled such that it outputs XML formatted like this:
<object id="6" name="Wood_Desk" type="Furniture" x="256" y="32" width="64" height="64">
<container size="4">
<object id="7" name="Paper_Note" type="Small_Item" x=256" y="32" width="32" height="32" says="I got that thing you wanted. Meet me in the library @ 0800">
</object>
<object id="8" name="Tooth_Brush" type="Small_Item" x=256" y="32" width="32" height="32">
</object>
</container>
</object>
The only way I can think of to do this currently is to reference the item ID of the item I want in the desk as a property of the desk and have my parsing code set up to find that item elsewhere in the level, but that makes my parsing code a lot messier.
Your title says nested properties but your example XML output shows nested objects. Either way, both are not currently supported of Tiled, but both would be worth supporting in the future.
Alternatively, I would probably give the desk object a name and add a property on each item object that should be inside like “container: name_of_desk”. You can of course also use the unique object IDs for this. In any case I think this should be easier to manage than having multiple properties, or some comma-separated list, on the desk object.
To quickly find items by their name or ID you of course just need to set up for example an std::map<int,Object*> after loading your map and then run through your objects another time to resolve the references.
I’m not sure what kind of parsing code you have, but in my engine I wrote support for what you’re looking for there (and indeed used it a lot on Citizens of Earth), by doing something like this:
For the objects you want inside an object, I have a property on the object in Tiled like:
Parent: Wood_Desk
At build-time, my tool parses the .tmx structure to generate a binary output file of the level for ease of run-time import, and saves a hashed value of the parent name. So when exporting the bit for Paper_Note, for example, it would export a 32-bit int representation of Wood_Desk that I can use later.
At run-time, when loading in the level and the objects, I notice an object has a parent specified. I check the objects for the specified hash name (since this is much faster than string comparison), and do whatever i need to do in order to associate these two objects in their respective relationship. Perhaps if I was trying to implement your specific example, I’d have the parent possess something like a HiddenObjectContainerComponent, ensure the objects inside are not rendered nor interactable, and then reveal them when the parent is interacted with.
So, I’m not sure how much that will specifically benefit you, but suffice to say, what you want to do is still possible in Tiled at this moment, you just have to use it in a different way
+1 for nested properties, even more so I would like the ability to create component defs, as in I define a flicker component to have these properties: flicker:{ period:.5, color:#FFFFFF }. and I can add a flicker component to any object just like I could a string