consumables chat data

CCalego3/29/2022
@Zhell
So that's odd. How come consumables work different and all other item types get a non-functional save button when they no longer exist on the actor?
This is interesting and worth being in the history here. Only consumables have the assumption that they will need functional chat buttons after the item has been destroyed. As such they automatically put the item data into the chat message flags, and use that information when the buttons are interacted with. Normally, it's expected that the item still exists on the actor that rolled the item. But since consumables have the "Destroy when empty" logic built in, they have the special handling built in.
ZZhell3/29/2022
And this is only consumables, and I'm guessing modifying a different item's chat message to contain the itemData as well will do nothing?
CCalego3/29/2022
not actually sure about that
CCalego3/29/2022
GitLab
module/item/entity.js · master · Foundry Network / Foundry VTT 5th ...
An implementation of the Dungeons & Dragons 5th Edition game system for Foundry Virtual Tabletop (http://foundryvtt.com). This work is permitted under the Open...
CCalego3/29/2022
innnnteresting so looks like if there is itemData in the flags, it'll prefer that always
const item = storedData ? new this(storedData, {parent: actor}) : actor.items.get(card.dataset.itemId);
const item = storedData ? new this(storedData, {parent: actor}) : actor.items.get(card.dataset.itemId);
CCalego3/29/2022
So in my wee concentration module, I could not use consumable for the card displayed to prompt for checks. I would need to create the chatcard myself though? Think so. the displayCard method only populates the itemData automatically for consumables. https://gitlab.com/foundrynet/dnd5e/-/blob/master/module/item/entity.js#L745
GitLab
module/item/entity.js · master · Foundry Network / Foundry VTT 5th ...
An implementation of the Dungeons & Dragons 5th Edition game system for Foundry Virtual Tabletop (http://foundryvtt.com). This work is permitted under the Open...
ZZhell3/29/2022
Just tried slapping a weapon (toObject()) into the same flag. It works.
CCalego3/29/2022
veeeerry interesting
ZZhell3/29/2022
I.e., weapon with con save, roll it, update the message.content with 'flags.dnd5e.itemData': weapon.toObject(), then delete the weapon from the actor. Con save still works
CCalego3/29/2022
creating and then deleting the item does feel kinda bad though
ZZhell3/29/2022
(and after refresh as well, just to make sure)
CCalego3/29/2022
like why cause 3 database updates for something that should take 1 - create weapon - create chat card - delete weapon
ZZhell3/29/2022
This could be interesting for magic items with spells. 🤔
CCalego3/29/2022
for that I honestly think a new preparation mode "item" would solve like all the problems
ZZhell3/29/2022
True but some don't like the clutter. Anyway, can't one just manually edit the message with the appropriate data before creating a chat card, no item needed?
CCalego3/29/2022
Yeah true. I guess you could make a temporary item, call displayCard with createMessage: false in the args, then modify the output to include the data of the temporary item I remember Item5e#roll had issues with rolling an ephemeral item, but displayCard didn't
ZZhell3/29/2022
ephemeral?
CCalego3/29/2022
temporary i.e. a Document that doesn't exist in the database
ZZhell3/29/2022
Right
CCalego3/29/2022
Could change the DOM output too to remove the extra stuff like the chat card footer with item details. Hmmm. I might do this in concentration5e. thanks @Zhell 🙂
LTLLeo The League Lion3/29/2022
@calego gave vote LeaguePoints™ to @Zhell (#217 • 2)
ZZhell3/29/2022
Something like ChatMessage.create(msg.toObject()) does work. 🤔 and that's not a lot of data tbh.
CCalego3/29/2022
is msg the output of displayCard?
ZZhell3/29/2022
(where msg is a message that works...)
CCalego3/29/2022
gotchya the output of displayCard({createMessage: false}) is all the data you'd need to pass into ChatMessage.create() so I envision something like this:
const fakeItem = new Item5e(someItemData, {temporary: true, parent: someActor});

const messageData = fakeItem.displayCard({createMessage: false});

messageData.flags['dnd5e.itemData'] = fakeItem.toObject();

ChatMessage.create(message);
const fakeItem = new Item5e(someItemData, {temporary: true, parent: someActor});

const messageData = fakeItem.displayCard({createMessage: false});

messageData.flags['dnd5e.itemData'] = fakeItem.toObject();

ChatMessage.create(message);
ZZhell3/29/2022
I wonder just how little data you need to do this. I'm gonna strip it down until it breaks.
CCalego3/29/2022
I think it depends on the action present, refer to the _onChatCardAction method in Item5e for example if you're rolling an attack, the chatmessage needs all the data to make an item with an attack roll for a save though, it really only needs enough to make a valid item (name and type), since all the rest comes from the chat message DOM (for better or worse... bleh)
ZZhell3/29/2022
Item5e is undefined, and just Item doesn't have a displayCard function. >_>
const itemData = {data: {actionType: "save", save: {ability: 'con', dc: 20, scaling: 'flat'}}, name: "Steve", type: "loot"};
let fakeItem = new Item.implementation(itemData, {temporary: true, parent: token.actor});
let messageData = await fakeItem.displayCard({createMessage: false});
messageData.flags['dnd5e.itemData'] = fakeItem.toObject();
messageData.content = `<div class="dnd5e chat-card item-card" data-actor-id="stSaie8MWAdB4hUG">
<header class="card-header flexrow">
<img src="icons/svg/item-bag.svg" title="Steve" width="36" height="36"/>
<h3 class="item-name">Steve</h3>
</header>
<div class="card-content">
Text goes here.
</div>
<div class="card-buttons">
<button data-action="save" data-ability="con">
Saving Throw
</button>
</div>`;
ChatMessage.create(messageData);
const itemData = {data: {actionType: "save", save: {ability: 'con', dc: 20, scaling: 'flat'}}, name: "Steve", type: "loot"};
let fakeItem = new Item.implementation(itemData, {temporary: true, parent: token.actor});
let messageData = await fakeItem.displayCard({createMessage: false});
messageData.flags['dnd5e.itemData'] = fakeItem.toObject();
messageData.content = `<div class="dnd5e chat-card item-card" data-actor-id="stSaie8MWAdB4hUG">
<header class="card-header flexrow">
<img src="icons/svg/item-bag.svg" title="Steve" width="36" height="36"/>
<h3 class="item-name">Steve</h3>
</header>
<div class="card-content">
Text goes here.
</div>
<div class="card-buttons">
<button data-action="save" data-ability="con">
Saving Throw
</button>
</div>`;
ChatMessage.create(messageData);
🥳 Got rid of the footer in a messy way but eh
ZZhell3/29/2022
No description
Kkaelad3/30/2022
Man, are we all writing our own concentrators? I do the same trick with mine, creating a temporary item then adding it to the chat message's flag so the saving throw button works. https://github.com/kaelad02/concentrator/blob/main/src/concentrator.js#L252
GitHub
concentrator/concentrator.js at main · kaelad02/concentrator
Foundry module to manage concentration. Contribute to kaelad02/concentrator development by creating an account on GitHub.
CCalego3/30/2022
Lol amazing Next thing you'll tell me that both of you have made little modules to check if an attack roll his
Kkaelad3/30/2022
Not yet
Kkaelad3/30/2022
The only other unpublished module I have adds two features onto Convenient Effects: 1. Auto apply Dead, Unconscious, and Wounded status 2. Add a button on item cards to "Add Convenient Effect" if you use a feature that has a matching convenient effect https://github.com/kaelad02/convenient-effects-ext
GitHub
GitHub - kaelad02/convenient-effects-ext: Foundry module that adds ...
Foundry module that adds some extensions to the CE module - GitHub - kaelad02/convenient-effects-ext: Foundry module that adds some extensions to the CE module
ZZhell3/30/2022
I'm told this means we have to duel at noon...? 🤔 I have thought about it... 😬 Definitely just a DM-only script though.
Kkaelad3/30/2022
I immediately started humming this: https://youtu.be/PYI09PMNazw
Cinema Hotel Studios
YouTube
The Ecstasy of Gold - Ennio Morricone ( The Good, the Bad and the U...
"The Ecstasy of Gold" (Italian title "L' Estasi dell'Oro"), is one of the Western compositions that most represent the genius of Ennio Morricone. Composed for the movie: "The Good, The Bad and The Ugly", directed by Sergio Leone, the Western theme simply became one of the most iconic music masterpiece in Cinema's history. The legendary music of ...

Looking for more? Join the community!

Want results from more Discord servers?
Add your server
Recommended Posts
ilthid stop dragActually, would it be possible to modify the core function that allows people to click and drag toke1.6.x mid-milestone update@dnd5e - **No Action Required** Milestone 1.6.0 is 69% Complete (_nice_) <https://gitlab.com/foundPlugin ContributorsI'm very proud to be the maintainer of a module (Export Sheet to PDF) that is getting many, many conmore-hooks-itemroll-hooksFor those of you interested in such things, I have hacked together a way to inject hooks into the mipreHooks5eJSON.stringify jankI discovered that the problem is JSON.stringify, not parselayersTIL about CSS Layers. https://developer.mozilla.org/en-US/docs/Web/CSS/@layer ```css @layer utilitiHitDice hooks MRI just added my first merge request 😄 <https://gitlab.com/foundrynet/dnd5e/-/merge_requests/495>advantage shennaneginsdevmode extension brainstormhttps://github.com/mdn/webextensions-examples/tree/master/devtools-panelsSaving Functions as module settings@wasp I remember you asked about saving functions as settings (which quickly turned into stringifyinnew consumable typesTried adding localization strings for some new consumable types, but keep getting this ("`DND5E.Consspell-compendium-5e alpha1Overriding onDropItem & onSortItemYou'd override them in your sheet class.getter & setter wrapper for settingsI'm trying to use a getter & setter pair as an interface for `game.settings.get` and `game.settings.scrollable tab contentsIt is possible, and you're firmly in the css and DOM structure side of development with this line ofJr devI'm cleaning out my bookmarks and accidentally came back to this article. Potentially useful startinHTCPackage: `hero-creation-tool`System Specific CSSI'm not 100% about this, but it is worth watching out that your solution doesn't actually end up beiadvancement-wip