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

How can I use the result of a Roll Query in a sheet worker script.

Hello I am learning how to create my own character sheets but I am quite new to Java scripts.  My question is how can I get the value of a RollQuery and use it in a Sheet worker sheet.   Example: I have an Atribut defined in my HTML called <dicepool>  And it’s value is  a Roll Query=  ?{number of dice |0} I want to call <dicepool> In my sheet worker script and be able to work with the numeric value I got from the Roll Query.  Is this posible ? And if so how do I script it? What would be the trigger ? Thanks  Jorge 
1566243680

Edited 1566243714
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Unfortunately this is not possible as the sheet can't react to chat messages, it can only send them via roll buttons. For the sheetworkers to work with it, the value has to be stored in an attribute. For this, I'd recommend either a select element (if the possible options are reasonably limited; say no more than 15, and probably less than that) or a text/number input if they are more free form. Then the user can enter the value in this attribute and the sheetworker can use it.
Thanks for he quick response. One more question. Is it posible in the HTML to take the result of the RollQuery an copy it in a new atribute?  The problem is that in the page I am modifying all the Bonuses are asked via RollQuerys that are defined in hidden Atributs. And what I am trying to do is add all this Atributs together to make a dice pool rol But if a add mor than two of this kind of Atributs I get an error so I was trying to add them up via Sheet Worker script.  Is there a way I can Add 4 or 5 of this rollqueary Atributs so that the I can use this result in my pool roll ex:  this is in a button sending it to the Roll template  {{totaldicepoolroll=(@{might_max}+@{might_edge}+@{rollqstasset}+@{rollqstbonus}-@{damage-track})d6!>4}} three of this Atributs have a RollQuery as a Value   
1566245931

Edited 1566246012
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
ah, gotcha, no, you can't store the result of the roll query in the sheet (see explanation above), but you can use multiple attributes and math to calculate how many dice to roll. You just need to wrap the calculation in inline roll brackets: {{totaldicepoolroll= [[ @{might_max}+@{might_edge}+@{rollqstasset}+@{rollqstbonus}-@{damage-track} ]] d6!>4}} Also, unless you want that field to literally just say "Xd6!>4", you'll want to wrap the whole thing in inline roll brackets as well: {{totaldicepoolroll= [[   [[ @{might_max}+@{might_edge}+@{rollqstasset}+@{rollqstbonus}-@{damage-track} ]] d6!>4 ]] }}
1566254023

Edited 1566254152
It worked !!!  I had to use more Brakets around the RollQuery Attributs and Curley Brakets for the exploting dice.  But now it works perfectly Thank you Scott for your help. {{totaldicepoolroll= [[{ [[ @{might_max}+@{might_edge}+[[@{rollqstasset}]]+[[@{rollqstbonus}]]-@{damage-track} ]] d6!}>4 ]] }}