Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

Can you change a general message before it is sent to chat?

I know how to capture the following message: &{template:atkdmg} {{charname=Aurel Dustbrew}} {{rname=Dagger}} {{mod=+3}} {{r1=[[1d20 +3]]}} {{attack=1}} {{damage=1}} {{dmg1flag=1}} {{dmg1=[[1d4]]}} {{dmg1type= Piercing}} {{crit1=Crit: [[1d4]]}} {{normal=1}} What I want to do is tack on a {{desc=...}} section to the message BEFORE it is posted. &{template:atkdmg} {{charname=Aurel Dustbrew}} {{rname=Dagger}} {{mod=+3}} {{r1=[[1d20 +3]]}} {{attack=1}} {{damage=1}} {{dmg1flag=1}} {{dmg1=[[1d4]]}} {{dmg1type= Piercing}} {{crit1=Crit: [[1d4]]}} {{normal=1}}  {{desc=This is the description}} If I just send the desc part to the chat it formats oddly: The call to post (Had to add the &{template:desc} to the front to get it to format ok)             var post = "&{template:desc} {{desc="             if (spellFlag === true) post = post + "Add the [Concentration](!
#Condition-Concentration) Status\n"             post = post + "Click [" + dmgType + "](!rtm Critical-" + dmgType + ") to resolve your critical\n"             if (spellFlag === true)                 post = post + "Click [Fumble](!rtm Critical-Spell-Fumble) if you fumbled\n"             else                 post = post + "Click [Fumble](!rtm Critical-Fumble) if you fumbled"             post = post + "}}"                          if (post.length> 0) sendChat('', post) What I would like to do is replace or add to msg.content before it hits the chat window so I can add the description into the attack template itself.
Try changing the  {{desc=...}} to  {{description=...}} and see if that works. I think the sheet templates were all updated a year or so ago. 
1625582969
timmaugh
Pro
API Scripter
I've done a lot of testing around this as a part of the meta stuff, and while the API can respond to ALL the messages (including basic/standard messages), it can't prevent them from hitting the chat immediately. Think of the API as another player at the table. If there is a general message that everyone at the table is going to see, then the API will see it, too. But by the time the API sees it, so have all the other players. On the other hand, a message directed at the API (with the leading ! ) is like a whisper just to the API. The other players don't see it in the normal chat output. You really have 2 options: a listener script that outputs secondary information (seems like the path you were pursuing), or changing the messages into basic API calls to let processing happen before you output the message again On the second point, you can do what you want (having a single message output where you have injected the information you want to inject) as a meta-script, provided you start the line with an exclamation point. For instance, ZeroFrame could take the line: !&{template:atkdmg} {{charname=Aurel Dustbrew}} {{rname=Dagger}} {{mod=+3}} {{r1=[[1d20 +3]]}} {{attack=1}} {{damage=1}} {{dmg1flag=1}} {{dmg1=[[1d4]]}} {{dmg1type= Piercing}} {{crit1=Crit: [[1d4]]}} {{normal=1}} {&simple} And output: &{template:atkdmg} {{charname=Aurel Dustbrew}} {{rname=Dagger}} {{mod=+3}} {{r1=[[1d20 +3]]}} {{attack=1}} {{damage=1}} {{dmg1flag=1}} {{dmg1=[[1d4]]}} {{dmg1type= Piercing}} {{crit1=Crit: [[1d4]]}} {{normal=1}} In other words, just outputting the message. The point is that since it is an API message, the players don't see it. And since it's an API message, other meta-scripts could act on the message. *Your* meta-script could check if there is a rolltemplate property of the message, and if it contains the name of a template for which you want to provide extra information, your script injects the right data into the command line and reissues the message (including the original template). ZeroFrame also puts the roll popups back into the message, so that might be of use to you, but you could of course do that part yourself, too. If you want to build your script as a plug-in to ZF to take advantage of the existing framework, I can help with that.
Thanks @timmaugh, you basically answered my question.  The original message is being sent by the Beyound 20 extension from DBDBeyond so I can't change that.  Seems I have to just take on a separate message like I am doing.  Thanks all timmaugh said: I've done a lot of testing around this as a part of the meta stuff, and while the API can respond to ALL the messages (including basic/standard messages), it can't prevent them from hitting the chat immediately. Think of the API as another player at the table. If there is a general message that everyone at the table is going to see, then the API will see it, too. But by the time the API sees it, so have all the other players. On the other hand, a message directed at the API (with the leading ! ) is like a whisper just to the API. The other players don't see it in the normal chat output. You really have 2 options: a listener script that outputs secondary information (seems like the path you were pursuing), or changing the messages into basic API calls to let processing happen before you output the message again On the second point, you can do what you want (having a single message output where you have injected the information you want to inject) as a meta-script, provided you start the line with an exclamation point. For instance, ZeroFrame could take the line: !&{template:atkdmg} {{charname=Aurel Dustbrew}} {{rname=Dagger}} {{mod=+3}} {{r1=[[1d20 +3]]}} {{attack=1}} {{damage=1}} {{dmg1flag=1}} {{dmg1=[[1d4]]}} {{dmg1type= Piercing}} {{crit1=Crit: [[1d4]]}} {{normal=1}} {&simple} And output: &{template:atkdmg} {{charname=Aurel Dustbrew}} {{rname=Dagger}} {{mod=+3}} {{r1=[[1d20 +3]]}} {{attack=1}} {{damage=1}} {{dmg1flag=1}} {{dmg1=[[1d4]]}} {{dmg1type= Piercing}} {{crit1=Crit: [[1d4]]}} {{normal=1}} In other words, just outputting the message. The point is that since it is an API message, the players don't see it. And since it's an API message, other meta-scripts could act on the message. *Your* meta-script could check if there is a rolltemplate property of the message, and if it contains the name of a template for which you want to provide extra information, your script injects the right data into the command line and reissues the message (including the original template). ZeroFrame also puts the roll popups back into the message, so that might be of use to you, but you could of course do that part yourself, too. If you want to build your script as a plug-in to ZF to take advantage of the existing framework, I can help with that. Ok thank
Beyond20 has a feature to adjust the rolls before they get sent to chat.  In the configuration menu, click on 'More Options' and look for the section that's highlighted in light blue: Send custom text to the VTT In the "Notes" or "Description" section of any item, action, or spell on the D&D Beyond Character Sheet, you may add your own custom text to be sent to the VTT as a message when you use that element's roll action. To do this, format the text you wish to send as follows: [[msg-type]] Put text you wish to send HERE[[/msg-type]] Replace "msg-type" with one of the following: "before", "after", or "replace" depending on how you want to affect the message or action that would normally be sent to the VTT. I haven't used it myself, but I believe the syntax would be something like this, and you'd put it in the notes field of the weapon attack on D&D Beyond: [[replace]]{{desc=This is the description}}[[/replace]]