LOEFD
Join Serverconsumables chat data
@Zhell
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.
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.
But since consumables have the "Destroy when empty" logic built in, they have the special handling built in.
Message Not Public
Sign In & Join Server To View
not actually sure about that
_onChatCardAction
is the start of this logic
https://gitlab.com/foundrynet/dnd5e/-/blob/master/module/item/entity.js#L1368
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);
So in my wee concentration module, I could not use
Think so. the
https://gitlab.com/foundrynet/dnd5e/-/blob/master/module/item/entity.js#L745
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
Message Not Public
Sign In & Join Server To View
veeeerry interesting
Message Not Public
Sign In & Join Server To View
creating and then deleting the item does feel kinda bad though
Message Not Public
Sign In & Join Server To View
like why cause 3 database updates for something that should take 1
- create weapon
- create chat card
- delete weapon
- create weapon
- create chat card
- delete weapon
Message Not Public
Sign In & Join Server To View
for that I honestly think a new preparation mode "item" would solve like all the problems
Message Not Public
Sign In & Join Server To View
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 itemI remember
Item5e#roll
had issues with rolling an ephemeral item, but displayCard didn'tMessage Not Public
Sign In & Join Server To View
temporary
i.e. a Document that doesn't exist in the database
Message Not Public
Sign In & Join Server To View
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 🙂
thanks @Zhell 🙂
@Calego (ElfFriend) gave
LeaguePoints™ to @Zhell (#217 • 2)

Message Not Public
Sign In & Join Server To View
is
msg
the output of displayCard
?Message Not Public
Sign In & Join Server To View
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);
2 Messages Not Public
Sign In & Join Server To View
I think it depends on the action present, refer to the
_onChatCardAction
method in Item5efor 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)5 Messages Not Public
Sign In & Join Server To View
Lol amazing
Next thing you'll tell me that both of you have made little modules to check if an attack roll his
5 Messages Not Public
Sign In & Join Server To View