Skip to content

Instantly share code, notes, and snippets.

@goblinHordes
goblinHordes / pfsrd_import.js
Created November 19, 2013 02:50
Example import of Pathfinder SRD data
var monsterAttributes = ['AC', 'XP', 'CR', 'Size', 'HP', 'HD', 'Fort', 'Ref', 'Will',
'Str', 'Dex', 'Con', 'Int', 'Wis', 'Cha'];
var monsterManual = [
{
"Name": "Janiven",
"CR": "2",
"XP": "600",
"Race": "human",
"Class": "ranger 3",
@goblinHordes
goblinHordes / apicmd.r20.js
Last active December 28, 2015 01:59
apicmd.r20.js - Roll20 API hooks for apicmd
apicmd.on('apicmd', '[options] info',
[['-e', '--echo', 'echos the remaining arguments back to chat']],
function (msg, argv){
if(argv.opts.echo){
sendChat('API', '/desc ' + argv.args.join(' '));
return;
};
});
on('chat:message', function(msg) {
@goblinHordes
goblinHordes / apicmd.js
Last active December 28, 2015 01:59
apicmd.js - Command line style parser and option handling based on Optparse.js
// Stripped down version Optparse.js
// Optparse.js Copyright (c) 2009 Johan Dahlberg (MIT License)
var optparse = {};
var apicmd = {};
(function(self) {
var LONG_SWITCH_RE = /^--\w+/;
var SHORT_SWITCH_RE = /^-\w$/;
var NUMBER_RE = /^(0x[A-Fa-f0-9]+)|([0-9]+\.[0-9]+)|(\d+)$/;
@goblinHordes
goblinHordes / lookup.js
Created November 5, 2013 05:22
Lookup Tables - Roll20 API
var tables = {
critical_hits : [
"stubbed a toe", //1
"broke a finger", //2
"lost a limb", //3
"decapitated" //4
],
flavor_text : [
"in a turn of luck",
@goblinHordes
goblinHordes / BFRpg.chargen.js
Created October 30, 2013 06:31
Basic Fantasy Role-Playing Game, Random PC Generator for Roll20 API
on("chat:message", function(msg) {
if(msg.type == "api" && msg.content.indexOf("!random_pc") !== -1) {
try {
options = JSON.parse(msg.content.substring(10));
} catch( err ) { options = {} }
pc = BFRpg.PlayerCharacter.random(options);
/*
newChar = createObj('character', {name:pc.fullname()});
@goblinHordes
goblinHordes / BFRpg.js
Created October 30, 2013 05:45
BFRpg.js - Basic Fantasy Role-Playing Game for Roll20 API
Function.prototype.inheritsFrom = function( parentClassOrObject ){
if ( parentClassOrObject.constructor == Function )
{
//Normal Inheritance
this.prototype = new parentClassOrObject;
this.prototype.constructor = this;
this.prototype.parent = parentClassOrObject.prototype;
// establish ActiveObject namespace
var ActiveObjects = ActiveObjects || {}
// create namespace shortcut
AO = ActiveObjects;
/*
ActiveObjects.Object - adds persistent state storage to R20 objects
@param {id} ID of Roll20 object.
*/
AO.Object = function (state){
@goblinHordes
goblinHordes / CommandDoors.js
Last active March 31, 2018 23:22
CommandDoors for Roll20 API Use CommandTokens to toggle open/closed states for doors, including wall modification for dynamic lighting.
/*
CommandDoors
Use CommandTokens to toggle open/closed states for doors, including wall modification for dynamic lighting.
Requires: CommandTokens.js
Once configured, doors are easy to use - simply move the associated CommandToken to toggle the door from open
to closed and back again. Configuring the doors takes a bit of work, but there is a helper function to
make the process pretty easy.
Before configuring a door, first look at the components of a CommandDoor. A CommandDoor consists of three tokens
@goblinHordes
goblinHordes / CommandTokens.js
Last active December 25, 2015 01:19
CommandTokens for Roll20 API Associate tokens to API functions and trigger functions when the token is moved.
/*
CommandTokens
Associate tokens to API functions and trigger functions when the token is moved.
CommandTokens provide an easy way to trigger API functions without typing or complicated layer manipulation by the GM.
CommandTokens are powered through an ugly-but-effective naming convention:
__[function]_(:[variable_1]:[variable_2]...)__
where [function] is the function to call and the [variable_x] elements are replaced by a colon delimited list
of parameters to pass to the function. Parameters are optional (as long as the underlying function is ok with that)
and do not require a trailing colon.