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

List dices values

1620383668
Divers
Pro
Sheet Author
I am trying to get dice values, with no calculations. How to do it ? My GM has a complicated home rule (I don't want to explain it here, nor to explain why it is important fo him) ;-) So, I don't want the chat to show the sum, or the critical hits, or anything, I just want to show the dice values raw. Like /roll 3d6[raw] => the chat shows "rolling 3d6 = 1, 6, 4"
1620384520
Ziechael
Forum Champion
Sheet Author
API Scripter
Something like: &{template:default} {{name=Raw Roll}} [[ [[1d6]] [[1d6]] [[1d6]] ]] {{Rolling 3d6=$[[0]], $[[1]], $[[2]]}}
1620384732
Ziechael
Forum Champion
Sheet Author
API Scripter
Variable quantities of d6s would be more of a hassle but still doable, you could also remove roll highlighting if that was required.
1620391567
Divers
Pro
Sheet Author
Thanks Zichael ! Actually 3d6 was an example, I don't know by advance how many dices. The number of dices is a variable of my character sheet
1620391605
Divers
Pro
Sheet Author
So I guess it is more of a hassle ;-)
1620395223
The Aaron
Roll20 Production Team
API Scripter
This is always for a chat command you're running, not for a character sheet button?  Does your GM have a Pro subscription?  I think the API is the only way to get this done dynamically.
1620397111
Divers
Pro
Sheet Author
Thanks The Aaron, I am creating the whole custom character sheet (Pro subscription). Once the GM will have tried it, I think he will get a Pro subscription. How can I do it with an API ? (I haven't scripted any APIs yet)
1620397332

Edited 1620397362
Divers
Pro
Sheet Author
At least, it would be ok to have the sum after the list of the values. Like in the chat /roll 3d6, shows it but [[2d6]] doesnt. But, /roll @{diceNumber}d6 doesn't work in the character sheet where  [[@{diceNumber}d6]] works.
1620397834
Finderski
Pro
Sheet Author
Compendium Curator
You could set that up using a sheet worker.  When the value changes that would alter the number of dice, the sheet worker updates the value for the button (probably would need to have a hidden input that equals the actual stuff you want to send, and then the button's value is set to be that hidden input. For example: <input type='hidden' name='attr_attRollValue' value=' &{template:default} {{name=Raw Roll}} [[ [[1d6]] [[1d6]] [[1d6]] ]] {{Rolling 3d6=$[[0]], $[[1]], $[[2]]}}' <button type='roll' name='roll_attRoll' value='@{attRllValue}'></button> The sheet worker would just update that hidden input with the appropriate number d6 rolls.
1620404394
Divers
Pro
Sheet Author
Thanks Finderski, but unfortunaltelyI don't understand how to implement your solution. I would appreciate some help on how to (wether one or the other of the three) : 1- implemete the worker to get the right number of dices 2- get my hands on the API solution, for my firsts steps on it 3- insert "/roll @{dicenumber}d6" instead of "[[@{dicenumder}d6]] thanks a lot !!
1620408585
Finderski
Pro
Sheet Author
Compendium Curator
Here's an example of how to get this to work with the sheet worker: <input type="number" name="attr_dicenumber" value="1"/> <input type="hidden" name="attr_attRollValue" value="&{template:default} {{name=Raw Roll}} [[ [[1d6]] ]] {{Rolling 1d6=$[[0]]}}"/> <button type="roll" name="roll_attRoll" value="@{attRollValue}"></button> <script type="text/worker"> on("change:dicenumber", function(eventInfo){ let numberOfDice = parseInt(eventInfo.newValue) || 1; let valueString = "&{template:default} {{name=Raw Roll}} [[ "; console.log("number of dice: " + numberOfDice); let rollString = `{{Rolling ${numberOfDice}d6=`; console.log("rollString: " + rollString); for (let i = 0; i < numberOfDice; i++) { valueString += "[[1d6]] "; i < numberOfDice -1 ? rollString += "$[["+i+"]]," : rollString += "$[["+i+"]]"; } rollString += "}}"; valueString += "]] " + rollString; setAttrs({attRollValue: valueString}); }); </script> I hope this helps.
1620409057
Divers
Pro
Sheet Author
Wow ! Thanks a lot ! I will try toi understand this and get back to you with another Thanks a lot! or with a question ;-)
1620410667
Divers
Pro
Sheet Author
AWESOME ! It works ! you're a genious :-)
1620411847
Finderski
Pro
Sheet Author
Compendium Curator
Not sure about that, but I do have some experience with character sheets. :) I'm glad it worked for you.
1620414270
Divers
Pro
Sheet Author
May I... well... ask some more ? ;-) I am struggling with my own roll template. 'cause I don't fully understand your script. Here is the template : <rolltemplate class="sheet-rolltemplate-myGMsGame">   <table>     <tr>       <th colspan="2"> {{name}}  </th>     </tr>     <tr>       <td colspan="2"> Roll <b>{{numberOfDice}}d6 </td>     </tr>     <tr>         <td align="right"><b>result : </b></td>         <td>             {{myRoll}}         </td>     </tr>     </table> </rolltemplate>
1620417199
Finderski
Pro
Sheet Author
Compendium Curator
Essentially, you'd change the script to this: <input type="hidden" name="attr_attRollValue" value="&{template:myGMsGame} {{name=Raw Roll}} {{numberOfDice=@{dicenumber}}} [[ [[1d6]] ]] {{myRoll=$[[0]]}}" /> <script type="text/worker"> //Look for a change in the dicenumber on("change:dicenumber", function(eventInfo){ //Get the Number of dice and make it an integer (instead of a text string) let numberOfDice = parseInt(eventInfo.newValue) || 1; //Construct the first part of the roll template call let valueString = "&{template:myGMsGame} {{name=Raw Roll}} {{numberOfDice=@{dicenumber}}} [[ "; //Construct the first part of the myRoll section for the results. let rollString = `{{myRoll=`; //Start the loop to add [[1d6]] between the roll template calls, this for (let i = 0; i < numberOfDice; i++) { valueString +="[[1d6]] " ; //If the number of dice -1 is less than the current loop iteration, the add a comma after the $[[#]] i < numberOfDice -1 ? rollString +="$[[" +i+ "]]," : rollString +="$[[" +i+ "]]"; } //Close out the myRoll template call rollString +="}}" ; //Put the two strings together, so you have complete roll button value call valueString +="]] " + rollString; //Set the hidden field equal to the complete string setAttrs({attRollValue: valueString}); }); </script> You're just having to replace the roll template pieces with yours and then construct them in the sheet worker. I think that should work...it worked for me, anyway. 😀 I also added some comments in the sheet worker to clarify what each thing is doing.
1620421906
Divers
Pro
Sheet Author
thank you for this comments !! I managed to make it work with my one sheet. Thanks a lot again !! My first testers enjoy it !! (I cite you)
1620475790
David M.
Pro
API Scripter
I know you've already got this working, but since you have a Pro sub I figured I'd toss out a quick scriptcards api solution. You mentioned complicated house rules - scriptcards can support pretty involved conditional logic, etc., as it is a sort of light procedural language that doesn't require compiling additional js code. So, you may be able to fully incorporate your GM's dice mechanics into a more comprehensive solution. There is definitely a syntax learning curve, but the script thread is full of people willing to help out! Here's a simple(-ish) annotated scriptcard for rolling and displaying a variable number of dice: !scriptcard {{ --:INITIALIZE VARIABLES| --=numDice|?{How many dice?|1} --=dieSize|?{What type?|d4,4|d6,6|d8,8|d10,10|d12,12|d20,20|d100,100} --=&diceOutput| --=i|0 --:TITLE CONTENT| --#title|Dynamic Dice Rolling Example --#leftsub|Rolling [$numDice]d[$dieSize] --:LOOP THROUGH NUMDICE, CALLING THE ROLLDIE PROCEDURE AND PASSING DIESIZE AS PARAMETER| --:Loop| -->RollDie|[$dieSize] --=i|[$i]+1 --?[$i] -lt [$numDice]|Loop --+Rolls|[&diceOutput] --X| End Macro --:PROCEDURES| --:RollDie| accepts dieSize as the first and only parameter --:ROLL ONE DIE OF TYPE DIESIZE| --=thisRoll|1d[%1%] --:APPEND THE FORMATTED DIE ROLL TO THE OUTPUT STRING| --&diceOutput|+[$thisRoll] --<| }}
1620564150
Divers
Pro
Sheet Author
Hi David, Wow, That's a great alternative solution. I will code it as well, in order to improve my skills ! Thanks !
1623769073
Divers
Pro
Sheet Author
I implemented the solution from Finderski. With the sheet worker. (It's french : Lance means Rolls, Résultat means Result) ;-) But now I would like to show the matching dices. And next to this show the sum of the dices. My GM has no Pro subscription. And, thanks to all of you, the Character sheet is published. So I would avoid a API solution. Do you think this would be possible ?