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

Morale Checking

I'm trying to figure out how to have a Macro that, when clicked, will ask for difficulty then roll 2d6 (adding them together) and determine success or failure if rolled under the difficulty.
1657649874
GiGs
Pro
Sheet Author
API Scripter
This isn't as easy as you'd expect, because by default when rolling multiple dice againts a difficulty, Roll20 counts each die separately. A group roll is treated as a single total. This is where, so, you compare two separate dice rolls to see which is highest. It will give you the highest there - so if you compare 2d6 with 0 dice, you automatically get the highest. /roll {2d6,0d0}kh1 You can alkso use inline rolls to make the 2d6 roll a number, and compare against a value of zero. /roll {[[2d6]],0}kh1 Then you need to add in a query for the difficulty /roll {2d6,0d0}kh1<?{Difficulty?|7} /roll {[[2d6]],0}kh1<?{Difficulty?|7} Finally you can make it neater using a roll template. A simple template that just shows the final total: &{template:default} {{result=[[{2d6,0d0}kh1<?{Difficulty?|7}]] }} A slight more complex version that shows the difficulty and the result. &{template:default} {{difficulty=[[?{Difficulty?|7}]]}} {{result=[[{2d6,0d0}kh1<?{Difficulty?}]] }} And a more complex version using the Reusing Rolls trick to show the roll, the difficulty, and the result. &{template:default} [[{[[2d6]],0}kh1<[[?{Difficulty?|7}]] ]] {{difficulty=$[[1]]}} {{roll=$[[0]]}} {{result=$[[2]]}} The big downside of all of these apporaches, is tha it will not show text as the total - for success, it will show 1, for failure it will show 0. There might be a way to comnine these methids with a rollable table to get the text output, but if there is, someone else will need to supply that. Otherwise, you'll need to settle for getting a result for 1 as success, and 0 for failure.
1657707209
Ziechael
Forum Champion
Sheet Author
API Scripter
GiGs said: <incredibly detailed and well described solution omitted for space saving> The big downside of all of these apporaches, is tha it will not show text as the total - for success, it will show 1, for failure it will show 0. There might be a way to comnine these methids with a rollable table to get the text output, but if there is, someone else will need to supply that. Otherwise, you'll need to settle for getting a result for 1 as success, and 0 for failure. You can use this ' trick ' to output custom text when using the success/failure mechanic :)
Oh interesting. How would I go about adding the text to the macro?
1657733392
Kraynic
Pro
Sheet Author
Daniel C. said: Oh interesting. How would I go about adding the text to the macro? Did you follow the link?  Instructions are in that post.
1657782300
GiGs
Pro
Sheet Author
API Scripter
Ziechael said: You can use this ' trick ' to output custom text when using the success/failure mechanic :) I knew there was a way :) Is it possible to append text to the 0 and 1 result, to create multiple success and failure tables, like [[1t[thistable-0] ]] (replacing the 0 with an inline roll) ?
1657801145
Ziechael
Forum Champion
Sheet Author
API Scripter
Absolutely, I've mentioned it in other threads but as long as you stick to something that can be coerced out of a binary result you are golden: 1t[[[success/fail calculation]]red] and 1t[[[success/fail calculation]]blue] already gives you scope for 4 custom table results or 2 sets of 2 that you query for: 1t[[[success/fail calculation]]?{Red or Blue|red,blue] I can't 100% remember where table calls sit in the order of operations but pretty sure it is after queries and inline rolls. Want random table options ranging from 0-10? Sure: 1t[[[ [[success/fail calculation]]d10 ]]] Specifically numbered tables but only in the event of success? Why the heck not: 1t[[[ [[success/fail calculation]]*?{Table|The first,1|The Second,2|The Third,3} ]]] With my patented cure all for all your custom success/failure output needs you need never buy another tonic again!