Skip to content

Instantly share code, notes, and snippets.

@Bastlifa
Bastlifa / gist:8a8ae5eae5696b4452e0af36a171bce3
Last active August 18, 2017 17:39
Roll20 API Script for Stress Levels
/****Stress Level Script for Matt C.****
Select a token. Click stress macro. The
macro will automatically roll some dice
and add the result to bar 3, up to 200.
If the threshold 100 is reached, a sound
will play. It will also post to chat for
any stress increase. Finally, there's a
stress reset.
You'll need to mod it to play sound.
@Bastlifa
Bastlifa / TokenControl
Created September 14, 2017 02:47
Token control script for roll20
/* Token control script
make a macro called TokenControl,
the body should read:
!TokenControl @{target|token_id} @{selected|token_id}
To use this, select a token that you want to alter the control of
then click the macro from your bar
then target a token of a player. I think the same token could work.
This will, hopefully, alter who controlls the selected token.
If the targeted token's player had control, it will remove it
if it did not, it will add it. */
@Bastlifa
Bastlifa / rooftops.js
Last active October 8, 2017 17:47
rooftop removal and restore script for roll20. WIP, probably awful in lots of ways. Didn't test much.
// a script to remove rooftops if a player enters a building
on("ready", function() {
"use strict";
var allPlayerTokens = [];
var allRoofTokens = [];
function getPlayerTokens()
{
@Bastlifa
Bastlifa / SpeedReport
Created October 26, 2017 08:06
Roll20 Bar1_Value Change Report to token owners and GM. Reports bar1 as "speed" at user request
//Requested speed updating script. Should be pretty simple.
on("change:graphic:bar1_value", function(obj, prev) {
if (obj.get("controlledby") != "" || obj.get("represents"))
{
if (obj.get("represents"))
{
if(getObj('character', obj.get('represents')).get("controlledby"))
{
SpeedUpdateReport(obj, false);
@Bastlifa
Bastlifa / MakeCDTable.js
Created October 30, 2017 20:40
Silly script to make a table for STA in roll20
//Just type !MakeChallengeDiceTable into chat and hit enter. Then go ahead and delete this script.
on("ready", function() {
"use strict";
on("chat:message", function (msg) {
if (msg.type === "api" && msg.content === "!MakeChallengeDiceTable")
{
var CDtable = findObjs({type: 'rollabletable', name: "Challenge-Dice"})[0];
if (!CDtable)
{
@Bastlifa
Bastlifa / 10To5.js
Created November 4, 2017 13:45
Change ten foot squares maps in roll20 to 5 foot squares maps (path functions provided by Aaron)
on("ready", function() {
var graphics;
var paths;
const scalePathString = function(pathstring,scale){
return JSON.stringify(_.map(JSON.parse(pathstring),(n)=> _.map(n,(i)=> _.isNumber(i) ? scale*i : i )));
};
const simpleObject = function(o){
@Bastlifa
Bastlifa / FireTrapScript
Last active November 7, 2017 01:43
Fire Trap Script for Roll20. Time update help from Aaron
//A little trap
on("ready", function() {
"use strict";
var i = 0;
const millisecondsPerSecond = 1000; // handy conversion
let timeForFullSpin = 15 * millisecondsPerSecond; // rotate fully in 15 seconds
@Bastlifa
Bastlifa / ShowHealth.js
Created November 24, 2017 23:23
Roll20 API script to show the health of any tokens on the object layer on the current map the GM is looking at.
on("ready", function() {
on("chat:message", function (msg) {
if (msg.type === "api" && msg.content === "!ShowHealth")
{
var page = getObj('page', getObj('player',msg.playerid).get('lastpage')).id;
var tokens = findObjs({type: 'graphic', _pageid: page});
for (var i=0; i<tokens.length; i++)
{
if (tokens[i].get("bar1_value"))
@Bastlifa
Bastlifa / Faces.js
Created November 24, 2017 23:31
Face Changing API Script for Roll20
/*
* A Simple face changing script.
* Make a rollable table with the character name (one word characer name) plus -Faces
* Example, character named John Smith
* Table name is John-Faces
* Fill table with face names, and pictures which you have uploaded. Can't be from purchase or search
* Must be uploaded to your library.
* Make macro with this body, as token action macro:
* !FaceChange John-?{Face|Normal|Soldier|Popper|Pirate|Noble|Elder|Cleric}
* Where those options (other than the title "Face") are the names of the items in your rollable table.
@Bastlifa
Bastlifa / FamiliarSightSwap.js
Created September 28, 2018 23:17
Familiar Sight Swap for Roll20 D&D 5E
//Familiar Sight Swap
// make a macro with body:
// !SwapSight PlayerTokenName FamiliarTokenName
on("ready", function() {
on("chat:message", function (msg) {
if (msg.type === "api" && msg.content.split(' ')[0] === "!SwapSight") {
SwapSight(msg);