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

Success/Failure message based on Roll macro results in a Custom Roll Template for a custom sheet.

Plain English roll rules: Select a Number of dice to roll. Select which type of die to roll. Select a Difficulty. Select the lowest of the dice, and compare it to the difficulty, if it is equal or lower, you succeed, otherwise you fail. Here's my current Macro and Roll Template: <button type="roll" value="&{template:sagas} {{name=@{character_name} is rolling for ?{Activity|}}} {{Roll=[[?{Number of Dice|1}d?{Die Type|12|6|8|10|12}kl1]]}} {{Difficulty=?{Difficulty|5|1|2|3|4|5|6|7|8}}}"> Make a Check</button> <rolltemplate class="sagas"> <div class="sheet-rolltemplate-sagas"> <div class="sheet-rollresult"> <strong>{{name}}</strong> <p>Roll: {{Roll}}</p> <p>Difficulty: {{Difficulty}}</p> <p>If the roll result is less than or equal to the difficulty, the check is successful. Otherwise, the check fails.</p> </div> </div> </rolltemplate> What I would like to do is replace the plain text " If the roll result is less than or equal to the difficulty, the check is successful. Otherwise, the check fails. " with "Critical Success" on a 1, "Success" on a successful check, and "Failed" on a failure. I've read " How-to-Make-Roll-Templates" a few times and it seems like it should be possible, but nothing I've tried has worked. I've even tried using Chat-GPT for help, but its solutions have not been solutions at all and when I point out that they don't work, it simply says it is not possible.
1688356672
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Chat GPT is useless for this for several reasons; 1) it's general quality of generated code is pretty bad (we're a long way from AI taking over programmer jobs), and 2) This is such a niche code area that it has no data to pull from. The easiest way to handle this is going to be with custom roll parsing . My keyboard is not really working at the moment, or I'd post some code to demonstrate. Doing this with only rolltemplate code is going to get complicated fast.
Thanks. I've been a programmer since the early 90s, professionally since the late 90s. Yeah, ChatGPT, in general, produces code that needs someone who knows what's wrong with it and can fix it, but it can be a time saver. Sadly, in terms of macros and Roll20 programming, that isn't me.
1688361873

Edited 1688366283
GiGs
Pro
Sheet Author
API Scripter
Of the chatGPT problems, the second point Scott made is far more important. If ChatGPT made perfect code every time and needed no-one to check it afterwards, it would still be useless for Roll20. This is because ChatGPT needs examples of code to train on, and there are plenty of those for HTML, CSS, JavaScript, etc, but there isn't enough Roll20-specific code to even start training it.
1688362510

Edited 1688366139
GiGs
Pro
Sheet Author
API Scripter
This problem seems like it shouldn't be too hard without custom roll parsing, as long as you use the drop-highest/keep lowest modifier inside an inline roll. It looks like you are doing that, but havent added a Logic Helper to your code. You'd need to change this line: <p>If the roll result is less than or equal to the difficulty, the check is successful. Otherwise, the check fails.</p> to something like this: < p >     {{#rollGreater() roll difficulty}}Failure{{/rollGreater() roll difficulty}}     {{#^rollGreater() roll difficulty}}         {{#rollTotal() roll 1}Critical{/rollTotal() roll 1}}         {{#rollGreater() roll 1}}Success{{/rollGreater() roll 1}}     {{#^rollGreater() roll difficulty}}   </ p >
1688363045
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
ah, I missed that the rest of the roll wasn't needed. Yeah, then all you need is the logic that GiGs showed.
1688366539

Edited 1688367392
GiGs
Pro
Sheet Author
API Scripter
Thanks, Scott. Vampirebytes, don't you also have to start the rolltemplate like this: <rolltemplate class="sheet-rolltemplate-sagas"> Rolltemplate code hasnt been updated with modern code, it still needs the -sheet prefix, and the rolltemplate part is probably to signal to rolltemplate that code inside this block should be treated differently. If you don't need those, I definitely want to know :) That would make the first inner div redundant and it should be removed or the class name changed.
1688367372

Edited 1688367431
GiGs
Pro
Sheet Author
API Scripter
Based on my admittedly brief testing, it looks like you have found an alternate way to have rolltemplates work. If you start with <rolltemplate class="sagas"> <div class="sheet-rolltemplate-sagas"> It works similarly to <rolltemplate class="sheet-rolltemplate-sagas"> But this alone doesn't work: <rolltemplate class="sagas"> You need that inner div with -sheet-rolltemplate- or it won't work. IMO this is superior: <rolltemplate class="sheet-rolltemplate-sagas"> The formatting can be a bit different with the inner div (though that is probably just because of the CSS I created), but does work. Still, the above is simpler and requires less code.
Thanks all!