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

Newbie question - Setup/prepare Javascript

September 24 (10 years ago)
Hello all,
I have been a Tabletop GM for many years (D&D then moved to Pathfinder). Life has caused my players to move around the country which has led me to roll20.net. So far it has been a great tool with a lot of flexibility. I have been playing with macros to meet my automated needs but looking for more flexibility which led me to start supporting roll20 for the API capability.

Here is where I am needing help so please be patient. I have experience with Java using Eclipse dev tools. However, I do not use Java enough to stay efficient at it but as with most of us I dabble in it and use trial and error. I have installed the necessary Javascript packages to Eclipse but not sure how to proceed.

My newbie question, are there any roll20 libraries that I can import into Eclipse so I can code and test? Or is all the coding handled within the roll20 browser itself? If anyone has a "How to" or any data they can share that would be greatly appreciated.

Thanks again,
Nic

September 24 (10 years ago)
The Aaron
Roll20 Production Team
API Scripter
Hi Nic! Welcome to Roll20 and the API.

The one Library you have access to on Roll20 is Underscore.js. The rest of Roll20's APIs are custom and built in. If you're trying to get started in the API and hone your Javascript skills, I highly recommend Javascript: The Good Parts by Douglas Crockford.

Here's an overview of my development process for API Scripts:

On my Local Machine:
  1. Create JS file (often I start with some Boiler plate I've developed for my scripts)
  2. Write outline of features in comments
  3. Implement minimal features
  4. Run JSLint on the file
    • While there are problems, go back to 3
  5. Copy contents of file
On Roll20 API page:
  1. Paste contents of script
  2. Save
  3. Test features in VTT
  4. Add Logging to verify behavior of find issues
Return to Local Machine step 3.

When I'm done, I copy the contents of the local file into a Gist, then update it to include a link to the Gist (that way, if people are using it, they know where to go to get the latest version).

Hope that helps, and don't be afraid to ask anything!
September 24 (10 years ago)
Aaron,
Thank you very much! That is exactly what I was looking for to get started. I haven't added a "Topic for Dummies" book on my shelf for quite some time so thanks for the recommendation.


September 24 (10 years ago)
The Aaron
Roll20 Production Team
API Scripter
No worries!

Also, I wouldn't say that Javascript: The Good Parts is for dummies, it's written by the author of JSLint and the creator of JSON encoding. =D But it is well written, easy to ready and pretty thurough. =-D
September 24 (10 years ago)
The Aaron
Roll20 Production Team
API Scripter
A while back, I was working on setting up a REPL for Roll20 that would mock out all the functions and allow you to preload an existing game state so that you could write UnitTests and do development locally. I actually go done with the hard parts, but I decided it was more effort than just creating a test campaign so I haven't finished it.
September 24 (10 years ago)
That would be an excellent testing environment! This will be my first taste in Javascript but it can not be much different then Java or .Net. Thanks again. Looking forward to playing around.
September 24 (10 years ago)
The Aaron
Roll20 Production Team
API Scripter
Ah, it is VERY different in a few key places (Scope, Inheritance, etc). If you're experienced in Java and.Net, I especially recommend that book, as it will point out those places and how to use them effectively.
September 24 (10 years ago)
Purchased on Amazon and waiting for the quick shipping. :)

Quick question though. Where are the log files? I did some searching and see the console.log() method but I could not find info on log(). I brought up the Chrome Dev tools and also even changed the .js to use console.log which produced errors. Again, sorry for the newbie question and I am sure the book will assist when it arrives.
September 24 (10 years ago)

Edited September 24 (10 years ago)
The Aaron
Roll20 Production Team
API Scripter
No worries. :)

There's a little black box below the scripts on the API Details page. All the log() calls print there.