Skip to content

Instantly share code, notes, and snippets.

@SCPRedMage
SCPRedMage / generate-spellbook.js
Last active March 15, 2016 04:44
Updated to only grab spellclass if we're filtering for it.
function getCharacterObj(obj) {
"use strict";
//send any object and returns the associated character object
//returns character object for attribute, token/graphic, and ability, and... character
var objType = obj._type,
att, characterObj, tok;
if ((objType !== "attribute") && (objType !== "graphic") && (objType !== "character")) {
function getAttributeObjects(characterObj,attributeArray) {
"use strict";
var i,
j = 0,
attributeObjArray = [],
attributeValue = [] ;
// can pass array of attribute strings or a single attribute string along with an associated character
// returns those attributes as an object array or returns false if they do not exist on the passed character.
on("add:character", function(obj) {
// If there aren't any ability objects to grab, then we're probably in the middle of a sandbox spin-up
if (findObjs({ _type: "ability"}).length === 0)
return;
var abil = findObjs({ _type: "ability", _characterid: obj.id});
if (abil.length === 0) // Only create the abilities if the character doesn't have any
{
createObj("ability", {
name: "Init",
@SCPRedMage
SCPRedMage / Skillbook.js
Last active March 14, 2016 16:34
Updated to include extra Artistry and Lore skills on the current beta version of the character sheet.
function getCharacterObj(obj) {
"use strict";
//send any object and returns the associated character object
//returns character object for attribute, token/graphic, and ability, and... character
var objType = obj._type,
att, characterObj, tok;
if ((objType !== "attribute") && (objType !== "graphic") && (objType !== "character")) {
var HLImport = HLImport || (function() {
'use strict';
var version = '0.5',
lastUpdate = 1457920161,
skillsAttr = ["acrobatics-ability", "acrobatics-cs", "acrobatics-ranks", "acrobatics-class", "acrobatics-ability-mod", "acrobatics-racial", "acrobatics-feat", "acrobatics-item", "acrobatics-size", "acrobatics-acp", "acrobatics-misc", "acrobatics-reqtrain", "artistry-ability", "artistry-cs", "artistry-ranks", "artistry-class", "artistry-ability-mod", "artistry-racial", "artistry-feat", "artistry-item", "artistry-size", "artistry-acp", "artistry-misc", "artistry-reqtrain", "artistry2-ability", "artistry2-cs", "artistry2-ranks", "artistry2-class", "artistry2-ability-mod", "artistry2-racial", "artistry2-feat", "artistry2-item", "artistry2-size", "artistry2-acp", "artistry2-misc", "artistry2-reqtrain", "artistry3-ability", "artistry3-cs", "artistry3-ranks", "artistry3-class", "artistry3-ability-mod", "artistry3-racial", "artistry3-feat", "artistry3-item", "artistry3-size", "artistry3-acp", "artistry3-misc
var TokenSync = TokenSync || (function() {
'use strict';
var version = '1.0',
lastUpdate = 1458191219,
syncable = [ "imgsrc", "bar1_link", "bar2_link", "bar3_link", "width", "height", "rotation", "layer", "isdrawing", "flipv", "fliph", "name", "aura1_radius", "aura2_radius", "aura1_color", "aura2_color", "aura1_square", "aura2_square", "tint_color", "statusmarkers", "showname", "showplayers_name", "showplayers_bar1", "showplayers_bar2", "showplayers_bar3", "showplayers_aura1", "showplayers_aura2", "light_radius", "light_dimradius", "light_otherplayers", "light_hassight", "light_angle", "light_losangle", "light_multiplier" ],
syncAll = "imgsrc|bar1_link|bar2_link|bar3_link|width|height|rotation|layer|isdrawing|flipv|fliph|name|aura1_radius|aura2_radius|aura1_color|aura2_color|aura1_square|aura2_square|tint_color|statusmarkers|showname|showplayers_name|showplayers_bar1|showplayers_bar2|showplayers_bar3|showplayers_aura1|showplayers_aura2|light_radius|light_dimradius|light_otherplayers|light_hass
@SCPRedMage
SCPRedMage / TokenSync.js
Last active March 18, 2016 17:22
TokenSync v1.6
var TokenSync = TokenSync || (function() {
'use strict';
var version = '1.6',
lastUpdate = 1458321490,
syncable = [ "imgsrc", "bar1_link", "bar2_link", "bar3_link", "width", "height", "rotation", "layer", "isdrawing", "flipv", "fliph", "name", "aura1_radius", "aura2_radius", "aura1_color", "aura2_color", "aura1_square", "aura2_square", "tint_color", "statusmarkers", "showname", "showplayers_name", "showplayers_bar1", "showplayers_bar2", "showplayers_bar3", "showplayers_aura1", "showplayers_aura2", "light_radius", "light_dimradius", "light_otherplayers", "light_hassight", "light_angle", "light_losangle", "light_multiplier" ],
propsListened,
syncProperty = function(updatedToken, properties) {
var propList = _.intersection(
This file has been truncated, but you can view the full file.
<!--spacer so scrollbar does not disappear-->
<div style="width:1px; height:600px; min-height:600px;position:absolute;left:1px;">&nbsp;</div>
<header>
<div role="contentinfo" aria-label="Announces changes to sheet">
<h2 style="font-weight:bold;color:red;font-size:1.2em;">Attention:</h2>
<label for="pf_acknowledge" class="sheet-sect sheet-inline-label">Acknowledge:</label>
<input id="pf_acknowledge" type="checkbox" class="sheet-sect-show sheet-ack-button" name="attr_attention3-show" value="1" style="width:115px; margin:-5px -15px 0 -100px;" checked="checked" /><span></span>
<span class="sheet-label-a">Labels have a for attribute, but due to Roll20 keeping multiple copies of pages in memory, you cannot use the for tag to jump to the input. We will endeavor to keep all labels just before the associated input in the page code.</span>
<span class="sheet-label-a">Screenreader users please turn on reading of <em>Title</em> attributes. Most inputs have titles describing them, but not yet labels.</span>
@SCPRedMage
SCPRedMage / AttackSpell.js
Created May 28, 2016 18:11
Sheet Worker to compile attacks and spells into template macros
function updateAttackMacro()
{
var baseMacro = "/w \"@{character_name}\" &{template:pf_generic} @{toggle_accessible_flag} @{toggle_rounded_flag}{{color=@{rolltemplate_color}}} {{header_image=@{header_image-pf_attack-melee}}} {{character_name=@{character_name}}} {{character_id=@{character_id}}} {{subtitle}} {{name=Attacks}}";
getSectionIDs("repeating_weapon", function(idarray) {
getAttrs(["_reporder_repeating_weapon"], function(repValues) {
getAttrs(_.map(idarray,function(id) { return "repeating_weapon_"+id+"_attack-type"; }), function(values) {
var repList = repValues._reporder_repeating_weapon.split(",");
repList = _.map(repList,function(ID) { return ID.toLowerCase(); });
var orderedList = _.union(repList,idarray);
var attackIDList = _.object(_.map(orderedList,function(id) {
@SCPRedMage
SCPRedMage / HL-import.js
Last active January 4, 2017 03:36
Roll20 Hero Lab Pathfinder import script
var HLImport = HLImport || (function() {
'use strict';
var version = '0.8',
lastUpdate = 1483500397,
skillsAttr = ["acrobatics-ability", "acrobatics-cs", "acrobatics-ranks", "acrobatics-class", "acrobatics-ability-mod", "acrobatics-racial", "acrobatics-feat", "acrobatics-item", "acrobatics-size", "acrobatics-acp", "acrobatics-misc", "acrobatics-reqtrain", "artistry-ability", "artistry-cs", "artistry-ranks", "artistry-class", "artistry-ability-mod", "artistry-racial", "artistry-feat", "artistry-item", "artistry-size", "artistry-acp", "artistry-misc", "artistry-reqtrain", "artistry2-ability", "artistry2-cs", "artistry2-ranks", "artistry2-class", "artistry2-ability-mod", "artistry2-racial", "artistry2-feat", "artistry2-item", "artistry2-size", "artistry2-acp", "artistry2-misc", "artistry2-reqtrain", "artistry3-ability", "artistry3-cs", "artistry3-ranks", "artistry3-class", "artistry3-ability-mod", "artistry3-racial", "artistry3-feat", "artistry3-item", "artistry3-size", "artistry3-acp", "artistry