D20 custom responses according to whats rolled

I’ve been playing around and trying to figure out how to have custom responses according to specific numbers rolled. Example:
1 = $(user) rolled a nat 1 and died.
2-19 = $(user) rolled a _
20 = $(user) rolled a nat 20, critical hit!

I have been using eval rng and trying to input responses via if and else but not quite getting it. This is the base command im working with, but im more than open to change it:

$(user) rolled a $(eval Math.floor((Math.random() * 20) + 1))

I also tried this based off of reading things but couldnt get it to work:

$(eval var a = (Math.floor(Math.random() * 20)); if (a=20) { var s = " $(user) rolled a nat 20, critical succuess! “; } if (a=1) { var s = " $(user) rolled a nat 1 and died.”; } else { “$(user) rolled {r}.”)

good bones to start with, just a few tweeks…

$(user) rolled a $(eval d=Math.floor(Math.random()*20)+1;s=``;if(d==1){s=` and died.`};THIS_PART;if(d==20){s=`, critical hit!`};NAT_HERE;d+s)

and “THIS_PART” and “NAT_HERE” r optional, u can just delete them if u dun need…
so for “THIS_PART” u can add other numbers too, not just 1 and 20 like this does… individual numbers can be done by following the pattern of if(d==1) and if(d==20) and if u want a range, u can do if(d>=2&&d<=19) for all of 2 to 19 or if(d>=5&&d<=9) for 5 to 9 etc…
and then for “NAT_HERE”, i have no idea what the heck “nat” is in this, but i noticed u only had it for 1 and 20, if this is significant/desired then replace NAT_HERE with…

if(d==1||d==20){d=`nat `+d}

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.