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

How to roll different dice for different attribute values

September 07 (3 years ago)

I want to make a character sheet, but for that i need help with a command, in this case how do I call for example : 2d6 if STR = 10 or 2d8 STR=11 ...

September 07 (3 years ago)

Edited September 07 (3 years ago)
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator

Depends on the exact progression. It may require a sheetworker if it's super complex, and even if it isn't I might still use a sheetworker. But for your specific example, a pure macro solution is:

[[2d[[{@{strength},0}<10*6+{@{strength},0}>11*8]] ]]

Which would roll 2d6 if your strength is 10 or less, or 2d8 if it's 11 or more.

September 07 (3 years ago)

Scott C. said:

Depends on the exact progression. It may require a sheetworker if it's super complex, and even if it isn't I might still use a sheetworker. But for your specific example, a pure macro solution is:

[[2d[[{@{strength},0}<10*6+{@{strength},0}>11*8]] ]]

Which would roll 2d6 if your strength is 10 or less, or 2d8 if it's 11 or more.

A need for this Table bellow.



September 07 (3 years ago)
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator

Oof. That's possible to do using the technique I showed, but it would be one FUGLY macro. I think a sheetworker, if you're making your own custom sheet, or an API script are going to be much better options.

September 07 (3 years ago)
Kraynic
Pro
Sheet Author

Does strength often change during play?  If this is something that gets set once during play and rarely changed, you could either have an input where people put the dice formula, or just use a dropdown that sets the dice when you select the strength value from the drop down list.

Also, is 15 supposed to be 5d6 instead of 5d10?  It seems like that would make more sense for the overall progression.

September 07 (3 years ago)


Scott C. said:

Oof. That's possible to do using the technique I showed, but it would be one FUGLY macro. I think a sheetworker, if you're making your own custom sheet, or an API script are going to be much better options.

And how i build API script for this sheet?



September 07 (3 years ago)


Kraynic said:

Does strength often change during play?  If this is something that gets set once during play and rarely changed, you could either have an input where people put the dice formula, or just use a dropdown that sets the dice when you select the strength value from the drop down list.

Also, is 15 supposed to be 5d6 instead of 5d10?  It seems like that would make more sense for the overall progression.


Yes change :c ; and 15 is 5d6, Ty bro.



September 08 (3 years ago)

Edited September 08 (3 years ago)
GiGs
Pro
Sheet Author
API Scripter

I'd go for a sheet worker, and store the damage dice in a stat called "damage" or "strength_dice". But to construct the sheet worker we'd need to know:

Is this dice progression only for the strength stat, or do other stats use it too?

Are the dice ever subject to modifiers (like +1 STR), and if so do they modify the stat or the dice?

September 08 (3 years ago)


GiGs said:

I'd go for a sheet worker, and store the damage dice in a stat called "damage" or "strength_dice". But to construct the sheet worker we'd need to know:

Is this dice progression only for the strength stat, or do other stats use it too?

Are the dice ever subject to modifiers (like +1 STR), and if so do they modify the stat or the dice?

This dice progression is for the 4 basic stats;
And for exemple ; STR 10 is 2d10,  10 STR + 1 STR  = 11 STR Or 2d12




September 08 (3 years ago)

Edited September 09 (3 years ago)
GiGs
Pro
Sheet Author
API Scripter

Okay, you didnt answer the question about whether stats ever get modified, so i am ignoring that. Here's a sheet worker that will calculate dice values for your stats.

There's some prep work to do:

Step 1: Assuming you have an input for the attribute like

<input type="number" name="attr_strength" value="10">

create a matching dice attribute for each one like

<input type="text" name="attr_strength_dice" value="" readonly>

It doesnt have to be visible, you could hide it like

<input type="hidden" name="attr_strength_dice" value="" readonly>


The attributes must start the same - spelled exactly the same - as the attribute they are based on, and then have _dice added to the end.


Step 2: Now check if your html sheet has a script block. If you dont have one already, create the following at the bottom of your sheet:

<script type="text/worker">



</script>

Any and all sheet workers go between the two script lines.


Step 3: Finally add the following sheet worker between the script lines. The first two lines need adjusting. Enter the extra dice roll values in order, in the same way the first few are listed here, on the dice_values line.

And on the stat_names line, enter the four attribute names (I wrote strength and dexterity, just as examples, you can replace them). They must be spelled exactly the same as on the character sheet - though whether capital letters are used or not doesnt matter. In this array, only use lower case.


const dice_values = ['1''1d2''1d4''1d6'];
const stat_names = ['strength''dexterity'];
const name_end = 'dice'; //if you want to use a different name end, change it here.
stat_names.forEach(stat => {
    on(`change:${stat}`, () => {
        getAttrs([stat], v => {
            const score = +v[stat] || 0;
            const dice = dice_values[Math.max(0Math.min(dice_values.length -1score))];
            setAttrs({
                [`${stat}_${name_end}`]: dice
            });
        });
    });
});


And voila, with that in place, your dice values will calculate automatically, at least up to scores of 39. You'll be able to use the dice in a macro or a roll using @{strength_dice}


GiGs said:

Okay, you didnt answer the question about whether stats ever get modified, so i am ignoring that. Here's a sheet worker that will calculate dice values for your stats.

There's some prep work to do:

Step 1: Assuming you have an input for the attribute like

<input type="number" name="attr_strength" value="10">

create a matching dice attribute for each one like

<input type="text" name="attr_strength_dice" value="" readonly>

It doesnt have to be visible, you could hide it like

<input type="hidden" name="attr_strength_dice" value="" readonly>


The attributes must start the same - spelled exactly the same - as the attribute they are based on, and then have _dice added to the end.


Step 2: Now check if your html sheet has a script block. If you dont have one already, create the following at the bottom of your sheet:

<script type="text/worker">



</script>

Any and all sheet workers go between the two script lines.


Step 3: Finally add the following sheet worker between the script lines. The first two lines need adjusting. Enter the extra dice roll values in order, in the same way the first few are listed here, on the dice_values line.

And on the stat_names line, enter the four attribute names (I wrote strength and dexterity, just as examples, you can replace them). They must be spelled exactly the same as on the character sheet - though whether capital letters are used or not doesnt matter. In this array, only use lower case.


const dice_values = ['1''1d2''1d4''1d6'];
const stat_names = ['strength''dexterity'];
const name_end = 'dice'; //if you want to use a different name end, change it here.
stat_names.forEach(stat => {
    on(`change:${stat}`, () => {
        getAttrs([stat], v => {
            const score = +v[stat] || 0;
            const dice = dice_values[Math.max(0Math.min(dice_values.length -1score))];
            setAttrs({
                [`${stat}_${name_end}`]: dice
            });
        });
    });
});


And voila, with that in place, your dice values will calculate automatically, at least up to scores of 39. You'll be able to use the dice in a macro or a roll using @{strength_dice}


Sorry Gigs, but yes i want change the stats, for exemple in your dice values script : if my dice is 1d2  but i have +1, so i have 1d4


GiGs said:

I'd go for a sheet worker, and store the damage dice in a stat called "damage" or "strength_dice". But to construct the sheet worker we'd need to know:

Is this dice progression only for the strength stat, or do other stats use it too?

Are the dice ever subject to modifiers (like +1 STR), and if so do they modify the stat or the dice?

They are for four stats, they are : Str, Dex, Int and Spt.
And yeeeees, they modify the dice.