Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems when dragging containers and contained items from one character to another #30

Closed
crazyclausewitz opened this issue Jan 16, 2022 · 4 comments · Fixed by #149
Closed
Assignees
Labels
bug Something isn't working inventory-tab Related to the inventory tab on the character or monster sheets

Comments

@crazyclausewitz
Copy link

When dragging items from one character to another they are not moved but copied instead. With containers this introduces some problems:

  • When dragging a container, only the container is copied but not its content
  • When dragging an item thats inside a container, the item vanishes on the other character sheet, since the copied item still references the old container. The weight however is still added to the weight carried and you cannot get rid of the dragged item, since it is nowhere to be displayed.
@freohr freohr added bug Something isn't working character-sheet Related to the character sheet, but not the inventory tab labels Jan 17, 2022
@anthonyronda
Copy link
Member

Just touching this Issue tonight to say this is a very complicated problem and we have to reckon with whether containers need an overhaul.

Foundry doesn't natively allow Items to hold other Items inside them the same way Actors can have Items inside them. The way it's done in OSE is a hack, and I'm still not comfortable enough with the codebase to touch the container code. As we've discussed on #32, a fix here should also go through all the world actors, find hidden bugged items, and unhide them.

@anthonyronda anthonyronda changed the title Problems when dragging items from one character to another Problems when dragging containers and contained items from one character to another Feb 23, 2022
@anthonyronda
Copy link
Member

Edited title just to clarify that the item drag-drop behavior between actors is the designed behavior and not a bug. Only the behavior of containers and contained items when dragged between sheets is unexpected/a bug

@anthonyronda anthonyronda self-assigned this Mar 7, 2022
@anthonyronda anthonyronda added inventory-tab Related to the inventory tab on the character or monster sheets and removed character-sheet Related to the character sheet, but not the inventory tab labels Mar 14, 2022
@anthonyronda
Copy link
Member

Macro to temporarily fix the second point in your issue:

/* Macro to fix items that may be stuck hidden because
 * they have a containerId value but the container can't be found
 * or two containers that contain each other */

// use with token selected
// updates the actor and linked tokens, not unlinked tokens
// If it's an unlinked token, delete the token afterward and create a new one

let arr = [];
actor.data.items.forEach((item) => {
  if (item.data.type === "container")
    arr.push({ _id: item.id, "data.containerId": "", "data.itemIds": []});
  else
    arr.push({ _id: item.id, "data.containerId": ""});
})
actor.updateEmbeddedDocuments("Item", arr);

@anthonyronda
Copy link
Member

There's going to be a fix for this in the latest release. Please keep in mind the following:

Contained items will "spill out" outside of the container on the new sheet. There's no way to prevent this behavior. The container and the items it contained are in fact entirely new instances of those objects with no way to "discover" each other's new item ids.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working inventory-tab Related to the inventory tab on the character or monster sheets
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants