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

Generic macro for die rolls with replaceables

1552686263
MSG
Pro
Sheet Author
Please forgive my ignorance, but I haven't worked with macros that much, and I certainly haven't done anything where you can get a popup that asks for a value.  I'd like to make a macro that basically does this: xdy+z I'd like to have the macro ask for values then roll - something like: /r xdy+z 'x' would default to 1 if no value entered, 'y' must have the number of sides entered and 'z' would default to 0 if no value entered.  How is this done in Roll20 format?  I think it would start out something like: /r ?{times|1}d ... but I get lost afterwards.  I'm thinking something like: /r ?{Times|1}d?{Sides}+?{Modifier|0} but it doesn't look right for some reason.  Would someone kindly help please?  Thank you!
1552687343
Kirsty
Pro
Sheet Author
MSG, did you test that macro? It works perfectly for me! If you'd like to turn it into an inline roll, you could put it in square brackets instead: [[?{Times|1}d?{Sides}+?{Modifier|0}]] It works just fine as you wrote it though. I think you're better at macros than you think you are!
1552687520

Edited 1552687719
MSG
Pro
Sheet Author
Um, wow.  No, I had not tested it because it didn't seem to look right to me and I didn't want to mess anything up.  Did you notice if {Sides} required a number to be put in? Thank you for testing that and for your reply.  Much appreciated!  :) EDIT:  I noticed I can just click Submit for {Sides} and it does a: 1d+0 - with the number of sides missing.  Is there anyway to force the user to enter the number of sides?
1552689363
Kirsty
Pro
Sheet Author
My suggestion would be to put a placeholder number in the Sides query, the same way that you did with the Times query. Unfortunately, you can't force the user to pick a number, having a placeholder is a good as you can get in a macro.
1552691258
GiGs
Pro
Sheet Author
API Scripter
You can put a default for sides as you have with the others, which will be used if the player enters nothing, like /r ?{Times|1}d?{Sides|6}+?{Modifier|0} If you want to use a dropdown you could use /r ?{Times|1}d?{Sides|4|6|8|10|12}+?{Modifier|0} So they'll have to choose an entry. You can put them in any order, so if 6-sided is the most common you could put that first like (for example): /r ?{Times|1}d?{Sides|6|8|10|12|4}+?{Modifier|0} Picking from a dropdown is a little slower than just entering a number, so for simple things its sometimes best to use the basic approach.
1552694852
Kirsty
Pro
Sheet Author
GiGs said: If you want to use a dropdown you could use /r ?{Times|1}d?{Sides|4|6|8|10|12}+?{Modifier|0} So they'll have to choose an entry. You can put them in any order, so if 6-sided is the most common you could put that first like (for example): Oh my goodness, I totally forgot you could do that. Thanks for the correction, GiGs!
1552694892
MSG
Pro
Sheet Author
Thank you both very much!
1552697909
GiGs
Pro
Sheet Author
API Scripter
Kirsty said: GiGs said: If you want to use a dropdown you could use /r ?{Times|1}d?{Sides|4|6|8|10|12}+?{Modifier|0} So they'll have to choose an entry. You can put them in any order, so if 6-sided is the most common you could put that first like (for example): Oh my goodness, I totally forgot you could do that. Thanks for the correction, GiGs! Hehe, it wasn't a correction, it was an addition.