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

Dice roller for custom character sheet

Hey guys. I'm trying to create my first custom character sheet and the layout part was quite simple, however, now I'm stuck with the dice roller. In this form, all tests are made using only d6 and adding the result to the value of one of the three attributes that was tested (power, skill and resistance). I've already managed to do this, creating a button for each attribute, which scrolls and then adds its value. <script type="text/worker">     on("clicked:rolld6", function(r){             let dado = r.htmlAttributes.value.split('-')[0];         let atributo = r.htmlAttributes.value.split('-')[1];         getAttrs(["charactername", atributo], function(v){              startRoll(`&{template:default} {{name=${v.charactername}}} {{Resultado=[[${dado}+${v[atributo]}]]}}`, diceroll => {                 console.log({diceroll})                 const dice = diceroll.results.roll.dice;                 const rolls = dice.join(' + ');                 const successes = dice.filter(d => d == 6);                 const sum_dice = dice.reduce((partialSum, a) => parseInt(partialSum) + parseInt(a), 0) + parseInt(v[atributo]);                 const critical = (successes.length * parseInt(v[atributo]));                 const result = parseInt(sum_dice) + parseInt(critical);                 console.log(dice, rolls, successes)                 finishRoll(diceroll.rollId,{                     resultroll: result                 });             });                 });     }); </script> Problem 1: Depending on the situation, the player may have the option to roll up to 3d6 in a single test. With that in mind, I tried to solve it with three Radio buttons, one with each amount of dice and this way, the player would only choose one of them before clicking on the attribute button to be rolled. Problem 2: In this system, you can roll a critical value on each of the dice you roll, which will add the value of the tested attribute an additional time for each critical rolled. To solve this, I created a field with the critical value starting at 6, but free for the user to change. Note: Outside of Roll20, it works perfectly, but when I try to adapt it inside the form, it doesn't work. Could someone give me a light?
1714182196

Edited 1714192790
GiGs
Pro
Sheet Author
API Scripter
Firstly, never test anything for roll20 outsiode of roll20. There are differences in the way characters work from standard web design that guarantee it won't work. Secondly, is there a reason you are using custom roll parsing? For simple rolls, a roll button is way easier. If you do need to use custom roll parsing, check put his guide: <a href="https://cybersphere.me/guide-to-custom-roll-parsing/" rel="nofollow">https://cybersphere.me/guide-to-custom-roll-parsing/</a>
Thank you for the answer and in fact, I didn't really want to do a test, outside of Roll20. I'm resuming my studies in programming to get back to working in this area and one of the test projects I decided to create was a plug for this system I play here in Brazil, 3DeT Victory. <a href="https://brunolombardidev.github.io/rpg_ficha_3det/" rel="nofollow">https://brunolombardidev.github.io/rpg_ficha_3det/</a> When I finished assembling it, I thought about adapting a version of it to Roll20, as the one we currently have is very simplified. In fact, I'm using her code as a basis to create this new one. <a href="https://github.com/Roll20/roll20-character-sheets/tree/master/3DeT_VICTORY" rel="nofollow">https://github.com/Roll20/roll20-character-sheets/tree/master/3DeT_VICTORY</a> As I had never tried to do anything in Roll20, besides macros, I started reading the materials I could find, while trying to adapt the original code to work in Roll20. I'll take a look at the link you provided, but would you have any tips on how I could solve these problems with a simple scroll button? I admit that I have a habit of complicating things, but I didn't want to put three buttons on each attribute, you know?
1714246046

Edited 1714246189
GiGs
Pro
Sheet Author
API Scripter
You can use a query asking for how many dice to roll as part of the roll. I generally don't provide help to people looking for "proofs of concept" - only to help people facing actual problems they are experiencing.&nbsp; Proofs of concept tend to expand in unpredictable ways and may not have an actual solution, so they can be an unending pit which assuming the people helping have infinite time - best to hire someone to answer your questions there or teach you what you want to learn. I'm not seeing why you need to use CRP here, when a roll button looks like a perfectly valid alternative (and much, much simpler to create).