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

Help with dice roll macros for Black Star (count 1s, 2s, 5s, 6s from a summed set of xd6)

1738722245

Edited 1738722290
Rich McNutt
KS Backer
I am trying to set up a game of Black Star, an indie space opera system. The core system uses 2d6 + modifer (an ability) with Bonus or Penalty dice. If you have bonus dice, then you take the 2 highest dice. If you have penalty dice, you take the two lowest dice. I have the syntax worked out how to roll off a character token. This is if the PC has bonus dice. &{template:default} {{name=Bonus Blasting}}{{Roll=[[{?{Number of dice rolled|0}d6+2d6}k2+@{selected|Blasting}]]}} This is for penalty dice &{template:default} {{name=Penalty Blasting}}{{Roll=[[{?{Number of dice rolled|0}d6+2d6}kl2+@{selected|Blasting}]]}} If no bonus or penalty, either works, the player just chooses 0. The system is entirely player facing, so players roll to defend against enemy attacks. When a player attacks, they deal additional damage equal to the number of 5s and 6s rolled. When defending, they suffer additional damage equal to the number of 1s and 2s rolled on the dice.  I am trying to figure out how to get roll20 to count and display the number of 1s and 2s, as well as 5s and 6s, on every roll so we don't have to hover over the dice and count manually. That is my main ask, if anyone has thoughts or advice. I do have a pro account, so API scripts are available to me. For a bonus, it would be amazing if I could figure out how to have the macro query bonus vs penalty dice. Right now I plan to use two different abilitiy mules to story the macros for the ability rolls. The player would choose to roll the bonus or penalty macro. Thanks in advance for any help!
This is a tricky one, because you're trying to get two separate outputs from a single roll. The parser only allows each roll to be iterated on once. But, what we can do is one of my favorite tricks - splitting dice. For any die that wasn't a 5 or 6, there's a 50% chance it's a 1 or a 2 - so we don't have to care about the d6 rolls beyond the 5s and 6s, we'll just roll the rest again as d4s. But, the bonus/penalty dice complicate things. I'll need to think about that for a bit, but if I figure it out, I'll get back to you.
1738727534
Gauss
Forum Champion
Scriptcards should be able to take care of this. I'll ping the folks that might be able to help.
1738774758
timmaugh
Forum Champion
API Scripter
This is pretty straightforward with the Metascript Toolbox installed... Plugger (one of the metascripts in the toolbox) has a function for getDiceByVal, which would get the dice from a given roll that satisfied certain requirements (like being <= 2), and presenting them in a handful of different ways (counting them, listing them, etc.). So the simplest rewrite of the above "Bonus Blast" macro would be something like: !&{template:default} {{name=Bonus Blasting}}{{Roll=[[{?{Number of dice rolled|0}d6+2d6}k2+@{selected|Blasting}]]}} {{All Dice={&eval}getDiceByVal(--$[[0]] -->0 --all --list|" "){&/eval} }}{{Low=**{&eval}getDiceByVal($[[0]] <=2 all count){&/eval}**}} {{High=**{&eval}getDiceByVal($[[0]] >=5 all count){&/eval}** }} {&simple} That might produce something like: This would represent the Roll line as ALREADY having applied the "keep high 2" mechanic (more on that in a minute), and it would show all of the dice as they were rolled, as well as a line presenting the total of all of the <=2 dice (the "Low" line) and all of the >=5 dice (the "High" line). Incidentally, you can get that "All Dice" line sorted if you sorted your initial roll, but I'll leave that up to you since that wasn't a parameter of your original ask. ...but if you leave the camera rolling... You could combine the Bonus/Penalty versions of the macro into a single command if you didn't mind having all of the information presented. The benefit is that you'd cut the number of macros you have to maintain in half. That would look like: !&{template:default} {{name=Blasting}}[[?{Number of dice rolled|0}d6+2d6+@{selected|Blasting}]]{{Base Roll=({&eval})getDiceByVal(--$[[0]] -->0 --all --list|" ")({&/eval})}} {{Bonus Result= {&r}{({&eval})getDiceByVal(--$[[0]] -->0 --all --list|,)({&/eval})}k2{&/r} }} {{Penalty Result= {&r}{({&eval})getDiceByVal(--$[[0]] -->0 --all --list|,)({&/eval})}kl2{&/r} }} {{Low=**{&eval}getDiceByVal($[[0]] <=2 all count){&/eval}**}} {{High=**{&eval}getDiceByVal($[[0]] >=5 all count){&/eval}** }} {&simple} This would produce something like: Here, we present the set of all dice in the "Base Roll" field, so that our ACTUAL results (of the keep-high-2 and keep-low-2 mechanics of the Bonus/Penalty framework) in the "Bonus Result" and "Penalty Result" lines. The player would have to apply the correct result based on the situation -- do they have Bonus dice? Or do they have Penalty dice? This version preserves the count of Low/High dice, as well. ...but if you leave the camera rolling... In the above version, you're still having to maintain at least 1 command macro for each modifier skill/attribute/whatever this system calls the modifiers. If you're fine maintaining that number of macros and/or you intend to display the options as a chat menu , you can stop here. But if you wanted to get this down to a single command, you could use other metascripts to make the player choose the attribute. The downside of this is that you'd have to employ a query, and not everyone wants to answer a question every time they want to make a roll. Not to mention you are already prompting them for the number of extra dice to roll. So there's definitely a tradeoff. Also, you could do this already with a query for the modifier, but that would force you (the command designer) to rename the template output so that it could no longer say "Blasting" or "Astral Carp Tossing" for those individual modifier/actions. Instead, it would have to say something generic for all outputs. Like: "Output" But, if you wanted to pursue the idea, the Toolbox offers a way to use a single query (which you'd already be introducing with a generically titled template output) for multiple different implementations -- like using it in one place to retrieve the numeric modifier for the roll, but in another for populating the title of the template with the textual name of the modifier (i.e., "Blasting"). This, too, is beyond the scope of your original ask, so I won't go into the details of working that one up, but I can show it if it is something you'd be interested in.
Thanks everyone for the help! Too late and too tired to give this a proper read tonight, but I am going to check it out tomorrow hopefully. Thanks again!
It's good that you got a working solution from scripts, because while I got the 1s, 2s, 5s and 6s out, I realized that I have no way of getting the sum out too with just macros - single in, single out is the rule of the parser and getting around it is very difficult. On the other hand, for anyone who does want an easier readout without scripts, [[{(?{Number of dice rolled}+2)d6sdcf<2cs>5}kh2+ @{selected|Blasting} ]] gives you the highlights for the highs and lows, and sorts the hover over results in descending order.
I'm using a chat menu, so the second option worked perfect! Thank you so much! 
I just wanted to post this for anyone else that may find this helpful, the second formulation that shows both the bonus and penalty result was not actually perfectly correct. The @{selected|Blasting} portion needed to be moved after the part of the formula that indicated k2 and kl2. When it was in the first line, as in, !&{template:default} {{name=Blasting}}[[?{Number of dice rolled|0}d6+2d6+@{selected|Blasting}]], it wasn't actually adding the attribute. The below formulation fixes the issue. !&{template:default} {{name=Blasting}}[[?{Number of dice rolled|0}d6+2d6]]{{Base Roll=({&eval})getDiceByVal(--$[[0]] -->0 --all --list|" ")({&/eval})}} {{Bonus Result= {&r}{({&eval})getDiceByVal(--$[[0]] -->0 --all --list|,)({&/eval})}k2+@{selected|Blasting}{&/r} }} {{Penalty Result= {&r}{({&eval})getDiceByVal(--$[[0]] -->0 --all --list|,)({&/eval})}kl2+@{selected|Blasting}{&/r} }} {{Low=**{&eval}getDiceByVal($[[0]] <=2 all count){&/eval}**}} {{High=**{&eval}getDiceByVal($[[0]] >=5 all count){&/eval}** }} {&simple} Thanks again for all the help!
1738986067
timmaugh
Forum Champion
API Scripter
Ah! Good catch!