Roll20’s API Scripts

Continuing from my previous post about Roll20, I wanted to talk about how script writing for Roll20 works and the particulars of the script I’m writing.

Roll20 has something called an API (Application Programming Interface) a term that the programmers reading this are already aware of, but one which I had to look up while writing this.

Behind all the fancy jargon I read, an API is a way to write and test programming code.

The simplest “API” is something like Notepad. You can design a program in it, but Notepad won’t run your program or tell you where you messed up.

There are more complicated APIs track syntax errors in your code, color the different key words, point out where you messed up, and even let you test run your code.

Roll20’s API tracks syntax and color codes. It tells you IF you messed up, but not WHERE. So when there is inevitably a problem you get to play hide and seek until you find it.

Every API is designed for a specific programming language. Roll20 uses Javascript.

I didn’t know any Javascript going into this.

I’m familiar with the basics of programming. I’ve taught myself a little bit of Python, I took a course on C in college, and I know a little about Perl and HTML* from various places.
*Not exactly a programming language but I’ll bet that nobody really cares.

To learn the particulars of Javascript I started taking a course on CodeAcademy.

The CodeAcademy course is pretty cool! Nice assisting prompts. A little poor on alternative ways of solving the problems, but that’s actually a good thing for programming courses.

I learned a little about Javascript from that, enough to write the program I wanted to for Roll20.

And what program is that? Something to automatically spit out the results of a critical hit in Hackmaster!

Hackmaster is a game like D&D that I play with my friends sometimes. Hackmaster has a ton of cool rules that make the game quite a bit more fun and shocking than D&D.

One of those rules is what happens when you hit your opponent real good. Depending on your height advantage over your opponent, the weapon you used, and how hard you hit, a special event occurs.

Why do I want a program for that? Well… Take a look.

Critical hit chart comes with lion and everything else you see here.
Critical hit chart comes with lion and everything else you see here.

There are about twenty pages like this that just go on and on.

It’s a bit much to flip through all those pages, cross reference with the different numbers you need, and then trail your finger down the chart to see what happens.

Instead, why not have a program do the work for you?

The program is started when a player uses the Critical Hit macro. Remember how macros can ask for values? That’s all the Critical Hit macro does. No dice are rolled.

The Critical Hit macro asks for seven different values: your size, your opponent’s size, your attack roll, your opponent’s defense roll, your damage roll, your opponent’s armor strength, and the type of weapon you’re using (Crushing, Hacking, or Piercing).

Next comes the script. The script is triggered when the Critical Hit macro is entered.

Nowhere near Matrix levels of code yet.
Nowhere near Matrix levels of code yet.

I looked around on Roll20’s forums and found the skeletons of some other scripts to use for the script to take information out of the Critical Hit macro and use it in the program.

From there, the script rolls a several thousand sided die that represents the location hit by the critical with different sized dice depending on the difference between the attacker’s and the defender’s sizes.

After getting that roll, the script enters a gigantic ~3,000 line long if/else tree that serves in place of the twenty page table. This comes up with a different results based on the location of the blow, how hard the target was hit, and what type of weapon was used.

Finally, the program spits out the result into Roll20’s chat along with some background information to make sure that it worked correctly.

Does the code work? Well, I don’t know yet. I’ve been typing away at it for about a week now and have transferred roughly one fifth of that giant table in the book to the programming script.

Due to how I structured the code, I can’t tell if it works correctly until I finish the whole thing.

Unfortunate, but what can I do at this point?

So here’s hoping that when I’m done in a few weeks and I press that Critical Hit macro button, it runs as smooth as melted chocolate.

If not, then I’ll probably have a blog post to make about code debugging…

-GoCorral

P.S. If you play Hackmaster and are interested in this code I will be posting the completed version of it on the Roll20 forums and the Hackmaster forums once I’ve finished. I’m also planning on doing a similar thing for the Fumble charts for Hackmaster so stay tuned for those as well.

Windows 10 Upgrade

One of the gifts I asked for and received for Christmas was some new RAM for my computer.

RAM is what your computer uses when it’s actually running programs. More RAM means your programs will run smoother and you’ll be able to run more of them (with some limitations).

I wanted the extra RAM to help with issues I’ve had in the past when I’m running programs in the background while playing a game. Things like Skype, my recording software for streaming, or just leaving Chrome open with a guide to the game.

In the past these things have slowed the game down a little bit, but not so much anymore!

I upgraded from 8GB of RAM to 24GB. I should be able to run three times as many programs, right?

Turns out that’s not the case. My current operating system, Windows 7, throttles the RAM my computer can use at 16GB.

Windows 10, however, lets me use up to 128GB of RAM. Far more than I will ever need.

And as you may have heard, Windows is offering a free downloadable upgrade to Windows 10 on all Windows 7 and 8 machines.

Setag liah! Setag liah!
Setag llib liah! Setag llib liah!

I’ve been reluctant to go through with the upgrade for a number of reasons.

First, bad reviews. Most of the reviews of Windows 10 are bad. That’s par for the course when a new operating system comes out though.

