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.

Advertisements

Gurutama Language Map

Language Map

Last night I made a map representing the relationships between different languages in Gurutama.

Since I am playing on using the Hackmaster rule system for Gurutama I modeled the relations between the languages on how languages work in Hackmaster.

Languages are treated as skills in Hackmaster with proficiencies ranging from 0-100%.

0-25% is when you know a few words in the other language. Most Californians have at least this much understanding of Spanish.

26-50% is when someone knows how to construct sentence frames, but can’t really carry a conversation. Someone who’s still learning the language.

51-75% is when someone knows enough to go on vacation to another country and speak that country’s language, but not enough to have a conversation about philosophy or something. My wife and I probably have this level of proficiency with Spanish.

76-87% is a normal mastery of a language. Hackmaster treats this level as the amount most people have in their native language.

88-100% is when someone knows lots of fancy words in their language. My dad has a PhD in linguistics, so he probably falls into this range.

That should give you a better idea of what the penalties listed in the image above mean.

Lets say that English is Merese on that map up there. My dad with his PhD in English linguistics would have around 20% mastery of a language that English borrows words from, like Swedish. He’d recognize a few cognates between the languages and he might know how to construct sentences, but he can’t really speak Swedish.

I’d guess that I have around 60% proficiency in Spanish. French is a very similar language. Everyone else in my family spoke French occasionally when I was growing up and the little bit of Spanish I know allowed me to understand the gist of the conversation even if I couldn’t participate. French and Spanish would be considered divergent languages in the Hackmaster system (along with Portuguese, Italian, Romanian, etc.).

A few of the languages up there might not be recognizably from Gurutama. Some of those are for monster races like trolls, giants, and orcs. The others, like Krangi, Lathlani, and Sqwuani, are for a few of the main races. Krangi is Hobgoblin, Lathlani is Elven, and Sqwuani is Avian.

The other members of my D&D group are getting a little more interested in Gurutama lately and there was talk of setting up a wiki for the campaign setting so everyone could edit and add stuff on.

If the wiki is set up I’ll start moving content there. The stuff I create will still be posted here but my friends can’t make the same promise.

That’s it for today!

-GoCorral

Town of Salem

Main Screen

One of my friends showed me a new game this weekend called Town of Salem.

Town of Salem is a Flash game produced by Blank Media Games that you play in your web browser. The company recently finished a successful Kickstarter campaign to fund mobile versions of the game, an independent PC client, and translations to play the game in other languages. The Kickstarter just finished so those projects are all still in the works.

The game is a more fleshed out version of the party game, Mafia.

For those of you who haven’t played Mafia, it’s pretty simple. All the players sit in a circle and are secretly assigned roles.

The game is effectively split into two teams, the Mafia and the Townies.

The Mafia want to take over the town by killing everyone and the Townies want to live, which means hanging the Mafia members after a swift trial.

There are fewer Mafia than Townies, but the Townies don’t know who the Mafia are.

The game is played in a series of days and nights. The party game simulates night by having everyone close their eyes and put their heads down.

At night the Mafia wake up and silently decide who to kill that night by pointing at people and gesturing wildly. In Town of Salem they can still talk by typing to each other secretly.

In the morning that person is dead and the Townies can vote to hang someone for the murder.

There are a few other roles that occasionally get included in the party game. The Doctor can heal someone each night and prevent the Mafia from killing them. The Sheriff can investigate someone and find out if they’re Mafia or not. Other stuff like that.

Town of Salem gives a special role to everyone. There are Mayors, Lookouts, Escorts, Mediums, Framers, Jesters, Executioners, Jailors. Tons of roles! There’s so many that a wiki page was created to keep track of them.

Town of Salem takes all the intrigue and guess work of Mafia and turns it into an easy to pick up internet game.

Each game has fifteen players. There are a couple different modes, but the classic mode has 3 Mafia members, 3 Neutral people who have their own agenda outside of killing all the Townies or all the Mafia, and 9 Townies that want to eliminate all the evil people like the Mafia or the Serial Killer role.

The game is just like the party game. People die each night and the Townies try to figure out who did it while the Mafia spread misinformation among the townsfolk.

Its a lot of fun and super quick to play as well. You can try it out at Blank Media Games if you’re interested. I’ve also posted a Youtube clip of one of my games with my friends for your viewing pleasure.

-Mister Ed

The Giver Movie Review

The Giver Movie Poster

My wife and I went on a date last weekend to see The Giver and we both really liked the movie.

It was a faithful adaption of the book and I felt it was a good movie on its own as well.

There are a few additions to the movie and a few things removed as well. Of course this sort of thing always happens in movie adaptions of books.

For example, Two scenes that I really enjoyed were not present in the movie, Jonas tossing an apple and seeing it turn red in the air, and a more direct explanation of precise language that Jonas receives from his parents.

In the book, Jonas says he is starving. His parents correct him and say that he is only hungry, not starving.

The movie skips that scene, but contains plenty of other pieces of dialogue that illustrate the precise use of language the people have developed in The Giver‘s utopia.

My wife was disappointed that the movie did not include the variety of gifts the children receive for each year of advancement. Only the bike at year nine is in the movie.

