philmophlegm: (Traveller)
[personal profile] philmophlegm
I want a function that returns a value equal to (x six-sided dice minus y six-sided dice) but which returns the answer '0' if the formula would otherwise result in a negative answer.

Or, to put it in role-playing terms, something like "4d6-3d6, but show any negatives as zero".

Doing the 4d6-3d6 bit is easy:
=(RANDBETWEEN(1,6)+RANDBETWEEN(1,6)+RANDBETWEEN(1,6)+RANDBETWEEN(1,6))-(RANDBETWEEN(1,6)+RANDBETWEEN(1,6)+RANDBETWEEN(1,6))

I had thought of then putting this inside an IF function, so that if the formula above was >=0, it showed the formula above, but if it was <0, it showed 0:

=IF((RANDBETWEEN(1,6)+RANDBETWEEN(1,6)+RANDBETWEEN(1,6)+RANDBETWEEN(1,6))-(RANDBETWEEN(1,6)+RANDBETWEEN(1,6)+RANDBETWEEN(1,6)),(RANDBETWEEN(1,6)+RANDBETWEEN(1,6)+RANDBETWEEN(1,6)+RANDBETWEEN(1,6))-(RANDBETWEEN(1,6)+RANDBETWEEN(1,6)+RANDBETWEEN(1,6)),0)

Unfortunately, that second function doesn't work. The reason it doesn't work is that it is recalculating the 4d6-3d6 part. That means that if the original 4d6-3d6 is positive, the formula doesn't show that positive number. Instead it rolls 4d6-3d6 again and shows the answer to that.

Any ideas?
This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

Profile

philmophlegm: (Default)
philmophlegm

March 2017

S M T W T F S
   1234
56 7891011
12131415161718
19202122232425
262728293031 

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Jun. 10th, 2025 01:54 am
Powered by Dreamwidth Studios