My dad has tried Windows 10 out and he hasn’t noticed any serious problems which was encouraging.

Second, detailed reviews that talk about the increased bloat of the operating system and annoying default features that spy on your computer for Microsoft.

The operating system bloat shouldn’t be a problem. Even if Windows 10 uses a whole 1GB more of RAM then Windows 7 I’ll still be 7GB up on what I previously had.

The spying is annoying, but since I can turn it off I’m not too concerned about it.

My third and final concern is whether all my programs will continue to run on Windows 10.

Most, if not all, of my games will continue to work on Windows 10 according to this community list.

I’d be shocked if Microsoft Office and Google Chrome didn’t transfer over fine.

That leaves just my streaming software.

While the upgrade was initially to get more use out of the streaming software, I haven’t seriously touched the stuff in about a year. Maybe it’s not so big a deal if it doesn’t work?

Anyways, I’ll be making a jump into Windows 10 tonight. If I don’t update the blog next week it’s probably because Windows 10 caused my computer to go up in flames and burn down my house.

Here’s hoping that doesn’t happen.

Crossed Fingers

-GoCorral

Writing for Master’s

The guidelines for how to prove you are a competent writer for Sac State's Master's Program.
The guidelines for how to prove you are a competent writer for Sac State’s Master’s Program.

I ended up getting rejected from the other program I applied to so I accepted Sac State’s offer of admission last week.

Sac State has a typical biology Master’s program. I’m reading up more on the specifics lately.

One of the things I found is pictured above, a writing test.

Sac State wants to know that its Master’s students can write competently.

A competent writer reflects well on the college and honestly, they wouldn’t be doing their job if they didn’t make sure their graduates were good writers.

I like to think of myself as a good writer. I do this blog after all don’t I?

I’m published in a magazine too. I’m a successful amateur for sure!

But they have higher qualifications for themselves.

So I can resign myself to taking a class on writing at Sac State (not so bad actually) or I can try and waive myself out of it.

First way to get out, already have a Master’s or PhD. NOPE!

Second way, publish an article in a peer-reviewed journal. Nope.

Third way, have an undergraduate GPA of 3.7. I’ve got a 3.55. Not quite there.

Fourth way, get a 4.5 on the writing section of the GRE. I got a 4.0. I could retake it though!

Fifth way, teach a writing class at a college. No again.

The second way was the most intriguing to me. I’m already working on a paper for a peer-reviewed journal.

I mentioned in a post on Alexander the Great a while back that I’m writing a paper on him.

The paper is basically finished at this point. I’ve gone through a lot of edits over the past two years with a lot of advice from very helpful friends, family, and friends of family.

I actually already submitted the paper for publication once in the Journal of Popular Culture. It was turned down.

This is pretty typical scholarly journals. The paper is never quite what they’re looking for.

So I was turned down, but with a list of revisions I could make to resubmit.

I finally sat down finished the revisions given by them and a few other helpers that read the paper since my first submission.

Now my most persistent helper is my favorite Classics professor when I was taking Classics as an undergrad. He gave me a more difficult edit, to try restructuring the conclusion section.

Right now the conclusion section is separated into paragraphs based on which source on Alexander I’m talking about.

The professor wants to see how it looks when the conclusion is split based on which topic I’m talking about.

I’m doubtful that it’ll be better. The conclusion already looks so good! I’ll give it a try though.

So tonight I’m going to stay up later and rewrite two pages on Alexander the Great’s modern image. Hopefully this version will get published and then Sac State will have proof that I’m a good writer. Wish me luck!

-Mister Ed

Quantum Roll

image

I mentioned that my group uses Roll20 to play D&D.

Roll20 started as a Kickstarter. They got successfully funded and released the beta to the backers before releasing the official version to everyone a bit later.

The folks who make Roll20 have a payment system common to most internet businesses.

The program is free to use if you’d like, but you can also pay a monthly or yearly fee to get access to new features sooner, more dataspace, and fewer ads. Pretty similar to WordPress’s system if you think about it.

Roll20 has an additional feature on their payment system though.

The website doesn’t have the vast following that WordPress has. They don’t make enough from ad revenue to keep the site going like WordPress does.

Roll20 relies almost entirely on people paying for the extra features. Thus is the site has a little tracker saying how many subscribers it needs to “keep the lights on.”

The tracker has other levels it can go up to though. There are a total of five different levels of support on the tracker.

The first level is keeping the servers on to support all the traffic that Roll20 gets.

The second level is having occasional updates done by the developers. This isn’t enough money for Roll20 to be their fulltime job, but its enough to convince them to work on weekends.

The third level is full time work by the developers. The tracker is currently a little ways into this level.

The fourth level pays for a publicist and additional developers to come up with system specific features for Roll20.

The fifth level allows for even more developers to be hired for projects beyond just Roll20.

With the third level not yet complete, the developers are coming out with occasional updates. The new one for May is a bit ridiculous. You can check it out on their blog post here: Quantum Roll

