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

Roll button html for rolling multiple dice

August 08 (5 years ago)
Aero
Pro

My html is very weak and I think I'm trying to do something very complicated - any help much appreciated!!

I want to put a roll button on a character sheet that does the following:

- Prompts the user to input a bonus number

- Rolls a d10 and adds the bonus number and an associated stat to the result

- Rolls another d10 without adding anything

- Adds text conditional on the comparison of the two numbers

I've figured out how to get a roll button that will roll a d10 and add the stat, but no clue how to do the rest.

August 08 (5 years ago)
GiGs
Pro
Sheet Author
API Scripter

It might not be possible to do what you want without an API script. But if you're designing your own sheet, you might be able to do it with a rolltemplate.

Can you be more descriptive how the comparison works, and what the possible results are. The more detail you can give the better.

August 09 (5 years ago)
Aero
Pro

Sure thing. If the first die plus the player-chosen bonus number plus the associated stat is higher than the second die the skill-check is a success. If it is equal to or less than the second die the skill-check is a failure.

Also, if the natural result of the first die equals the second die then it's a critical success if they are both even or a critical failure if they are both odd. This bit isn't crucial though.

What's important is getting the two results (die1+bonus+stat vs die2) from one button-click.

August 09 (5 years ago)
GiGs
Pro
Sheet Author
API Scripter


Richard K. said:

What's important is getting the two results (die1+bonus+stat vs die2) from one button-click.

Does the difference matter? Do you use margin of success / failure? 


August 10 (5 years ago)
Aero
Pro

Nope, just crit success, success, failure and crit failure.

However the natural numbers themselves are often relevant for side details so they do need to be displayed.

August 10 (5 years ago)

Edited August 10 (5 years ago)
GiGs
Pro
Sheet Author
API Scripter

You should be able to do this with rolltemplate logic helpers.

This part is a bit laborious:

Also, if the natural result of the first die equals the second die then it's a critical success if they are both even or a critical failure if they are both odd. This bit isn't crucial though.

but can be done. If this is your own homebrew though, I'd recommend using <5 for failure, and 6+ for success - the code for roll20 is MUCH easier. Using odd and even, you have to repeat each case 5 times because you have to list each number.

The first part is easier but not obvious:

You need to send the roll+bonus, the bonus, and the second roll - set them in your initial template call like

&{template:whatever} [[ [[1d10]] + @{stat} + ?{bonus|0} ]] {{firstroll=$[[0]]}} {{total=$[[1]]}} {{secondroll=[[1d10]]}}

Then in your rolltemplate,

{{#rollTotal() firstroll secondroll}}
    <!-- whatever you want to happen when both rolls are equal goes here -->
    {{#rollTotal() firstroll 2}}
		<!-- put the critical success entry here -->
	{{/rollTotal() firstroll 2}}
	{{#rollTotal() firstroll 4}}
		<!-- put the critical success entry here -->
	{{/rollTotal() firstroll 4}}
	{{#rollTotal() firstroll 6}}
		<!-- put the critical success entry here -->
	{{/rollTotal() firstroll 6}}
	{{#rollTotal() firstroll 8}}
		<!-- put the critical success entry here -->
	{{/rollTotal() firstroll 8}}
	{{#rollTotal() firstroll 10}}
		<!-- put the critical success entry here -->
	{{/rollTotal() firstroll 10}}
	{{#rollTotal() firstroll 1}}
		<!-- put the critical failure entry here -->
	{{/rollTotal() firstroll 1}}
	{{#rollTotal() firstroll 3}}
		<!-- put the critical failure entry here -->
	{{/rollTotal() firstroll 3}}
	{{#rollTotal() firstroll 5}}
		<!-- put the critical failure entry here -->
	{{/rollTotal() firstroll 5}}
	{{#rollTotal() firstroll 7}}
		<!-- put the critical failure entry here -->
	{{/rollTotal() firstroll 7}}
	{{#rollTotal() firstroll 9}}
		<!-- put the critical failure entry here -->
	{{/rollTotal() firstroll 9}}
{{/rollTotal() firstroll secondroll}}
{{#^rollTotal() firstroll secondroll}}
    <!-- whatever you want to happen when both rolls are NOT equal goes here -->
    {{#rollGreater() total secondroll}}
	
	    <!-- this is a normal success -->    
		
    {{/rollGreater() total secondroll}}
    {{#^rollGreater() total secondroll}}
	
	    <!-- this is a normal failure -->    
		
    {{/^rollGreater() total secondroll}}
{{/^rollTotal() firstroll secondroll}}
Notice that the critical failure and success need to be repeated 5 times because there's no way within a template to check if the roll is odd or even - you have to list every number.
If you change it to be <=5 and >=6 that first section owuld be
{{#rollTotal() firstroll secondroll}}
    <!-- whatever you want to happen when both rolls are equal goes here -->
    {{#rollGreater() firstroll 5}}
		<!-- put the critical success entry here -->
    {{/rollGreater() firstroll 5}}
    {{#rollLess() firstroll 6}}
		<!-- put the critical failure entry here -->
    {{/rollLess() firstroll 6}}
{{/rollTotal() firstroll secondroll}}

You can show the natural numbers anywhere by using {{firstroll}} and {{secondroll}}