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

Character Sheet / Changing Roll Button Values

1550200259

Edited 1550200331
So, having combed through the forums, it looks like what I want to do will either require API or can't be done. I'm trying to set up a character sheet for a custom game I've written. I don't really know HTML, JS, or CSS but that's not a problem. I can figure that out as I go. The problem I'm having is translating the rolling mechanics to Roll20. The game uses dice pools based on skill levels. If you have >0 in a pool after modifiers, you roll regularly. If you have 0, you roll 2 dice and take the lowest (kind of like how Blades in the Dark works). If you have <0, you fail. If anyone has any idea how I could do this, that would be great. I've tried digging through the Blades sheet code but because I don't really know HTML I can't find how it has different rolls depending on if you have 0 or not 0 in a skill.
1550277961
GiGs
Pro
Sheet Author
API Scripter
You cant do that with the standard dice macros available to free users. But with the API, you can do anything. It may be possible to do what you need with the Power Cards API. that's a specific API script that exists for handling complex roll expressions, which has a dedicated thread in the APi forum. If that can't handle it, you can definitely write an API script that can (the API uses javascript).&nbsp; You can also do it like the Bales sheet probable did: by faking it with a rolltemplate. Look for rolltemplate in the bales sheet code. Essentially with a roll template, you set up a macro that does each of the dice results possible, and another value that is used to decide wich to display. So you'd have rollbuttons which include something like (all on one line): value='&amp;{template:myCustomTemplate} {{poolsize=[[whatever calculation is used to determine dice pool size]]}} {{abovezero=[[ your roll without working if &lt; 0 dice ]] }} {{zero=[[{2d6}kh1]] }}' Then you'd create a rolltemplate to interpret this which would include helper logic functions described here:&nbsp; <a href="https://wiki.roll20.net/Roll_Templates#Logic" rel="nofollow">https://wiki.roll20.net/Roll_Templates#Logic</a> . You'd check the value of poolsize to see which calculation to show in chat, like so: {{#rollGreater() poolsize}}&nbsp; &nbsp; &nbsp; &nbsp;Rolled: {{abovezero}} {{/rollGreater() poolsize}} {{#rollTotal() poolsize}}&nbsp; &nbsp; &nbsp; &nbsp;Rolled: {{zero}} {{/rollTotal() poolsize}} {{#rollLess() poolsize}}&nbsp; &nbsp; &nbsp; &nbsp;Rolled: a failure! {{/rollLess() poolsize}}
1550281697

Edited 1550281732
I'd prefer to avoid using the any API script, though since this is my own system it doesn't matter too much. It's not like I expect to release it soon if at all. I'll play around with the roll templates. If I can't get that to work I'll check out Power Cards. Thanks so much!
1550282848
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
What numbers are possible for the dice pools? For instance is it 1 die per skill point?
1550313518

Edited 1550320325
Jakob
Sheet Author
API Scripter
Okay, I can explain how it works with the Blades sheet, it should be straightforward to add an extra case for number of dice &lt; 0. Basically, whenever the number of action dots changes, a sheet worker runs that sets an attribute (let's call it prowl_formula) to the value returned by the buildRollFormula function below. const diceMagic = function (num) { if (num &gt; 0) { return `dice=${ [...Array(num).keys()].map(() =&gt; "[[d6]]").join("&amp;"+"#44"+"; ") }`; } else { return "zerodice=[[d6]]&amp;" + "#44" + "; [[d6]]"; } }; const buildRollFormula = function (base) { return ` {{?{Bonus dice|${ [0, 1, 2, 3, 4, 5, 6, -1, -2, -3].map(n =&gt; `${n},${diceMagic(n + (parseInt(base) || 0))}`).join("|") }}}}`; }; E.g. on("change:prowl", () =&gt; { getAttrs(["prowl"], v =&gt; { setAttrs({ "prowl_formula": buildRollFormula(v["prowl"]) }); }); }); The attribute prowl_formula will then have a built-in query asking for bonus dice from -3 to 6. Depending on what the sum of bonus dice and skill is, the value sent to chat after the user answers the query will be either "{{zerodice=[[d6]], [[d6]]}}" (for &lt;= 0) or something like "{{dice=[[d6]], [[d6]], [[d6]]}}". This part is calculated by the diceMagic function (where you'd have to add extra logic treating 0 and less than 0 differently). Now, the roll button for Prowl just includes the value of the prowl_formula attribute, which is then interpreted by the roll template. The reason to have "dice" and "zerodice" here ist that they both display differently, with some extra text appearing if we send zerodice. The corresponding part in the roll template looks similar to this: {{#dice}}{{dice}}{{/dice}}{{#zerodice}} &lt;div class="zerodice"&gt;{{zerodice}}&lt;/div&gt; &lt;div class="zerodice2" data-i18n="zerodice"&gt;&lt;/div&gt; {{/zerodice}} You could send something like "{{negativedice=1}}" and add some extra logic here that displays "Failure" when that one is sent, instead of dice or zerodice. Extra remarks Since you said that you're not familiar with Javascript or coding for Roll20, I thought I'd explain two things: [...Array(num).keys()].map(() =&gt; "[[d6]]") There's no magic here. This just produces an array with num &nbsp;elements, all of which are the string "[[d6]]" The reason I use "&amp;"+"#44"+"; " all over the place is that this is the HTML code for a comma. This is necessary because commas are syntactically relevant in Roll20 query expressions, so I have to escape them if I want them to be used in the query results.&nbsp;
Scott C. said: What numbers are possible for the dice pools? For instance is it 1 die per skill point? Just 1 die per point Jakob said: -snip- That actually helps a lot, thanks. And the #44 thing was definitely confusing me since it was everywhere and I spent too much time trying to dig through and find what it was referencing.