Skip to content

Instantly share code, notes, and snippets.

View Cazra's full-sized avatar

Ada Lindberg Cazra

View GitHub Profile
var MarchingOrder = (() => {
'use strict';
/**
* A line segment consisting of 2 vec3s defining its endpoints.
* @typedef {vec3[]} Segment
*/
/**
* A wrapper around a follower token. This includes positioning information
/**
* PathMath script
*
* This is a library that provides mathematical operations involving Paths.
* It intended to be used by other scripts and has no stand-alone
* functionality of its own. All the library's operations are exposed by the
* PathMath object created by this script.
*/
var PathMath = (() => {
'use strict';
/**
* A small library for testing collisions between moving tokens in Roll20.
*/
var TokenCollisions = (() => {
'use strict';
/**
* An object encapsulating a collision between two tokens and the point
* of collision.
* @typedef {object} Collision
@Cazra
Cazra / gist:8347581
Created January 10, 2014 05:54
roll20 API familiar summon (broken)
// This script allows the players to summon their familiars.
// When summoned, the familiar appears in their
// master's square.
on("chat:message", function(msg) {
var cmdName = "!familiar";
var msgTxt = msg.content;
var curPageID = Campaign().get("playerpageid");
// map of familiars to images.
var familiarImages = {};
@Cazra
Cazra / gist:8059943
Last active December 31, 2015 23:28
Roll20 API script: Checks if a character token moved through a trapped square during its movement.
/**
* A script that checks the interpolation of a token's movement to detect
* whether they have passed through a square containing a trap.
*
* A trap can be any token on the GM layer for which the cobweb status is
* active. Flying tokens (ones with the fluffy-wing status or angel-outfit
* status active) will not set off traps unless the traps are also flying.
*
* This script works best for square traps equal or less than 2x2 squares or
* circular traps of any size.
@Cazra
Cazra / gist:5792605
Last active December 18, 2015 13:49
roll20 api script for having tokens be able to carry other tokens.
/**
* A set of chat commands used to set tokens to carry other tokens.
* When a token moves, the any tokens it is carrying move to its new location.
*
* The following commands are available:
* !carry [carrierName], [carriedName'] Tells your token specified by carrierName
* to carry another token. The carried token will remain in place
* uder the carrier token.
* !drop [carrierName], [carriedName] Tells your token to drop a carried token.
* !dropAll [carrierName] Tells your token to drop all carried tokens.
@Cazra
Cazra / gist:5771375
Last active December 18, 2015 10:49
roll20 Marching Order script.
/**
* A set of chat commands used to specify a marching order.
* When a token moves, the one behind it in the marching order will move to its
* former location recursively.
*
* The following commands are available:
* !follow [myTokName], [leaderName] Tells your token specifed by myTokName
* to follow another token specified by leaderName.
* !unfollow [myTokName] Makes your token stop following other tokens.
* You can also have a token stop following another token just by
@Cazra
Cazra / gist:5765350
Created June 12, 2013 13:42
Java String utility Converts all decimal integers in a string to hex.
/**
* Converts all decimal numbers in a string to hex.
* @param src The source string, possibly containing decimal numbers.
* @return The source string with all decimal numbers replaced by
* their equivalent hex numbers.
*/
public static String decimalInStringToHex(String src) {
String result = "";
int last = 0;
@Cazra
Cazra / gist:5737747
Created June 9, 2013 05:23
roll20 character token locator script
// This is a script for a chat command that can be used to find a character
// token you've misplaced on the map. It can work two ways:
// You can specify a token by name, say "Dave the Dwarf", with
// !find Dave the Dwarf
// or you can find the token for your character with
// !find me
//
// How it works is it generates a very large temporary aura on the token.
// The aura shrinks and you can follow it in.
//
@Cazra
Cazra / gist:5737453
Last active December 18, 2015 06:08
This is a script for a "heal" chat command for the roll20 virtual tabletop API.
// This is a "heal" chat command for the roll20 virtual tabletop API.
// It can be used to heal all 3 bars for a token by name,
// or you can have it heal the tokens for all the characters in your campaign's journal.
//
// E.g:
// Healing one character named "Dave the Dwarf":
// !heal Dave the Dwarf
//
// Healing all characters
// !heal all