Skip to content

Commit

Permalink
Minor adjustments to sharing data
Browse files Browse the repository at this point in the history
  • Loading branch information
Haxxer committed Jan 31, 2022
1 parent 775aac6 commit d703d5c
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 29 deletions.
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,17 @@ Like what we've done? Buy us a coffee!

## What is Item Piles?

Have you ever wished you could represent items in your scenes? A pile of items, something to interact with - or perhaps chests whose appearance changes depending on what happens to it, whether it's open, closed, full, or empty.
Have you ever wished you could represent items in your scenes? A pile of items, something to interact with - or perhaps chests whose appearance changes depending on what happens to it, whether it's open, closed, full, or empty. Do you want an easy way to split loot between players?

Then you need **Item Piles**!

In short, this module enables dropping items onto the canvas, which then get represented as a pile of items. In order to work in all systems without breaking or messing too much with the core functionality of Foundry, this **creates an unlinked token & actor** to hold these items. When a player double-clicks on an item pile token, it opens a custom UI to show what the pile contains and players can then take items from it.

As a GM, you can open the same Item Pile inventory UI by holding **Left Control** and then **double-clicking** on the item pile token.
Item Piles can also be configured to act as a container, where it can be open or closed, locked or unlocked, with the ability for the token that represents the pile to change image depending on its state.

Item Piles can also be configured to act as a container, where it can be open or closed, locked or unlocked, with the ability for the token that represents the pile to change image depending on its state. In addition, when an item pile is interacted with it can also play sounds for the action, such as opening, closing, or attempting to open a locked item pile. Sounds are only played for the user who attempted the action.
In addition, when an item pile is interacted with it can also play sounds for the action, such as opening, closing, or attempting to open a locked item pile. Sounds are only played for the user who attempted the action.

In addition, the module features a robust and well documented API, where module and system creators can leverage Item Piles to enrich your looting experience.
Last but not least, the module features a robust and well documented API, where module and system creators can leverage Item Piles to enrich your looting experience.

---

Expand Down Expand Up @@ -118,12 +118,6 @@ Instead, we recommend that you duplicate the default item pile to create new ver

![Item Pile Token Configuration](./docs/images/configs.png)

### Warning!

Be sure to set any new Item Piles as **unlinked from its actor data**! Unless you know what you're doing, keeping this enabled will be confusing as **all tokens of this pile will share the same images and inventory**.

![Item Pile Token Linked](./docs/images/disable-link.jpg)


### Sharing and splitting

Expand All @@ -137,6 +131,12 @@ If there's any quantity that is uneven and cannot be split between players, ther

When both sharing options are disabled, only then can you enable the **Take All** button.

### Warning!

Be sure to set any new Item Piles as **unlinked from its actor data**! Unless you know what you're doing, keeping this enabled will be confusing as **all tokens of this pile will share the same images and inventory**.

![Item Pile Token Linked](./docs/images/disable-link.jpg)

### Extra UI and settings

In addition, item piles have a few extra buttons on the right click Token HUD to open, close, lock, and unlock containers, and a quick way to access the configuration of that token.
Expand Down
2 changes: 1 addition & 1 deletion changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Item Piles Changelog

## Version 1.3.0 Beta - Not released (see beta track on readme)
## Version 1.3.0
- Added item pile currency and/or item splitting capabilities
- Added chat message when currency and/or items are split between players
- Added API methods:
Expand Down
15 changes: 0 additions & 15 deletions module.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,6 @@
"lang": "en",
"name": "English",
"path": "languages/en.json"
},
{
"lang": "fr",
"name": "French",
"path": "languages/fr.json"
},
{
"lang": "ja",
"name": "日本語",
"path": "languages/ja.json"
},
{
"lang": "de",
"name": "Deutsch (German)",
"path": "languages/de.json"
}
],
"dependencies": [
Expand Down
12 changes: 9 additions & 3 deletions scripts/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ import { registerSocket } from "./socket.js";
import { registerLibwrappers } from "./libwrapper.js";
import { registerHotkeysPre, registerHotkeysPost } from "./hotkeys.js";
import flagManager from "./flagManager.js";
import { ItemPileInventory } from "./formapplications/itemPileInventory.js";
import DropCurrencyDialog from "./formapplications/dropCurrencyDialog.js";
import { ItemPileCurrenciesEditor } from "./formapplications/itemPileCurrenciesEditor.js";
import { getActorCurrencies, getActorItems } from "./lib/lib.js";

Hooks.once("init", async () => {
Expand All @@ -24,6 +21,7 @@ Hooks.once("init", async () => {

Hooks.once("socketlib.ready", registerSocket);
Hooks.on("canvasReady", module._canvasReady);
Hooks.on("preCreateToken", module._preCreatePile);
Hooks.on("createToken", module._createPile);
Hooks.on("deleteToken", module._deletePile);
Hooks.on("dropCanvasData", module._dropData);
Expand Down Expand Up @@ -143,6 +141,14 @@ const module = {
}
},

async _preCreatePile(document){
if(!document.isLinked){
document.data.update({
[`actorData.flags.${CONSTANTS.MODULE_NAME}.-=${CONSTANTS.SHARING_DATA}`]: null
});
}
},

async _createPile(tokenDoc) {
if (!lib.isResponsibleGM()) return;
if (!lib.isValidItemPile(tokenDoc)) return;
Expand Down

0 comments on commit d703d5c

Please sign in to comment.