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 .
×

I need help with a macro wich lets some numbers negate failures

I tried for hours to make this but nothing seems to work. The idea is to roll some d10 and count the successes, 1s count as failures and each subtrcacts one success. It looks like this:  /em Rolls [[?{number of dice}d10>?{difficulty}f1]] But the part Im stuck now is making each 10 negate a 1. The idea is to make a macro, wich rolls xd10, counts all dice higher than y, subtracts all the 1s but each 10 negates a 1. Thank you for every idea
1630348720
GiGs
Pro
Sheet Author
API Scripter
You cant actually have 10s negate 1s, and also have successes count separately. The roll20 dice system cant cope with that.
GiGs said: You cant actually have 10s negate 1s, and also have successes count separately. The roll20 dice system cant cope with that. I’m mot so sure about that. What if you use the “re-use dice rolls” tool?
1630359547
timmaugh
Roll20 Production Team
API Scripter
If scripts are available (a perk of playing in a game started/owned by a Pro subscriber), then Plugger has a plugin that can get the dice of a roll. Combine that with a ZeroFrame loop and you could get the base value of a roll, then adjust for 10s versus 1s.
1630367548

Edited 1630380568
GiGs
Pro
Sheet Author
API Scripter
Gargamond said: GiGs said: You cant actually have 10s negate 1s, and also have successes count separately. The roll20 dice system cant cope with that. I’m mot so sure about that. What if you use the “re-use dice rolls” tool? No, that trick wont work either. The only way to do this is as tim points out, with an API script.
1630378847
timmaugh
Roll20 Production Team
API Scripter
So, here's an example with MathOps, Plugger, and ZeroFrame installed. I used a roll template just to help with the layout: !&{template:default}{{name=Roll Example}}{{Base Roll=[[?{number of dice|10}d10>?{difficulty|7}f1]]}}{{Final Adjusted=[\][\]$[[0]].value + {& math min({&eval} getDiceByVal($[[0]] 1 all count){&/eval},{&eval} getDiceByVal($[[0]] 10 all count){&/eval})}\]\] }}{&simple} Or, with line-breaks, just for readability: !&{template:default} {{name=Roll Example}} {{Base Roll=[[?{number of dice|10}d10>?{difficulty|7}f1]]}} {{Final Adjusted=[\][\]$[[0]].value + {& math min({&eval} getDiceByVal($[[0]] 1 all count){&/eval},{&eval} getDiceByVal($[[0]] 10 all count){&/eval})}\]\] }} {&simple} The Final Adjusted section is doing the work. That starts by deferring an inline roll: [\][\] ... \]\] ...so that it isn't detected until we let our other constructions shake out to their values. By default, Plugger's eval block runs first, left to right. get all 1s from the 0th roll:  {&eval} getDiceByVal($[[0]] 1 all count){&/eval} get all 10s from the 0th roll: {&eval} getDiceByVal($[[0]] 10 all count){&/eval} Those reduce to a number. Next, MathOps runs a min function: {& math min( ... ) } ...to return the lesser of the two die sides retrieved: 10s, or 1s. The 1s have already been subtracted out of the successes of the base roll. The number of successes you get back will always be the lesser of the number of 1s or 10s. Again, lots of things become possible with the API, but that is a Pro perk. =/
1630378958
timmaugh
Roll20 Production Team
API Scripter
Meant to post a screen cap of the proof of concept in action. Here is an example where there was one 1, and two 10s, and it correctly gave back one success to the final roll:
Thanks a lot, i really aprecciate it. I will talk with my players about getting pro.
1630431401
GiGs
Pro
Sheet Author
API Scripter
If you do get pro, make sure you grab the tokenMod script - it will make your life so much easier. there are a lot of useful scripts to check out, but that one is a must-have.