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

[Script Help] Script for displaying different calculations on a roll's result

Hello me again still struggling with the possibilities of the roll20 macro language. I am looking for a way to display the result of a fireball (10D6) in the following way in the chat xx Damage (where xx is the roll result) yy Damage on successfull save (where yy is the roll result divided by 2 dropping any fractions) zz Damage on successfull save with resistance (where zz is the roll result divided by 4 dropping any fractions) So what I need how to do this a spell template on the ad&d char sheet I presume the answer will be : Not without the api :-) rgds JT
1457630463
The Aaron
Pro
API Scripter
Correct, not without the API sadly.   The closest you can get is doing something trippy with math like: [[ [[10d6]] * 10000500025]] Assuming the result of 10d6 was 37, you'd get: 37 0 18 500 9 25 which is 37, 18(.5) for save, 9(.25) for save+resistance.  Not very user friendly, but maybe that would work for you?
Hit thanks for your answer. If I get it right, it is not possible to save the result of a die roll inside a macro for later use? So die rolling is fire and forget? Can you explain why that's the way it is? rgds JT
1457641359
The Aaron
Pro
API Scripter
That is correct.  Macros are only capable of utilizing the immediate result of a calculation.  Why is a question for the developers which I can't really answer. =/
1457721676
Lithl
Pro
Sheet Author
API Scripter
The Aaron said: That is correct.  Macros are only capable of utilizing the immediate result of a calculation.  Why is a question for the developers which I can't really answer. =/ All you need for Turing-completeness in an imperative language is the ability to store values and conditional branching. The macro system can already get some limited conditional branching within rolls, and precomputed branching using roll queries, so adding the ability to store values brings it pretty damn close. In theory, once the macro system is Turing-complete, it could simulate any computer algorithm. The API would still be necessary for manipulating the VTT, but any script based on taking user input and coughing up output to chat would then be possible to replicate without a Pro subscription by the campaign owner. Of course, a minimally Turing-complete language is very hard to work with for anything complex and the above may not be the devs' reasoning for limiting the macro system, but each time macros are updated to include more power and complexity, the API system (one of the marketable features of the Pro subscription) loses some value.