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

Show Succesful AND Failed Rolls

I'm looking to create a a macro that will roll (x)d6 and will show >(x) as successful, but I also need to know how many (if any) of those rolls are 1's. These 1's will lead to a seperate roll calculation. I know by hovering over the result, I will see if any 1's were rolled, (and I guess I'm being very pendantic) but I would rather have a way of knowing built into the roll/template.  Heres my code currently: &{template:atkdmg} {{rname=Plasma Pistol}} {{range=12 inch}} {{damage=1}} {{dmg1flag=1}} {{dmg1flag=1}} {{dmg1=[[?{how many shots}d6>[[7-?{BS}]]]]}} {{dmg2flag=1}} {{dmg1type=Str 7, AP 4}} {{dmg2=[Gets Hot](!
#Gets-Hot}} {{spelldesc_link=[To Wound](!
#To-Wound)}} What I'm trying to achieve is for the "Gets Hot" message within dmg2 to ONLY appear IF any of the rolls are a 1. Would be super awesome to include the amount of 1's rolled, but one step at a time.
1680540478
timmaugh
Forum Champion
API Scripter
Welcome to MetaScript Air, I'll be your captain for this flight... =D Short of a RainbowEncoder trick to structure your rolls to show you the failures, there isn't a built-in way to show the failures and the successes. Nor is there a built-in way to run a conditional output based on that number (conditionals in general are very limited to a handful of math tricks at best). But you can do both of those things with a couple of metascripts. You can get the 1s from a given roll by using a Plugger getDiceByVal() statement: {&eval}getDiceByVal($[[1]] 1 all total){&/eval} Then you can use that in an APILogic conditional check do see if the value is at least 1, and include the button if it is (btw, I think you left a closing parentheses off your button syntax): {{dmg2={&if {&eval}getDiceByVal($[[1]] 1 all total){&/eval} >= 1}[Gets Hot](!
#Gets-Hot )}} In order to make the metascripts work, however, we have to start the message with a bang (!), and then we have to include a {&simple} somewhere in the line (somewhere that survives conditional inclusion -- eg, don't put it in a conditional unless you conditionally want to sometimes output a simple message vs. sometimes let the message continue on to the script moderator). The final version of your line would look more like: !&{template:atkdmg} {{rname=Plasma Pistol}} {{range=12 inch}} {{damage=1}} {{dmg1flag=1}} {{dmg1flag=1}} {{dmg1=[[?{how many shots}d6>[[7-?{BS}]]]]}} {{dmg2flag=1}} {{dmg1type=Str 7, AP 4}} {{dmg2={&if {&eval}getDiceByVal($[[1]] 1 all total){&/eval} >= 1}[Gets Hot](!
#Gets-Hot )}} {{spelldesc_link=[To Wound](!
#To-Wound)}} {&simple} One other thing... if the button doesn't seem to want to work, I would look at retrieving it later. Currently, you're getting it with Roll20 syntax, so it gets returned immediately (before the metascripts get involved). If that turns into a problem, you can use an escaped version (a ZeroFrame construction): #^Gets-Hot ...where later in your line (out by the {&simple}) you include an escape construction: {&escape ^}
As Tim says there is no in-built way to show the failures and successes separately from a single roll. However a statistically equivalent approach is to count the successes then reroll all the failures (such that they remain failures) where you can then count the 1's from that new roll.   As for conditionally showing the "Gets Hot" message that can be done with a variant of template overwriting . Ultimately leading to the macro &{template:atkdmg} {{rname=Plasma Pistol}} {{range=12 inch}} {{damage=1}} {{dmg1flag=1}} {{dmg1flag=1}} {{dmg1=$[[2.computed]]}} {{dmg2flag=1}} {{dmg1type=Str 7, AP 4}} {{dmg2=$[[4.computed]] Fails}} {{dmg$[[5]]=$[[4.computed]] Fail(s) [Gets Hot](!
#Gets-Hot)}} {{spelldesc_link=[To Wound](!
#To-Wound)}} [[ [[ {[[ [[(?{how many shots}-[[ [[?{how many shots}d6>[[7-?{BS}]] ]] Successes from ?{how many shots} Shots]])d(7-?{BS}-1)<1]] Fails]],0}>1*2 ]] ]] I designed it show only the results and not the rolls since they can confuse the issue. I'm also not sure exactly how this ends up looking.
@Rainbow - That does exactly what I wanted it to do!! Thats awesome!! Thank you so much dude