Random number generators on computers aren’t exactly random. It’s complicated to explain, but you can trust the programmers on this one. They wouldn’t lie about a deficiency that they have.

This is frustrating for some people that use Roll20. Real dice are random, shouldn’t virtual ones be random too?

The Roll20 development team has solved that problem by hooking its dice rolling program up to data from a light beam splitter in Australia.

The light splits randomly giving random data details. Roll20 uses those numbers to decide the outcome of a die rolled on the website.

It’s so ridiculous that most of Roll20’s fans have been calling it an April Fools joke or overkill for the problem.

My opinion? It’s a pretty damn cool way to solve the problem using freely available methods. I won’t notice while playing, but I like that the developers care.

That’s all for now!

-Mister Ed

Mapping Methods

Room 2 of the Lich Shade dungeon drawn using graph paper with notes on it.
Room 2 of the Lich Shade dungeon drawn using graph paper with notes on it.

There a lot of different styles of DMing in D&D and other roleplaying games.

You can wing it and come to each session with very little prepared.

You can come up with the adventure for each session in the week before.

You can also do what I do, make up the entire campaign before starting it.

Between each session I have almost no creative work to do for D&D. My campaign has been running for close to three years now and I’ve only had to design one adventure out of about a dozen since then.

It’s nice. I don’t need to spend extra time on the game for me and my friends to have a lot of fun.

I have started to run into a few issues though.

When I wrote the campaign I imagined my group would still manage to meet in person.

That proved to be horribly wrong. We have in person sessions about once a year now.

When I drew all my maps they looked like the one pictured above. I’d make them on a piece of yellow-green graph paper.

When they reached a room I’d draw with a wet-erase marker on a battle mat I brought to each session.

When the players defeated the monsters in one room I’d erase and draw the next room.

Dry erasing was easy, but creating good maps in our current system is a little difficult.

My group now plays over the internet using an internet browser program called Roll20.

Roll20 is really great. It has everything a tabletop has. You can even turn on a feature to see your dice roll across the table.

However, I can’t just grab a pen and draw on my monitor as easily as I draw on the battle mat used previously.

I suppose I could do that if I was used to creating digital images, but I’m not.

Instead I’ve taken to making lame looking maps or using a cool mapping software piece called GridMapper.

The second room of the Lich Shade dungeon made using GridMapper.
The second room of the Lich Shade dungeon made using GridMapper.

GridMapper is extremely simple. You pretty much just click to change stuff.

I can easily build maps in GridMapper. They don’t look amazing because it doesn’t come with preset images like trees and stuff, but they’re functional just like my dry erase mat.

GridMapper has one issue, it has a maximum image size. Easy to get around though, I just make two images and glue them together for really big rooms.

I’m slowly converting all my old pencil maps into GridMapper maps for Roll20 now.

That’s it for now!

-Mister Ed

Acceptance Wall

Normally I’d post something about D&D on Monday, but this week I’ll be showing off something that came in the mail recently.

My first graduate school acceptance letter.
My first graduate school acceptance letter.

I got into graduate school! Hurray! Validation!

This year I only applied to local schools as my wife is in the first year of a two year program for her teaching credential.

I applied to two programs at the college I got my undergraduate degree from and a third program at a nearby CSU (Sac State).

I’ve been rejected from one of the programs and have yet to hear back from the other one, but Sac State has accepted me! Woohoo!

Assuming the other program doesn’t accept me, I will be driving to the capital every day to learn and research science stuff.

The professor I’ve been placed with studies salmonella. I haven’t read up a lot on it, but what I saw on the papers she’s published was interesting.

Salmonella typically hurt your body in many ways one of which is by attacking your macrophage cells. Macrophages are the part of your immune system that eats bacterial invaders.

The salmonella bacteria don’t like being eaten by macrophages though. They protect themselves by putting poisons into your macrophages.

The professor has helped discover how this process works and she is attempting to harness the power of salmonella for good, not evil!

You see, if salmonella are so good at invading macrophages and killing them, they can also be used to invade macrophages and help them.

We can modify salmonella to make it deliver medicine to macrophages. This could do a number of things.

It could protect against auto-immune diseases like HIV. It could also super charge the immune system to assist the fight against other bacterial infections. These two things are some of the most sought after effects in medicine right now.

HIV is a huge problem throughout the developing world, so the interest in that is obvious.

The second effect, of boosting the immune system is even more amazing in my opinion.

Bacterial infections such as tuberculosis, STIs, and many others are currently treated with antibiotics. But bacteria can evolve and become immune to these antibiotics.

Researchers can come up with new antibiotics, but in a few years the disease will have evolved immunity to it again.

But what if you treated the disease just by making the immune system better? The bacteria can still evolve past this, but it takes much longer to do that than to develop antibiotic resistance. Possibly long enough that the disease can be eradicated entirely? That would be astounding.

While my original goal was to get entrance into a PhD program, working on making people immune to disease doesn’t sound that bad either. I think I’ll be quite happy at Sac State.

That’s all for tonight!

-Mister Ed