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 for set variables and calculating end result

First off, the people I'm DMing for stop reading, you know who you are. Now, I am trying to set up a macro to determine how much rainfall happened in a time period. To do this i am first trying to get it to roll 1d3(level of rain) and 1d8 (number of hours of rain) and set those as specified variables. So then,i can use Ifelse/then statements to have it do another roll for the total inches of rain per hour multiplied by the number of hours.  I cannot seem to find a way to define a variable to the result of a roll. I haven't even touched how to do the if statements yet because I can't figure out the first part. I am using this for ToA stuff, if anyone has a similar macro they used or suggestions, its much appreciated. 
1555189515
GiGs
Pro
Sheet Author
API Scripter
Are you trying to do this is an API script or a macro? Macros dont support conditional logic - there's no way to do if/then expressions.  I'm not sure what if/then statement you need though. Cant you just do 1d3 x 1d8 ?
I have been trying to do this in a marco. I am new to Pro, a couple weeks, and not sure how to use the API just yet. If this can't be done in a macro it seems its time i bite that bullet and start reading up on the API.
1555342782

Edited 1555342832
GiGs
Pro
Sheet Author
API Scripter
I am not confident I'm understanding what you need properly, because what you've asked for doesn't seems to need the the API. You can combine rolls in a single macro, like /roll 1d?{rain|3} * 1d?{hours|8} and it will roll them both. If you need the rolls stored as variables, you can use a character sheet for that. Create a character sheet, call it GM, and add two attributes (on the Attributes and Abilities tab - ignore all the other attributes on there). Give them these values: Rain: 1d3 Hours: 1d8 Then you can create a macro to roll them: /roll @{GM|Rain} * @{GM|Hours} You can pretty these up by using the default roll template: &{template:default} {{name=Precipitation}} {{Rain/Hour=@{GM|Rain}}} {{Hours=@{GM|Hours}}} {{Total Rain=[[@{GM|Rain} * @{GM|Hours} ]] }} You can find more about macros on the roll20 wiki.
I appreciate the help. My friend and I have decided to write and API to do this for us