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

Capture Text For Send To Chat

1746492957
GiGs
Pro
Sheet Author
API Scripter
What's the best way too have a button you click, that then pops up an inputbox: you type some text and it sends that text to the chat? I thought about using custom roll parsing, but that only works for numbers, and I'm wanting to enter text.
1746504848

Edited 1746504868
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Depends on what you're doing. If it's literally just send the text to chat unprocessed, then a basic roll button will do or sending the query in the final startRoll call of a CRP function. If you need to do logic based on what the user enters, then you'll send it via startRoll. You can actually get text, you just have to be slightly tricksy by putting the query inside a roll label (and of course if the user enters a right square bracket, it'll kind of break). Here's what the extractQueryResult function from the K-scaffold looks like (with the scaffold specific syntax edited out): const extractQueryResult = async function(query){ const rollObj = { query:`[[0[response=?{${query}}]]]` }; const msg = `{{query=[[0[response=?{${query}}]]]}}`; const roll = await startRoll(msg); finishRoll(roll.rollId); return roll.results.query.expression.replace(/^.+?response=|\]$/g,''); }; Oosh is the one that originally figured this out.
1746545293

Edited 1746545306
GiGs
Pro
Sheet Author
API Scripter
Thank.s I was overthinking things and a roll button will do for my purposes. Do you have a link to Oosh's original post?
1746549286
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Yep, adventures with startroll
1746559244
GiGs
Pro
Sheet Author
API Scripter
I should have realised it was that thread. Thanks!