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

Can i somehow get min/max values for rolls in the API?

I want to make a custom roll message via the API and sheettemplates and i want to know what the min/max of a possible roll could be. I could write something myself to check this from the inline rolls but i imagine there already exist a inbuild function i can use to get this?  Couldnt find anything related to this tho.
1621874533
The Aaron
Roll20 Production Team
API Scripter
There aren't any built in ways of doing it, but I have a couple functions that might help you: const expressionMax = (txt) => { const tokenize = /(\d+d\d+|\d+|\+|-)/ig; const dieparts = /^(\d+)?d(\d+)$/i; const ops = { '+': (m,n) => m+n, '-': (m,n) => m-n }; let op = '+'; return (txt.replace(/\s+/g,'').match(tokenize)||[]).reduce((m,t)=>{ let matches = t.match(dieparts); if(matches){ return ops[op](m,[...Array(parseInt(matches[1])||1)].reduce(m=>m+(parseInt(matches[2])),0)); } else if(/^\d+$/.test(t)){ return ops[op](m,parseInt(t)); } else { op = t; return m; } },0); }; const expressionMin = (txt) => { const tokenize = /(\d+d\d+|\d+|\+|-)/ig; const dieparts = /^(\d+)?d(\d+)$/i; const ops = { '+': (m,n) => m+n, '-': (m,n) => m-n }; let op = '+'; return (txt.replace(/\s+/g,'').match(tokenize)||[]).reduce((m,t)=>{ let matches = t.match(dieparts); if(matches){ return ops[op](m,[...Array(parseInt(matches[1])||1)].reduce(m=>m+1,0)); } else if(/^\d+$/.test(t)){ return ops[op](m,parseInt(t)); } else { op = t; return m; } },0); }; I'm pretty sure they work right... at a minimum, they can be a jumping off point.
Thanks will come in handy