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

Sending linebreak/returns in API

1526998438

Edited 1526999222
DXWarlock
Sheet Author
API Scripter
I've ran into a roadblock I cannot seem to get around. Sending any text to API where a carriage return is used only sends the first line. For example on the character sheet I have this block of html (trimmed down to important parts): <fieldset class="repeating_cast">         <button type='roll' value='!cast --@{CASTdesc}' name='roll_CastCheck' /></button>         <textarea class="sheet-casttext" name="attr_CASTdesc"></textarea> </fieldset> The important parts is the button that sends an API command of " !cast --@{CASTdesc}" Where  @{CASTdesc} is the textarea.  And the text area, which could have for example inside it: One Two Three Problem is the API message sent, only sees "One". If I make the textarea on the sheet say: One Two Three It reads it all. Anyone know a fix/workaround for this?
1526999341
The Aaron
Pro
API Scripter
You can surround with {{ }} to use multiple lines.  See TokenMod:             args = msg.content                 .replace(/<br\/>\n/g, ' ')                 .replace(/(\{\{(.*?)\}\})/g," $2 ")                 .split(/\s+--/); In my case, I'm stripping out the newlines, but you could use something like: msg.content.replace(/\s*(\{\{|\}\})\s*/g,' ');
1526999580

Edited 1526999629
DXWarlock
Sheet Author
API Scripter
Surround which part, What I have the sheet sending? I'm assuming that part, as I THINK its already lost before the chat:message sees it. So as such: !cast {{--@{CASTdesc}}}
1526999713
The Aaron
Pro
API Scripter
Yes, exactly.
1526999767
DXWarlock
Sheet Author
API Scripter
I'll try that, I've been throwing html and js at the wall for 2 hours trying to get something to stick. What would we do without you!
1527000588
DXWarlock
Sheet Author
API Scripter
That did exactly what I needed. Go get one virtual beer, on me!
1527000627
The Aaron
Pro
API Scripter
I'm virtually drunk already! =D