Storing a collection of Items in an Item?

Use cases would be: - containers could contain other Items - some items have prerequisites, which consist of other Items I'm trying to figure out the best way to represent that. It seems logical that adding Items to an item should be done via drag and drop from a compendium (or from the game items SideBar tab). I can use the BasicDocAppshell.svelte example from essenial-svelte-esm as a reference for drag and drop... but what do I do with the drop? Option 1 Add them as an embedded collection? As far as I can tell, one can't just arbitrarily add an embedded collection or Items to an Item? Option 2 I could just write the uuids or ids to an array in the Item's .system node. But I feel like that's probably expensive as it would involve a db lookup on each item? Option 3 ...?
1 Reply
TyphonJS (Michael)
I'm not going to have much bandwidth to provide advice as I'm behind "schedule" on getting the next TRL release out. The cleanest solution would be an embedded collection for items within items, but as you recognize this isn't going to work out. I don't think there is anything you can do at the system level to change the base Item into accepting an embedded collection, but I haven't tried or looked into it. Your next best bet is using flags on the item documents. I don't know anything about the data you are trying to store in an item or if that data is dynamic. Conceivably you'll create an item compendium that can be dropped on the UI you create for an item. If the data is static then you can parse and store attributes from those drops in flags. If it is not static attributes then you'll have to do UUID lookups, but also have those sub-items imported into the world items collection. That is probably not ideal in general. So, not having a clue about the data organization or larger purpose of what you are trying to build I can only provide the above general advice. You might have to change your design to make it more efficient given the limitations of Foundry. Beyond that I really can't spend too much more time offering advice in the coming month. I need to get the next TRL release out before July 10th and it's going to be close.