Skip to content

Instantly share code, notes, and snippets.

@Bastlifa
Bastlifa / ScreenShaker.js
Last active May 13, 2020 00:08
Roll20 API script to shake the screen, maybe for earthquake
/* Screen Shake (really just maps, tokens, and paths)
make a macro with the folloing body
/w gm &{template:default} {{name=Screen Shaker}} {{[Start](!ScreenShake)}} {{[Shake With Time](!ScreenShake ?{time})}} {{[Stop](!ScreenShakeStop)}}
*/
on("ready", function() {
var ScreenShakeEnabled = true;
on("chat:message", function (msg) {
if (msg.type === "api" && msg.content.split(' ')[0] === "!ScreenShake" && playerIsGM(msg.playerid))
{
var shakeTime = 0;
@Bastlifa
Bastlifa / Rooftops.js
Last active July 26, 2023 14:34
Rooftops Refactored (and laden with commented sections) for roll20
/*
A script to remove and restore rooftops when a player gets within range of the building.
To use this:
1: After first loading, use !RooftopCommands to make the use macros
2: Use the polygon tool to make your dynamic lighting lines on the building.
3: Move the player flag to the page you want to use this on.
4: Use a roof token, best if it's rotation is an integer multiple of 90 degrees (0, 90, 180, 270)
5: Name the roof token "roof", without the quotes.
6: Drag in player tokens. That is, tokens either assigned to players, or representing characters assigned to player
7: Type !RoofReady into chat, or better yet, use it from the macro.
@Bastlifa
Bastlifa / NoWhisper
Created November 4, 2017 21:26
Removes GM Whispers From Characters in Roll20
on("ready", function() {
on("chat:message", function (msg) {
if (msg.type === "api" && msg.content === "!NoWhisper")
{
var characters = findObjs({type: 'character'});
for (var i=0; i<characters.length; i++)
{
if (getAttrByName(characters[i].id, 'wtype'))
{
@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 / 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 / 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 / rooftops.js
Last active July 23, 2023 08:22
Rooftops plus dynamic lighting
// a script to remove rooftops if a player enters a building
// move the player flag to the page you want to use this on
// draw your dynamic lighting lines on your building
// use a roof token, best if it's rotation is an integer multiple of 90 degrees (0, 90, 180, 270)
// name the roof token "roof", without the quotes. Preferable put it on map layer
// drag in player tokens. That is, tokens either assigned to players, or representing characters assigned to player
// type !RoofReady into chat, or better yet, use it from a macro. Alternatively, dragging the player flag to the page does this.
// should be good to go. Let me know if there are errors please :)
// other feature: !RoofDLOff and !RoofDLOn will now turn off or on the dynamic lighting interaction of the script. Default is 'on'.
// if you want default to be off, change the declaration on line 21 to read: var dlInteraction = false;
@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 / 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 / DLMoonTrack
Created August 29, 2017 16:11
Roll20 Script for Moon Tracking. Needs GM work to function.
/****************Dragonlance Moon Tracker*****************
A script to track the moon phases in a Dragonlance Game.
You'll need the accompanying images for the moon phases.
Put them in a table as specified. Create a character
named "MoonTracker", optionally, change the GM whisper
for Nuitari to whisper your black robed mages. Only they
can see Nuitari.
*********************************************************/