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

Sanitizing user input to macros

Hi, this is my first post.   I've been looking at some of the simple macros, specifically: /me rolls a [[1d20+?{modifier|0}]] for ?{reason|no reason}! This sounds great, but it seems to fail (always returns zero) if the modifier is entered as "+5" rather than just "5" ie. the plus sign causes a problem. I think this will possibly frustrate my players and/or clutter the chat with misrolls. Is there any easy way to sanitize the input to ignore non-numeric characters, maybe using a regex or something?  I certainly did search to see if this has been answered before, so apologies if I missed an existing answer.
1620599890
Andreas J.
Forum Champion
Sheet Author
Translator
try use extra bracket to make the input more flexible: /me rolls a [[1d20+(?{modifier|0})]] for ?{reason|no reason}!
That worked perfectly.  Thanks a lot for such a good simple solution.