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

[Custom Sheet] Rolling macro for non-Fieldset skills rolls calculations

1700023361

Edited 1700023438
Jeremy H.
Pro
Sheet Author
Hello, Been a while since I've posted; I'm attempting to work on a sheet for one of my own systems, and I'm running into a problem implementing rolls for skills. Rolls have three calculations for skills; Rolled Dice (Associated Attribute + Misc.) Keep Dice ((Associated Attribute / 2) + Misc.) Static Bonus (Level + 5 if marked as Trained) My roll button WILL work when interacting with a fieldset version of the skill, but a normal version of the skill. Here are the examples of the two skills (I've also attached the HTML at the end, but be warned I'm trying to edit and improve things as I go, so it may still look rough) Working skill: &lt;h3&gt;Artisan (Repeating)&lt;/h3&gt; &lt;fieldset class="repeating_artisan-s"&gt; &lt;div class="sheet-table-row"&gt; &lt;b&gt;Artisan:&lt;/b&gt; &lt;input type="text" name="attr_ExArtisanS"&gt;&lt;br&gt;&lt;br&gt; &lt;input type="checkbox" name="attr_ArtisanTrainedSmarts" value="5+@{level}"&gt; &lt;input type="number" name="attr_ExArtSrt" value="@{smartsT}+@{ArtSrta}" disabled&gt; k &lt;input type="number" name="attr_ExArtSrtk" value="floor((@{smartsT})/2)+@{ArtSrtb}" min="1" disabled&gt; + &lt;input type="number" name="attr_ExArttr" value="@{ArtisanTrainedSmarts}+@{ArtSrttra}" disabled&gt; &lt;button type="roll" value="/em rolls @{ExArtSrt}k@{ExArtSrtk} with a bonus of @{ExArttr}, for [[@{ExArtSrt}d10?{Reroll this number and below. (Leave blank if none)|r&lt;0}?{Explode this number and above. (Leave blank if none)|!!&gt;11}sk@{ExArtSrtk}+@{ExArttr}]])"&gt;&lt;/button&gt; &lt;br&gt;&lt;b&gt;Miscellaneous Bonuses&lt;/b&gt; &lt;input type="number" name="attr_ArtSrta" value="0"&gt; k &lt;input type="number" name="attr_ArtSrtb" value="0"&gt; + &lt;input type="number" name="attr_ArtSrttra" value="0"&gt; &lt;br&gt;&lt;br&gt; &lt;/div&gt; &lt;/fieldset&gt; Not working skill: &lt;h3&gt;Acrobatics&lt;/h3&gt; &lt;button type="roll" value="/em rolls @{AcroAgi}k@{AcroAgik} with a bonus of @{AcroAGITrained}, for [[@{AcroAgi}d10?{Reroll this number and below. (Leave blank if none)|r&lt;0}?{Explode this number and above. (Leave blank if none)|!!&gt;11}sk@{AcroAgik}+@{AcroAGITrained}]])"&gt;Acrobatics&lt;/button&gt;&lt;br&gt;&lt;br&gt; &lt;input type="checkbox" name="attr_AcrobaticsTrained" value="5+@{level}"&gt; &lt;input type="number" name="attr_AcroAgi" value="@{AgilityT}+@{AcroAGIa}" disabled&gt; k &lt;input type="number" name="attr_AcroAgik" value="floor((@{AgilityT})/2)+@{AcroAGIb}" min="1" disabled&gt; + &lt;input type="number" name="attr_AcroAGITrained" value="@{AcrobaticsTrained}+@{AcroAGItra}-@{ap}" disabled&gt; &lt;br&gt;&lt;b&gt;Miscellaneous Bonuses&lt;/b&gt; &lt;input type="number" name="attr_AcroAGIa" value="0"&gt; k &lt;input type="number" name="attr_AcroAGIb" value="0"&gt; + &lt;input type="number" name="attr_AcroAGItra" value="0"&gt; Is there something I'm missing? Whenever I try to get it to roll, this is the result for the non working variant: Complete source: <a href="https://www.mediafire.com/file/kw6an37jf65q5ds/TheFade3e.html/file" rel="nofollow">https://www.mediafire.com/file/kw6an37jf65q5ds/TheFade3e.html/file</a>
1700024173
GiGs
Pro
Sheet Author
API Scripter
I'm surprised the repeating attributes are working but global ones aren't. It's usually the other way around. Try putting parentheses round every single autocalc attribute. Parentheses are the round brackets you've used in floor(). Just start with every attribute used in the acrobatics roll. Alternatively (far, far more complicated), try to teach yourself how to replace autocalc attributes, which are a legacy system, with sheet workers.
1700024728
Jeremy H.
Pro
Sheet Author
GiGs said: I'm surprised the repeating attributes are working but global ones aren't. It's usually the other way around. Try putting parentheses round every single autocalc attribute. Parentheses are the round brackets you've used in floor(). Just start with every attribute used in the acrobatics roll. Alternatively (far, far more complicated), try to teach yourself how to replace autocalc attributes, which are a legacy system, with sheet workers. Hello, thank you for the quick response! I have actually tried using parentheses, been removing and re-adding them periodically. Getting the same results. Here is the code: &lt;h3&gt;Acrobatics&lt;/h3&gt; &lt;button type="roll" value="/em rolls @{AcroAgi}k@{AcroAgik} with a bonus of @{AcroAGITrained}, for [[(@{AcroAgi})d10?{Reroll this number and below. (Leave blank if none)|r&lt;0}?{Explode this number and above. (Leave blank if none)|!!&gt;11}sk(@{AcroAgik})+(@{AcroAGITrained})]])"&gt;Acrobatics&lt;/button&gt;&lt;br&gt;&lt;br&gt; &lt;input type="checkbox" name="attr_AcrobaticsTrained" value="5+@{level}"&gt; &lt;input type="number" name="attr_AcroAgi" value="(@{AgilityT}+@{AcroAGIa})" disabled&gt; k &lt;input type="number" name="attr_AcroAgik" value="(floor((@{AgilityT})/2)+@{AcroAGIb})" min="1" disabled&gt; + &lt;input type="number" name="attr_AcroAGITrained" value="(@{AcrobaticsTrained}+@{AcroAGItra}-@{ap})" disabled&gt; &lt;br&gt;&lt;b&gt;Miscellaneous Bonuses&lt;/b&gt; &lt;input type="number" name="attr_AcroAGIa" value="0"&gt; k &lt;input type="number" name="attr_AcroAGIb" value="0"&gt; + &lt;input type="number" name="attr_AcroAGItra" value="0"&gt; Here is the result: Is there anything else I might be missing? I can look into sheet workers, but if I can help it I'd like to avoid rewriting large parts of the sheet. It really is only the attempts at rolling which fail to work in this manner.
1700024963
GiGs
Pro
Sheet Author
API Scripter
That screenshot definotely indicates there is a parenthesis problem (possibly more than one) somewhere. You can't do any harm by adding them, so there's no reason to ever remove them. You have this: &lt;input type="number" name="attr_AcroAgi" value="(@{AgilityT}+@{AcroAGIa})" disabled&gt; k What about the AgilityT and AcroAGIa attributes? And every attribute that is involved in their calculation?
1700025127

