#got it, thanks, that'll get me looking

1 messages · Page 1 of 1 (latest)

hexed cliff
#

I think my issue is actually not so much related to the item not cloning properly, but rather when I then try to use createEmbeddedDocuments on the target and pass it that item, it'll create it but not its contents, and I think it may be because the content items' permissions don't get update in this way?

Basically, I'm trying to find a way to take an existing container from one token and clone it to another actor. I can easily clone over the container itself, but its contents get lost.

latent magnet
#

they just contain a list of ids of items that 'are in' that container, and then the sheet rendering makes it look like that

hexed cliff
#

right

latent magnet
#

there's no actual items-inside-items in foundry

hexed cliff
#

so how would i accomplish the ask of cloning a container and the list of item ids in it?

Create the new container and then loop through the items, clone each, and put them into the new container?

latent magnet
#

yep, i'd think so

hexed cliff
#

I was afraid of that

latent magnet
#

and since the new items will have new ids, also double check at the end that it all lines up. you can create with {keepId: true} but better to just assume they'll change, catch them, then update the container, more resilient that way

hexed cliff
#

You wouldn't happen to know how to update the container's list of items contents, would you? I have successfully created the new container at the destination, created all the new items that were "in" the source container, and they currently just show in the destination inventory. How would I update the container to "move" the items into it (link it to the container). Directly setting the container.system.contents seems forbidden. Cannot set property contents of #<ContainerData> which has only a getter

latent magnet
#

and the nested data models may make it more complicated than that

#

this isn't pf2e, which is the only system i'm specifically familiar with, so you're on your own from here, ask back in the main channel if you get stuck

hexed cliff
#

Appreciat eit

#

I got it. You were close. It's the other way around. You can't set the system.contents direclty on a container. Instead, you set the system.container on each item. Then it works. Thanks again.