PDA

View Full Version : How to attach Information to a roll in Chat



Weltenbrand
January 20th, 2021, 16:06
Hi,

I want to attach information (a string) to the result of a roll when the roll action is started.
To be more precise I want something which passes through the
ActionsManager.performAction command and can then be accessed in the dragobject when the result is dragged out of chat.

Is it possible to attach widgets to the chat representation of the roll based on this information?

I hope something likes this is possible.

Best Regards

Trenloe
January 20th, 2021, 17:12
See post #3 here: https://www.fantasygrounds.com/forums/showthread.php?35531-Coding-dice-rolls-(actions)-in-CoreRPG

Weltenbrand
January 20th, 2021, 17:31
You mean Initiating an action?

I don't see how this translates to my question. Could you be more precise?

superteddy57
January 20th, 2021, 17:36
What that guide shows you is how the roll system is built and can be manipulated. You will have to understand this system first to be able to add the chat output you are looking to add. Once it's outputting to chat, then the output can be dragged from the chat and dropped. This however, then will lead down a whole other system. So what I am getting at is it's not a simple step by step answer to your question. Will require learning a bit more of how things work first.

Weltenbrand
January 20th, 2021, 18:07
I have the rolls and the resulthandler working.

Maybe it is not clear what I am asking.
43046
The roll result in chat has the attached dragdata.
I would like to add something e.g. in the custom entry or add a extra slot to this dragobject.
And this something should be added to the rRoll which is given to ActionsManager.performAction (or be added in the resulthandler).
So far I can get strings from the the rRoll which is passed to performAction throught to the resulthandler, but the dragdata from the chat message does not contain this information.

Trenloe
January 20th, 2021, 19:00
The post I referenced has a link to the FG dragdata object: https://www.fantasygrounds.com/refdoc/dragdata.xcp

Does the details on the dragdata object help?

superteddy57
January 20th, 2021, 19:05
Also, the dragdata changes from the chat as a seperate object as well. Here is an example of an attack chat output and it's dragdata

43048

Trenloe
January 20th, 2021, 19:19
Ah, sorry - I was misunderstanding what you were referring to.

You can't really do what you're asking. You're pretty much limited to the description text, the dice values, the action type, and a few other things. Basically what was added to the message data structure before being sent to the chat window using Comm.deliverChatMessage.

Details on the message data structure here: https://fantasygroundsunity.atlassian.net/wiki/spaces/FGCP/pages/996644567/Comm

Which is limited. That's why FG actions tend to pass data using values in the description - standard practice to to enclose these in square bracks [ ... ]. You can see this in the example superteddy57 provides above - [ATTACK{M)] and [vs. KAC] - making the attack type and target AC type available if the attack roll is dragged from the chat window.

I mention this in post #2 of the thread I linked to: "Note that the way modRoll gets which ability to use appears somewhat strange at first glance. It parses it out of the roll description using local sAbility = string.match(rRoll.sDesc, "%[ABILITY%] (%w+) check"); It isn't passed as a parameter in rRoll. This is pretty standard practice in FG rulesets - it allows data to be passed asynchronously and also allows the roll to keep it's data well after the roll has finished (so that the result can be drag/dropped from the chat window, for example). The data is usually identified by a keyword in square brackets [] - you've probably seen this a few times in FG roll results in the chat window."

Weltenbrand
January 21st, 2021, 10:24
Ok thank you. Sorry for the confusion.

Yes I am aware of the version where the information is embedded in the message text (which I wanted to avoid since it clutters the message).