Skip to content

Commit

Permalink
Merge branch 'Pathv2-Jumpgate-Itsatrap' of github.com:shdwjk/roll20-a…
Browse files Browse the repository at this point in the history
…pi-scripts into Pathv2-Jumpgate-Itsatrap
  • Loading branch information
shdwjk committed Dec 6, 2024
2 parents 996df69 + da1270d commit 7b93d35
Show file tree
Hide file tree
Showing 9 changed files with 13,819 additions and 31 deletions.
13,048 changes: 13,048 additions & 0 deletions Earthdawn (FASA Official) character sheet companion/03.330/Earthdawn.js

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "Earthdawn by FASA character sheet companion",
"script": "Earthdawn.js",
"version": "03.301",
"previousversions": ["03.30","03.19","03.15","03.023","03.022","03.021","03.020","03.001","03.000","02.042","02.041","02.040","02.000","01.002","01.001","01.000"],
"version": "03.330",
"previousversions": ["03.301","03.30","03.19","03.15","03.023","03.022","03.021","03.020","03.001","03.000","02.042","02.041","02.040","02.000","01.002","01.001","01.000"],
"description": "The Roll20 \"Earthdawn by FASA character sheet companion\" API script is made to work with the \"Earthdawn by FASA\" character sheet and \"Earthdawn 4th Edition\" Compendium. It provides many features that automate and assist in many tasks. It is optimized for Earthdawn 4th edition and 1879 1st Edition, but currently has limited support for other editions.\r\r For more information please see [Earthdawn Sheet wiki page](https://wiki.roll20.net/Earthdawn_-_FASA_Official_V2).",
"authors": "Chris Dickey",
"roll20userid": "633707",
Expand Down
7 changes: 4 additions & 3 deletions Its A Trap/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ var ItsATrap = (() => {
* @param {Graphic} token
*/
function _checkTrapInteractions(token) {
if(token.iatIgnoreToken)
if(ignoreTokens[token.id])
return;

// Objects on the GM layer don't set off traps.
Expand Down Expand Up @@ -649,10 +649,11 @@ var ItsATrap = (() => {
// This is to prevent a bug related to dropping default tokens for characters
// to the VTT, which sometimes caused traps to trigger as though the dropped
// token has move.
let ignoreTokens = {};
on('add:graphic', token => {
token.iatIgnoreToken = true;
ignoreTokens[token.id] = true;
setTimeout(() => {
delete token.iatIgnoreToken;
delete ignoreTokens[token.id];
}, 1000);
});

Expand Down
677 changes: 677 additions & 0 deletions Plugger/1.0.10/Plugger.js

Large diffs are not rendered by default.

45 changes: 24 additions & 21 deletions Plugger/Plugger.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
Name : Plugger
GitHub : https://github.com/TimRohr22/Cauldron/tree/master/Plugger
Roll20 Contact : timmaugh
Version : 1.0.9
Last Update : 17 MAY 2024
Version : 1.0.10
Last Update : 8 OCT 2024
=========================================================
*/
var API_Meta = API_Meta || {};
Expand All @@ -15,10 +15,10 @@ API_Meta.Plugger = { offset: Number.MAX_SAFE_INTEGER, lineCount: -1 };

const Plugger = (() => {
const apiproject = 'Plugger';
const version = '1.0.9';
const version = '1.0.10';
const schemaVersion = 0.1;
API_Meta[apiproject].version = version;
const vd = new Date(1715952845199);
const vd = new Date(1728392407761);
const versionInfo = () => {
log(`\u0166\u0166 ${apiproject} v${API_Meta[apiproject].version}, ${vd.getFullYear()}/${vd.getMonth() + 1}/${vd.getDate()} \u0166\u0166 -- offset ${API_Meta[apiproject].offset}`);
if (!state.hasOwnProperty(apiproject) || state[apiproject].version !== schemaVersion) {
Expand Down Expand Up @@ -361,13 +361,14 @@ const PluggerPlugins01 = (() => {
return;
};

const tickSplit = (s, ticks = ["'", "`", '"'], split = ['|', '#'], mark = '--') => {
const tickSplit = (cmd, ticks = ["'", "`", '"'], split = ['|', '#'], mark = '--') => {
const escapeRegExp = (string) => { return string.replace(/[.*+\-?^${}()|[\]\\]/g, '\\$&'); };
let index = 0;
let tokens = [];
let markrx,
openrx,
splitrx;
splitrx,
markbase;

class ArgToken {
constructor(type = '') {
Expand All @@ -380,10 +381,12 @@ const PluggerPlugins01 = (() => {
if (
split && Array.isArray(split) && split.length &&
ticks && Array.isArray(ticks) && ticks.length &&
s && typeof s === 'string' && s.length
mark && typeof mark === 'string' && mark.length &&
cmd && typeof cmd === 'string' && cmd.length
) {
markrx = new RegExp(`(?:^|\\s+)${escapeRegExp(mark).replace(/\s/g, '\\s')}(.+?)(?:${split.map(s => escapeRegExp(s)).join('|')})`, 'g');
openrx = new RegExp(`^\\s+${escapeRegExp(mark).replace(/\s/g, '\\s')}`);
markbase = `\\s+${escapeRegExp(mark).replace(/\s/g, '\\s')}`;
markrx = new RegExp(`${markbase}(.+?)(?:${split.map(s => escapeRegExp(s)).join('|')}|(?=${markbase})|$)`, 'g');
openrx = new RegExp(`^${markbase}`);
splitrx = new RegExp(`^($|${split.map(s => escapeRegExp(s)).join('|')})`);
return true;
}
Expand All @@ -394,7 +397,7 @@ const PluggerPlugins01 = (() => {
ticks.some(t => {
let res;
let rx = new RegExp(`^${escapeRegExp(t)}`);
if ((res = rx.exec(s.slice(index))) !== null) {
if ((res = rx.exec(cmd.slice(index))) !== null) {
tick = t;
index += res[0].length;
return true;
Expand All @@ -407,12 +410,12 @@ const PluggerPlugins01 = (() => {
let res;
if (tick) {
let tickrx = new RegExp(`^${escapeRegExp(tick)}`);
if ((res = tickrx.exec(s.slice(index))) !== null) {
if ((res = tickrx.exec(cmd.slice(index))) !== null) {
index += res[0].length;
}
}
if (index < s.length) {
if ((res = splitrx.exec(s.slice(index))) !== null) {
if (index < cmd.length) {
if ((res = splitrx.exec(cmd.slice(index))) !== null) {
index += res[0].length;
}
}
Expand All @@ -422,35 +425,35 @@ const PluggerPlugins01 = (() => {
let tick = getTick();
let rx;
if (tick) {
rx = new RegExp(`^.+?(?=$|${escapeRegExp(tick)})`);
rx = new RegExp(`^.*?(?=$|${escapeRegExp(tick)})`);
} else {
rx = new RegExp(`^.+?(?=$|${split.map(s => escapeRegExp(s)).join('|')}|\\s+${escapeRegExp(mark).replace(/\s/g, '\\s')})`);
rx = new RegExp(`^.+?(?=$|${split.map(s => escapeRegExp(s)).join('|')}|${markbase})`);
}
let res = rx.exec(s.slice(index));
let res = rx.exec(cmd.slice(index));
token.results.push(res[0]);
index += res[0].length;
if (index < s.length) {
if (index < cmd.length) {
transition(tick);
}
};

const getArg = () => {
let res;
markrx.lastIndex = 0;
if ((res = markrx.exec(s.slice(index))) === null) {
index = s.length;
if ((res = markrx.exec(cmd.slice(index))) === null) {
index = cmd.length;
return;
}
let token = new ArgToken(res[1]);
index += markrx.lastIndex;
while (index < s.length && !openrx.test(s.slice(index))) {
while (index < cmd.length && !openrx.test(cmd.slice(index))) {
getPart(token);
}
tokens.push(token);
};

if (validate()) {
while (index < s.length) {
while (index < cmd.length) {
getArg();
}
return tokens;
Expand Down
5 changes: 3 additions & 2 deletions Plugger/script.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "Plugger",
"script": "Plugger.js",
"version": "1.0.9",
"version": "1.0.10",
"description": "Plugger is a meta-script and part of the Meta-Toolbox. Plugger allows for scripts to be run from within the command lines that are inteded for other scripts, and it runs those scripts at meta-script priority (before the intended-recipient script receives the message). With only a few lines of modificadtions, scripts can be registered as plugins, which allows them to return information to the command line. By returning the data to the command line, Plugger ensures that the data is available to the intended-recipient script.\r\rFor more information, see the original thread in the API forum:\r\r[Plugger Forum Thread](https://app.roll20.net/forum/post/10005724/meta-script-plugger-give-scripts-and-plugins-zero-order-priority)\r\rOr read about the full set of meta-scripts available: \r\r[Meta Toolbox Forum Thread](https://app.roll20.net/forum/post/10005695/script-set-the-meta-toolbox)",
"authors": "timmaugh",
"roll20userid": "5962076",
Expand All @@ -17,6 +17,7 @@
"1.0.5",
"1.0.6",
"1.0.7",
"1.0.8"
"1.0.8",
"1.0.9"
]
}
6 changes: 3 additions & 3 deletions Triggered Cleanup/script.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"name": "Triggered Cleanup",
"script": "Triggered Cleanup.js",
"version": "1.0",
"version": "1.1",
"previousversions": [],
"description": "Originally designed for a specific table, this script was made with one-offs and LC/Westmarches in mind. Many APIs find difficulties in running scripts when numerous tokens are left on a table. This script removes all tokens linked to a character sheet when using the command [!cleanup] in the chat. It also deletes tokens when the linked character sheet is deleted. It will ignore any tokens on a map that has the word [bullpen] in the name (not case-sensitive)",
"description": "Originally designed for a specific table, this script was made with one-offs and LCs/Westmarches in mind. Many APIs find difficulties in running scripts when numerous tokens are left on a table. This script removes all tokens linked to a character sheet when using the command [!cleanup] in the chat. It also deletes tokens when the linked character sheet is deleted. It will ignore any tokens on a map that has the word [bullpen] in the name (not case-sensitive)",
"authors": "Jeffrey Simons",
"roll20userid": "4069317",
"useroptions": [],
"dependencies": [],
"conflicts": []
}
}
3 changes: 3 additions & 0 deletions Triggered Cleanup/v1.1/Release Notes.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Improved efficiency by reorganizing when certain calls were made.

Found that two findObjs calls were performed with every chat entry. This should now only trigger when the API command is used.
55 changes: 55 additions & 0 deletions Triggered Cleanup/v1.1/Triggered Cleanup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/* This script wildelete all tokens that are linked to a character when entering [!cleanup] in the chat (not case-sensitive).
The script will also delete tokens for character sheets that are deleted.
The script will not delete any tokens on a map with the phrase "Bullpen" (not case sensitive) in the name.
*/
on('destroy:character',function(obj){
log(obj.get('_id'))
let tokens = findObjs({ type: 'graphic', represents: obj.get('_id') });
const inMap = new Array()
let maps = findObjs({type: 'page'})
for (let i = 0; i < maps.length; i++) {
if (maps[i].get('name').toLowerCase().includes('bullpen')){
inMap.push(maps[i])
}
}
for(let i = 0; i < tokens.length; i++){
let flag = 1
for(let j = 0; j < inMap.length; j++){
if(tokens[i].get('_pageid')===inMap[j].get('_id')){
log("inMap Name: " + inMap[j].get('name'))
flag = 0
}
}
if (flag){
tokens[i].remove();
}
}
})

on("chat:message", function(msg) {
if(msg.content.toLowerCase() === "!cleanup"){
let tokens = findObjs({ type: 'graphic' });
const inMap = new Array()
let maps = findObjs({type: 'page'})
for (let i = 0; i < maps.length; i++) {
if (maps[i].get('name').toLowerCase().includes('bullpen')){
inMap.push(maps[i])
}
}
for(let i = 0; i < tokens.length; i++){
log("Token: " + tokens[i].get('_id') + " & " + tokens[i].get('represents'))
let flag = 1
for(let j = 0; j < inMap.length; j++){
if(tokens[i].get('represents') === ''){
flag = 0
}
if(tokens[i].get('_pageid')===inMap[j].get('_id')){
flag = 0
}
}
if (flag){
tokens[i].remove();
}
}
}
})

0 comments on commit 7b93d35

Please sign in to comment.