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

User Input in StartRoll Function

Hey, I have a quick question.

I am using custom roll parsing with startRoll and finishRoll.

Everythings working as wanted, however I need the user to set a difficulty class.

startRoll(`&{template:test} {{name=Test}} {{roll1=[[${strength}d6]]}}`, (results) => {

Is it possible to get the user input like this in startRoll?

/roll 1d20 + ?{Bonus1} vs ?{MinToSucceed} + ?{Bonus1}
September 28 (1 year ago)

Edited September 28 (1 year ago)
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator

You can use roll queries as normal, and you can access the result of the roll query in your js if you put it in its own roll template field:

startRoll(`&{template:test} {{name=Test}} {{roll1=[[${strength}d6]]}} {{difficulty=[[?{Difficulty|0}]]}}`, (results) => {
    console.log(results.results.difficulty.result); // => the user entered difficulty
});

EDIT: Had the wrong object reference for results. Fixed this.