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

Syntax for Success Target

1657234243

Edited 1657235729
I need a roll that rolls 2d4 at levels 1-3, then adds a d4 at levels 4, 8, 12, 16, 20. So this works to return the number of success: [[{4, 8, 12, 16, 20}<4+2]] The 4 on the right side of the < will be replaced with the player's level. Currently This returns a 0, 1, 2, 3, 4 or 5 (based on the value of 4 which currently returns 1 or 0 if less than 4 and 2 or higher if you replace the 4 with an 8 or higher), and then adds 2, so it will result in 2, 3, 4, 5, 6 or 7. So I just want to basically append "d4" to the number returned (2d4, 3d4, 4d4, 5d4, etc). This returns the correct number, but does not append the "d4" so the roller can roll that number of d4s: [[{4, 8, 12, 16, 20}<4+2 d4 ]] Theoretically, this should return and the roller should roll 3d4 since the successes (the 4) are 1, plus 2. I have a feeling it is a syntax thing, but I am far from a Roll20 syntax expert, clearly. Any insight would be awesome. Thanks
1657244837
Kraynic
Pro
Sheet Author
You could just do something like this: [[[[2+floor(@{level}/4)]]d4]] That should have you rolling 2 dice if you are below level 4, and then will roll 2 plus one die for each 4 levels the character possesses.  Obviously, you may need to change @{level} to be the correct attribute for the sheet you are using.
Fantastic, that is even better. I appreciate your help!
Out of curiosity, is the floor() function necessary? floor will round a decimal down to the lowest whole number, but a person's level will never be a decimal. Did you just add that as a standard practice? The syntax works with or without the floor function, just curious. Thanks again, this is great and I will be able to use it on other things going forward.
1657299071
Kraynic
Pro
Sheet Author
It is probably best to keep it in there to be sure the dice roller doesn't get confused by someone trying to roll 2.25d4.  The floor function makes sure you never have the decimal.
1657308679
GiGs
Pro
Sheet Author
API Scripter
Roll20 always rounds to the nearest for dice rolls. So without Floor, you'll get the wrong number of dice sometimes.