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 the API - Ideas? Suggestions?

Greetings, all. I have a modest background writing scripts in various languages. However, I'm just getting started writing my own scripts for the Roll20 API. I am curious if the community has any input: What were the challenges you faced getting started? What starter projects would you suggest? What do you feel are scripts that would help the Roll20 community? Thanks Mike
1607088688

Edited 1607088700
The Aaron
Roll20 Production Team
API Scripter
One challenge is understanding the environment, particularly if you're used to writing Javascript in a web browser. API scripts have more in common with Node modules than with browser code. They exist in a sandbox, far removed from the actual game. They merely react to events by setting properties on objects or creating new objects. They can't affect the user interface directly.  Just for learning the Roll20 API, I suggest some simple starter projects: Write a script that responds to the !parrot command and repeats the arguments back to chat with some small change, like adding "Polly says " to the front.  Write a script that reports the name of a token that is moved, and how far it went.  Write a script that whispers to the DM how many duplicate numbers where rolled in the last dice roll.  That should give you a nice tour of the API's features without being too ambitious.  As for scripts that would help the community, I'd say watch the forum for a while and see what people are asking about. Look for things that could be automated, or games with dice mechanics that aren't easily supported. Maybe find some old script that could be better abs polishing it up.  Be sure to ask lots of questions on your journey!
1607090567
timmaugh
Pro
API Scripter
Welcome to the world of R20 scripting! I think you'll find that everyone's answer to those questions will be different, depending on where they are in their development as coders when they try their hand at a script for the community... whether you're learning the javascript or whether you're used to javascript but now have to fly without access to the DOM while you learn the function hooks to the Roll20 backend. I think tracking down errors is universally difficult, given how the various scripts in your game are strung together and the line numbers are thrown off, but that's not anything you can't work through. I have only been on Roll20 a year and a bit, now, so I can also say that knowing what is already out in the scriptosphere is difficult, too. Am I recreating the wheel? Am I going the long way around to solve a problem someone else already cracked? The scripts don't just exist in the Roll20 Git Repo... they are in Gists, in personal Repos, and just in posts in the forums. There is a movement underway... slowly... to try to get arms around that to help both scripters and script-consumers find what they're looking for. If you're looking for a starter project, I would look for something that interests you and will hold your attention while you work out the kinks of coding for the API. Find a niche that matters to you and dive in. My first script was revamping and expanding an existing script (by GiGs) for a game system (Hero) that wasn't seeing a lot of other development, so I was fairly confident I wasn't duplicating another development path. Of course, it also means that it didn't see a lot of consumption, either. =D Good luck, and post with questions along the way. I think you'll find the community is super supportive.