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 .
×

The new D&D 2024 sheet is now available!

Create a free account

Roll20 Macros Processed Outside Roll20 With Response

You can do a fair amount with the Roll20 macros but if you only have the free account sometimes you want a little more. I wanted to make a macro that handles Mirror Image for me. I would click on the macro provide a attack values and it would determine how many images I have, roll to determine if the attack was against a image or the caster based on the number of images left and automatically remove an image if the attack was against and image and it hit. With regular macros I was having an difficult time doing the whole sequence. But I found this hack. Macros allow you to reference images from 3rd party servers. The way that Roll20 determines a valid image URL is to check the ending of the URL for a valid image extension. This can be exploited. What I did was create a little PHP script that I run on my web server. The PHP script does all of the processing of Mirror Image (with instructions sent via query parameters) and then creates an image with the results. The server then returns the image. When a roll20 macro tries to get the image from my server, it is actually going to a MirrorImage.php URL but because I tack on a query parameter that ends in ".png", Roll20 is happy with it. My server returns an image so Roll20 is happy with it and displays the image. So, unknowingly, the roll20 macro tripped the script on my server which generated the Mirror Image functionality and returned it as an image. This does not pose any security risk form roll20 since you can only send a image back as a result but it allows you to perform all kinds of processing outside roll20 and then show the results in roll20. The only other trick is getting by the caching. Normally roll20 caches images so if you ran the macro twice the second time you would normally get the exact same results since it would just show the results of the cached image. To get around this I added a roll (random number) into the query parameter. I happened to have used two rolls of 1D100 meaning roughly 10000 possibilities. The difference in this random number causes roll20 to consider the URL as a different URL and forces it to read the image from the original server (and thus pick up the updated images with the new results). The follow is an example of the output of my Mirror Image and what appears in roll20... When calling the macro I pass the attack value into the macro and it does the rest.
1667184620

Edited 1667184663
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Cool idea! I have been told that the number that appears after a Roll20 image is a cache buster, that performs the same function you are talking about above. Ex. The image you posted is: <a href="https://s3.amazonaws.com/files.d20.io/images/311954534/_j4820Z__cUl0OJxI2vgeg/med.PNG?1667166130" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/311954534/_j4820Z__cUl0OJxI2vgeg/med.PNG?1667166130</a> ... the&nbsp; ?1667166130 &nbsp;is a randomly generated number that keeps it from serving the same image twice. It's a bit technical, but this might be worth posting in&nbsp; Tips n Tricks .
I didn't try that but the few tests that I did, when the URL did not end in a image extension (like PNG), it rejected it.
Hmm. I tried to post in the Tips n Tricks but it seem to be telling me that it was too old and automatically closed.
I also used it to make a macro for a player which automatically re-rolls 1s and 2s on his great sword attacks. The macro can be passed parameters to include any of Divine Favor, Hunter's Mark, Smite Level 1, and Smite Level 2. Even does the double dice rolls on crits and provides the accumulated damage (total of all damage from all the attack and various damage buffs).
1667191305
Kraynic
Pro
Sheet Author
Lord A. said: Hmm. I tried to post in the Tips n Tricks but it seem to be telling me that it was too old and automatically closed. Make sure you are on the last page of the thread.&nbsp; A quirk of the forums is that you will get that message if all the posts on the page you are looking at are old enough for the thread to have been automatically locked.
1667307561

Edited 1667307576
Thanks. Posted an abridged version in the&nbsp; Tips n Tricks. Aside: I also improved my Great sword macro so that it gets data from the character sheet (such as PB, STR Mod and the Gobal Damage Mod Roll contents) and passes them as query parameters so that updating the stats in the character will automatically update the macro.&nbsp;