consumables chat data
@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.
35 Replies
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.
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?
not actually sure about that
_onChatCardAction
is the start of this logic
https://gitlab.com/foundrynet/dnd5e/-/blob/master/module/item/entity.js#L1368GitLab
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...
innnnteresting
so looks like if there is
itemData
in the flags, it'll prefer that always
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#L745GitLab
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...
Just tried slapping a weapon (toObject()) into the same flag. It works.
veeeerry interesting
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
creating and then deleting the item does feel kinda bad though
(and after refresh as well, just to make sure)
like why cause 3 database updates for something that should take 1
- create weapon
- create chat card
- delete weapon
This could be interesting for magic items with spells. 🤔
for that I honestly think a new preparation mode "item" would solve like all the problems
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?
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'tephemeral?
temporary
i.e. a Document that doesn't exist in the database
Right
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 🙂
@calego gave LeaguePoints™ to @Zhell (#217 • 2)
Something like
ChatMessage.create(msg.toObject())
does work. 🤔 and that's not a lot of data tbh.is
msg
the output of displayCard
?(where
msg
is a message that works...)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:
I wonder just how little data you need to do this.
I'm gonna strip it down until it breaks.
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)Item5e
is undefined, and just Item
doesn't have a displayCard
function. >_>
🥳
Got rid of the footer in a messy way but ehMan, 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.
Lol amazing
Next thing you'll tell me that both of you have made little modules to check if an attack roll his
Not yet
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
I'm told this means we have to duel at noon...? 🤔
I have thought about it... 😬 Definitely just a DM-only script though.
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 ...