The special effects and acting in the movie were excellent. I loved that it switched back and forth between black and white and color. Jeff Bridges and Meryl Streep were amazing as always and the young actors put forward impressive performances as well.

My wife’s major complaint (and I agree with her) was that the movie was too short. It’s only about an hour and a half long. The movie could’ve easily been lengthened and included all the things that we missed from the book.

I’d definitely recommend the movie for those who enjoyed the book or for people who get as excited about utopia/dystopia stories as I do.

Oh! And fair warning, Taylor Swift is in this movie and it utterly destroys your suspension of disbelief when she shows up.

-Mister Ed

Gurutama Timeline Revising Part 1

One of the problems that comes up in D&D is whether races are capitalized.

English is clear on that topic. African is capitalized because its a continental descriptor, but black is not because physical descriptors are less important.

Hobgoblin is a race in D&D, but is it a “nationality” or a physical descriptor?

The issue becomes more confused when languages are considered.

In D&D a race’s native language is often just referred to by that race’s name. Elves speak Elven. Hobgoblins speak Goblin.

The simplest way out for me was to just capitalize all races all the time, so I will be attempting to do that as I go forward with the work on Gurutama. This includes Human, Dwarf, Elf, and anything else that would not normally be capitalized in English.

4121 BE: The Merfolk came into existence and their god was Drolfo Sitnalta, god of the sea.

4037 BE: Drolfo told his followers to build a city between the islands of the Maw. The Merfolk named the city Drolfo’s Cove in honor of their god.

3983 BE: On the island, Rontu-Aru, the great egg mother, Izquitl, needed a perch, so she created Cui-Xoloc, the tallest mountain in the world, to rest upon. Cui-Xoloc rose sheer faced, miles into the sky, dividing the southern island-continent in two. An enormous waterfall sprung off the north side of the mountain, joining the river leading to the ocean.

3837 BE: Izquitl needed beauty and love and blood, so she called up Hrududu, a vast rainforest covering the eastern half of Rontu-Aru. Izquitl needed more, so she started to sing the first song of the world. The many birds of Hrududu listened and when she stopped her song the birds had taken on tall forms and gained intelligence not present in their lesser cousins. The Avians took flight.

3734 BE: Into the world came Humankind, timid and savage, knowing not from whence they came but living ever in decadent fear of the great fiery abyssal volcano, their own window into the beating heart of the world. The mountains grew up around the Humans for their fear of the outside world was even greater than the terror within the inferno.

3654 BE: The Dwarves knew that the world came and went in cycles just like the seasons. They knew how to survive the cataclysms and be reborn afterwards. They had buried themselves deep, deep within the earth. The Dwarves crawled up out of the dirt and rocks in the mountains in the west. They looked at the new world around them and said, “Oi! Whot’s all this then? The old one was better!”

The Dwarven chieftain calmed his people, “Calm thyselves! Have we not read that it takes time for a new world to ripen? We shalt go back into the ground until this Earth is ready for our holy presence.”

“Aye! The chieftain is wise! Into the ground again!”

The Dwarves got out their picks and shovels to create a new home in the new world. They would venture out of the mountains once the world “ripened.” For what purpose would they venture out? Only the writing in the Books they preserved between each generation could tell.

 

A few minor edits, but not much to do for this first part. I’ve considered taking out the parts about physical features of the world, but there’s nothing major here. Besides, what’s the difference between myth and legend for history this old?

-Mister Ed

Next: Gurutama Timeline Revising Part 2

Cartoon History

20140401-175524.jpg
I said in a previous post that I’m reading the Cartoon History of the Universe Part 3. Here’s the page I’m on now about Japanese civilization.

The Cartoon History series is now complete with five books. The first three are called Cartoon History of the Universe Parts 1-3 and the second two are called Cartoon History of the Modern World Parts 1-2.

The author’s name is Larry Gonick. He does a bunch of other cartoon non-fiction books as well.

I own Larry Gonick’s Cartoon Guide to Physics, Cartoon Guide to Chemistry, and his Cartoon History of the United States.

All his books are funny, informative, and quick to read. You can check out more of them at his simple website, www.larrygonick.com

I started reading the series in third grade when I was homeschooled by my parents.

Only the first two books existed then. I’ve read them cover to cover dozens of times since. This repeated reading is probably why I know so much about ancient history, but a lot less about anything after the fall of Rome.

I showed the books to my father-in-law recently because he was interested in the Roman Empire and the Holy Roman Empires.

His reaction upon flipping through them was surprise at the vast amount of sex in them.

Gonick doesn’t shy away from portraying the sexual scandals in his books. If sex between two people influenced their actions and their actions affected history, then he includes the sex.

I read the books when I was eight if that matters to anyone.

Gonick also writes a comic feature for the children’s science magazine, Muse. The magazine is written for ages 10-14.

The feature is a page comic of archetypal philosophers from different cultures talking with each other.

The philosophers also fool around and crack jokes in the margins of other articles throughout the magazine.

I’m rereading the later three Cartoon History books now so that I can fill the gaps in my natural recall of different historical periods.

I’ll probably need to reread it another dozen times before my recall of anything past 500AD is perfect, but I’m hoping that I’ll get there!

That’s all for tonight!

-Mister Ed