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

New to programming, how flexible is the API?

Hey kids, I'm looking to make a couple custom macros in the API.  Specifically, one in which after the player fires off a basic attack, the macro would randomly select from an array of quotes and quips for each attack.  There seem to be a variety of macros on here, but my knowledge and time are limited, and I'm just curious if this simple function is possible through the API.  Thanks!
1550962881
GiGs
Pro
Sheet Author
API Scripter
Yes, you could do that, and there's probably a few ways you could do it. 
That's awesome!  Can you recommend a resource or similarly existing script that I can reference to get started?
1550964446
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Look up Rollable Tables .
1550964744
GiGs
Pro
Sheet Author
API Scripter
That's a great idea, Keith. A much easier solution than using the API and learning the programming language.
1550965936
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Seeing as it would take me half an hour to write a "Hello World" script in JS, I go for the simple solution. :)
1550966307
GiGs
Pro
Sheet Author
API Scripter
Plus, sometimes the simplest solutions are actually the best ones! There's no real advantage to using a script over a rollable table in this case, I just didn't think of it in this case because I usually answer script-related questions.
1550966629
GiGs
Pro
Sheet Author
API Scripter
To answer your question, Ben: unfortunately there's no shortcut to learning how to use javascript. There are tutorials on line, and a bunch of help (including some script snippets) in the roll20 wiki. The github page for roll20 scripts has a load of example scripts - some are very complex, some are fairly simple. In this case, though, learning how to use rollable tables is a better solution. If there's something you want to do with your tables beyond what the rollable tables provide, though, scripts can make that happen. Just let us know what you'd need to do and we'll help.
1551146033
The Aaron
Roll20 Production Team
API Scripter
One case for API would be if you want it to glom onto Roll Templates from a Character Sheet where you don’t have a way to add a Rollable Table at the point of execution.