Edited 1700025183
GiGs
Pro
Sheet Author
API Scripter
An alternate interpretation: the attributes are partly being treated as text, and not autocalc attributes, and I can't think off my head why that would be happening. Are the attribute values higher than 1 and 0, and are they higher values outside of the roll? Also please post your screenshots as text, because commenters cant pick parts out of them and reply using them.
1700026001
GiGs
Pro
Sheet Author
API Scripter
I think I may be beginning to get an inkling of the issue. You might need to make more use of inline roll brackets (pairs of square brackets): [[ ]]) in the roll button. Can you show what the output should look like when the button is pressed?
1700026232
Jeremy H.
Pro
Sheet Author
GiGs said: An alternate interpretation: the attributes are partly being treated as text, and not autocalc attributes, and I can't think off my head why that would be happening. Are the attribute values higher than 1 and 0, and are they higher values outside of the roll? Also please post your screenshots as text, because commenters cant pick parts out of them and reply using them. Apologies on that last bit. Either way - That was my thought at first too was that it's treating it as text. I did some tests to see if you can roll @{AcroAgi}d10 and you can, but only if you put parentheses around them, for example: (@{AcroAGi})d10, this same idea did not work when you have the formula after the "floor(" As for AgilityT and AcroAGIa, the latter is listed in there (it's the first miscellaneous bonus). As for AgilityT, I noticed in the attribute's name it's not capitalized, for example here's the Agility section of the sheet where AgilityT is coming from. &lt;b&gt;Agility&lt;/b&gt;: &lt;input type="number" name="attr_agility" value="1" min="0"&gt; + &lt;b&gt;Temp&lt;/b&gt;: &lt;input title="AGI Number" type="number" name="attr_agilityN" value="0" min="0"&gt; &lt;b&gt;Total&lt;/b&gt;: &lt;input title="AGI TOTAL" type="number" name="attr_agilityT" value="(@{agility}+@{agilityN})" disabled&gt;&lt;br&gt;&lt;br&gt; So, I changed it in the Acrobatics skill roll, but unfortunately no luck. As a sidenote, I attempted to roll it through the regular /roll command instead of the [[]] brackets, referencing the attributes within the sheet as follows: /roll @{Character1|AcroAgi}d10sk@{Character1|AcroAgik} This is the result; rolling ((1+0)+0)d10sk(floor(((1+0))/2)+1) ((1+0)+0) =1
1700026549
Jeremy H.
Pro
Sheet Author
GiGs said: I think I may be beginning to get an inkling of the issue. You might need to make more use of inline roll brackets (pairs of square brackets): [[ ]]) in the roll button. Can you show what the output should look like when the button is pressed? Here's what the working versions look like when pressed (including screenshot and copy/paste of result and how the roll function is written just for completeness sake): Screenshot:&nbsp; Result:&nbsp; Jeremy H. (GM) rolls 1k1 with a bonus of 6, for 8) Roll Formula:&nbsp; [[@{ExArtSrt}d10?{Reroll this number and below. (Leave blank if none)|r&lt;0}?{Explode this number and above. (Leave blank if none)|!!&gt;11}sk@{ExArtSrtk}+@{ExArttr}]]
1700075826
GiGs
Pro
Sheet Author
API Scripter
In the original screenshot, are the numbers being displayed accurate:
1700077394
Jeremy H.
Pro
Sheet Author
GiGs said: In the original screenshot, are the numbers being displayed accurate: Yes, the numbers are all accurate. And in other places where auto-calculation is used (ex. the Defenses section) it works correctly too. After beating my head on this for a bit, I ended up biting the bullet and just refactored everything to use Sheet Workers - it works now and the "minimum" actually works now, albeit in the JavaScript for some reason Math.min() and Math.max() work in reverse. Not really questioning it since it works!
1700078753
GiGs
Pro
Sheet Author
API Scripter
I'm glad you switched to sheet workers. They are superior in many ways, but generally harder to write (maybe not in this case though). I'm curious about min and max returning the opposite. Though I have sometimes thought they are the opposite of what I wanted, using them can be a bit mindbending at times.