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

[MACRO] Trying to determine number of dice to roll from math

July 01 (11 years ago)
Jason H.
KS Backer
So I have a macro where I don't want to have to update the number of dice it rolls as my character levels. I have the math figured out, it goes:

[[ ceil(@{Character|level}/2) ]]

This returns correctly. If I try to use it to determine the number of dice to roll:

[[ ceil(@{Character|level}/2) d6 +1 ]]
or
/r ceil(@{Character|level}/2) d6 +1

It fails. I'm using the syntax from the Dice Reference under Computed Dice Roll correctly as far as I can see, but it returns:

Could not determine result type of: [{"type":"M","expr":"ceil(4/2)"},{"type":"C","text":"d6 +1 "}]

Can anyone show me what I'm doing wrong? TIA.
July 01 (11 years ago)

Edited July 01 (11 years ago)
Actoba
Pro
Sheet Author
It's not possible due to the order of operations - https://wiki.roll20.net/Dice_Reference#Order_of_Operations

Edit : /r (2+2)d6 would work but /r (ceil(2+2))d6 does not
July 01 (11 years ago)
Jason H.
KS Backer
: /
July 01 (11 years ago)
Lithl
Pro
Sheet Author
API Scripter
Try [[(@{Character|level}/2+0.4)d6+1]]
July 01 (11 years ago)
Actoba
Pro
Sheet Author
Ooo does the system just ignore the decimal fraction if you attempt to roll something like 2.35 d6......iiiiinteresting :)
July 02 (11 years ago)
Lithl
Pro
Sheet Author
API Scripter

Well, rolling a fractional number of dice doesn't make sense. =)

round() is automatically applied to the number of dice.

July 02 (11 years ago)
Actoba
Pro
Sheet Author
/me puts chisel down and backs away from the dice bag slowly

I guess I was just expecting it would bomb out instead of applying round to it....good to know...thanks! :)
July 02 (11 years ago)
Jason H.
KS Backer
@Brian: Thanks very much, that works like a charm.