Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Script Updates May 29 #1937

Merged
merged 1 commit into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
674 changes: 674 additions & 0 deletions Plugger/1.0.9/Plugger.js

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions Plugger/Plugger.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/*
=========================================================
Name : Plugger
GitHub : https://github.com/TimRohr22/Cauldron/tree/master/Plugger
Roll20 Contact : timmaugh
Version : 1.0.8
Last Update : 05 APRIL 2024
Name : Plugger
GitHub : https://github.com/TimRohr22/Cauldron/tree/master/Plugger
Roll20 Contact : timmaugh
Version : 1.0.9
Last Update : 17 MAY 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.8';
const version = '1.0.9';
const schemaVersion = 0.1;
API_Meta[apiproject].version = version;
const vd = new Date(1712322138494);
const vd = new Date(1715952845199);
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 @@ -354,8 +354,8 @@ const PluggerPlugins01 = (() => {
// VERSION
// ==================================================
const apiproject = 'PluggerPlugins01';
const version = '0.0.3';
const vd = new Date(1620099268834);
const version = '0.0.4';
const vd = new Date(1715952845199);
const versionInfo = () => {
log(`\u0166\u0166 ${apiproject} v${version}, ${vd.getFullYear()}/${vd.getMonth() + 1}/${vd.getDate()} \u0166\u0166 -- offset continues from Plugger`);
return;
Expand All @@ -382,7 +382,7 @@ const PluggerPlugins01 = (() => {
ticks && Array.isArray(ticks) && ticks.length &&
s && typeof s === 'string' && s.length
) {
markrx = new RegExp(`\\s+${escapeRegExp(mark).replace(/\s/g, '\\s')}(.+?)(?:${split.map(s => escapeRegExp(s)).join('|')})`, 'g');
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')}`);
splitrx = new RegExp(`^($|${split.map(s => escapeRegExp(s)).join('|')})`);
return true;
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.8",
"version": "1.0.9",
"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 @@ -16,6 +16,7 @@
"1.0.4",
"1.0.5",
"1.0.6",
"1.0.7"
"1.0.7",
"1.0.8"
]
}
143 changes: 143 additions & 0 deletions ScriptInfo/0.0.4/ScriptInfo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
/*
=========================================================
Name : ScriptInfo
GitHub :
Roll20 Contact : timmaugh
Version : 0.0.3
Last Update : 05 APRIL 2024
=========================================================
*/
var API_Meta = API_Meta || {};
API_Meta.ScriptInfo = { offset: Number.MAX_SAFE_INTEGER, lineCount: -1 };
{ try { throw new Error(''); } catch (e) { API_Meta.ScriptInfo.offset = (parseInt(e.stack.split(/\n/)[1].replace(/^.*:(\d+):.*$/, '$1'), 10) - (13)); } }

const ScriptInfo = (() => { // eslint-disable-line no-unused-vars
const ScriptInfo = 'ScriptInfo';
const scriptVersion = '0.0.3';
API_Meta[ScriptInfo].version = scriptVersion;
const vd = new Date(1716993288422);
const logsig = () => {
state.houseofmod = state.houseofmod || {};
state.houseofmod.siglogged = state.houseofmod.siglogged || false;
state.houseofmod.sigtime = state.houseofmod.sigtime || Date.now() - 3001;
if (
!state.houseofmod.siglogged ||
Date.now() - state.houseofmod.sigtime > 3000
) {
const logsig =
"\n" +
" ________________________ \n" +
" ╱ ______ ╲ \n" +
" ╱ _____ ╲ \n" +
" ╱ ____ ╲ \n" +
" ╱______________________________╲ \n" +
" | _____ _____ | \n" +
" | |_|_| MOD |_|_| | \n" +
" | |_|_| _____ |_|_| | \n" +
" | | | | \n" +
" | | o| | \n" +
"_____________|_________|___|________|______________\n" +
" \n";
log(`${logsig}`);
state.houseofmod.siglogged = true;
state.houseofmod.sigtime = Date.now();
}
return;
};
const versionInfo = () => {
let hom = String.fromCodePoint(0xd83c, 0xdfe0);
log(`${hom} ${ScriptInfo} v${scriptVersion}, ${vd.getFullYear()}/${vd.getMonth() + 1}/${vd.getDate()} ${hom} -- offset ${API_Meta[ScriptInfo].offset}`);
};
let reportMsg;
const fillReportMsg = () => {
reportMsg = Object.keys(API_Meta).reduce((m, k) => {
if (API_Meta[k].hasOwnProperty('offset')) {
m = `${m}{{ ${k}${API_Meta[k].hasOwnProperty('version') ? ` (${API_Meta[k].version})` : ''}=${API_Meta[k].offset} / (${API_Meta[k].hasOwnProperty('lineCount') ? API_Meta[k].lineCount : '????'})}}`;
}
return m;
}, `&{template:default}{{name=Script Information}}{{ SCRIPT NAME=**START / LINES**}}`);
};
const fillReportMsgState = () => {
let size = JSON.stringify(state).length;
let output = Object.keys(state).reduce((m, k) => {
let ksize = JSON.stringify(state[k]).length;
m = `${m}{{ ${k}=${(ksize / 1024).toFixed(3)}kb / ${((ksize / size) * 100).toFixed(1)}%}}`;
return m;
}, `&{template:default}{{name=State Information}}{{ KEY NAME=**SIZE / PCT**}}`);
return `${output}{{**TOTAL**=${(size / 1024).toFixed(3)}kb / 100.0%}}`;
};
const findInMeta = (() => {
let lookup;

let doLookup = (n) => {
lookup = Object.keys(API_Meta)
.reduce((m, k) => [...m, { start: (API_Meta[k].offset), end: (API_Meta[k].offset) + (API_Meta[k].lineCount) - 1, name: k }], [])
.sort((a, b) => a.start > b.start ? 1 : -1);
doLookup = doLookupReal;
return doLookupReal(n);
};
const doLookupReal = (n) => {
let location = {};
lookup.find(e => {
if (n >= e.start && n <= e.end) {
location.within = e.name;
location.line = n - e.start;
return true;
} else {
if (n < e.start && !location.before) {
location.before = e.name;
location.linesbefore = e.start - (n + 1);
return false;
} else if (n > e.end) {
location.after = e.name;
location.linesafter = n - e.end;
return false;
}
return false;
}
});
if (location.within) return `Line ${n} corresponds to line ${location.line} in ${location.within}.`;
if (location.before && location.after) return `That line number does not correspond to any script reporting its offset. ` +
`It occurs ${location.linesafter} lines after the end of ${location.after}, and ` +
`${location.linesbefore} lines before the start of ${location.before}.`;
if (location.after) return `That line number does not correspond to any script reporting its offset. ` +
`It occurs ${location.linesafter} lines after the end of ${location.after}.`;
if (location.before) return `That line number does not correspond to any script reporting its offset. ` +
`It occurs ${location.linesbefore} lines before the start of ${location.before}.`;
return `No information is available for that line number. Check that you have scripts reporting to API_Meta by running !scriptinfo.`;
};
return (n) => doLookup(n);
})();
const handleInput = msg => {
if (msg.type !== 'api' || !/^!(scriptinfo|stateinfo)\b/.test(msg.content)) return;
if (/!scriptinfo/.test(msg.content)) {
let args = msg.content.split(/\s+/).slice(1);
if (!args.length) { // get API_Meta object info
sendChat('MODERATOR', reportMsg);
} else {
args.forEach(a => {
sendChat('MODERATOR', `&{template:default}{{name=Script Information (Line ${a})}}{{=${findInMeta(Number(a))}}}`, null, { noarchive: true });
});
}
}
else {
sendChat('MODERATOR', fillReportMsgState());
}
};

const registerEventHandlers = () => {
on('chat:message', handleInput);
};

on('ready', () => {
logsig();
versionInfo();
fillReportMsg();
registerEventHandlers();
findInMeta(100);
});
return {};
})();

{ try { throw new Error(''); } catch (e) { API_Meta.ScriptInfo.lineCount = (parseInt(e.stack.split(/\n/)[1].replace(/^.*:(\d+):.*$/, '$1'), 10) - API_Meta.ScriptInfo.offset); } }
/* */
38 changes: 19 additions & 19 deletions ScriptInfo/ScriptInfo.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/*
=========================================================
Name : ScriptInfo
GitHub :
Roll20 Contact : timmaugh
Version : 0.0.3
Last Update : 3/31/2023
Name : ScriptInfo
GitHub :
Roll20 Contact : timmaugh
Version : 0.0.3
Last Update : 05 APRIL 2024
=========================================================
*/
var API_Meta = API_Meta || {};
Expand All @@ -13,9 +13,9 @@ API_Meta.ScriptInfo = { offset: Number.MAX_SAFE_INTEGER, lineCount: -1 };

const ScriptInfo = (() => { // eslint-disable-line no-unused-vars
const ScriptInfo = 'ScriptInfo';
const scriptVersion = '0.0.2';
const scriptVersion = '0.0.3';
API_Meta[ScriptInfo].version = scriptVersion;
const vd = new Date(1680266411490);
const vd = new Date(1716993288422);
const logsig = () => {
state.houseofmod = state.houseofmod || {};
state.houseofmod.siglogged = state.houseofmod.siglogged || false;
Expand All @@ -26,18 +26,18 @@ const ScriptInfo = (() => { // eslint-disable-line no-unused-vars
) {
const logsig =
"\n" +
" ________________________ \n" +
" ╱ ______ ╲ \n" +
" ╱ _____ ╲ \n" +
" ╱ ____ ╲ \n" +
" ╱______________________________╲ \n" +
" _____ _____ \n" +
" ┃ ┃_┃_┃ MOD ┃_┃_┃ ┃ \n" +
" ┃ ┃_┃_┃ _____ ┃_┃_┃ ┃ \n" +
" \n" +
" o \n" +
"_________________________________┃_______________\n" +
" \n";
" ________________________ \n" +
" ╱ ______ ╲ \n" +
" ╱ _____ ╲ \n" +
" ╱ ____ ╲ \n" +
" ╱______________________________╲ \n" +
" | _____ _____ | \n" +
" | |_|_| MOD |_|_| | \n" +
" | |_|_| _____ |_|_| | \n" +
" | | | | \n" +
" | | o| | \n" +
"_____________|_________|___|________|______________\n" +
" \n";
log(`${logsig}`);
state.houseofmod.siglogged = true;
state.houseofmod.sigtime = Date.now();
Expand Down
5 changes: 3 additions & 2 deletions ScriptInfo/script.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "ScriptInfo",
"script": "ScriptInfo.js",
"version": "0.0.3",
"version": "0.0.4",
"description": "# ScriptInfo \r\rScriptInfo helps you troubleshoot script errors or to get help with odd script behavior. ScriptInfo will give you a report of installed scripts and their versions, as well as what line each script starts on. \r\rThe version of a script is important if you need to ask for help regarding an unexpected or odd behavior, and lets the community or the script author verify you are on the correct version (or at least a version that should deliver the sort of behavior you expect). \r\rLine numbers are important because when your game's sandbox spins up, all of the scripts are collected into a single, long file of javascript code. If your sandbox errors out due to a problem with the execution of a script, it will report a line number. However, that line number will be between 1 and the total number of script lines in your game, so how do you know where that error originated? With ScriptInfo, you can run a different report to learn that an error on line X represents line Y of script Z. For a simple example, imagine you have 10 scripts installed (ScriptA, ScriptB, ScriptC, etc.), each consisting of 100 lines of code. You get an error that lists line #304 as where the error occurred. ScriptInfo would tell you that line #304 represents line 4 of ScriptD\r\r## Limitations \r\rScriptInfo interrogates a particular object in javascript that script authors must opt-in to use. If a script does not report to this object, ScriptInfo will not be able to get the information it needs, though it will still be able to tell you basic information (such as that an error occurred so-many-lines after a given script and/or so-many-lines before a given script). Many of the more widely used scripts available in the one-click do make use of this centralized reporting object, including TokenMod (as well as the rest of The Arcane Scriptomancer's scripts: RecursiveTables, GroupInit, etc.), ScriptCards, Reporter, Supernotes, Spawn, SmartAoE, and all of the metascripts.\r\r## Usage \r\rTo get the report of all scripts, use the command: \r\r!scriptinfo \r\rTo get a report of one or more lines, use the same handle, followed by the line numbers you wish to know about, each separated by a space: \r\r!scriptinfo 2549\r\r!scriptinfo 180 2021 15024\r\rTo get a report of the size of your state (broken out by each key), use: \r\r!stateinfo \r\rFor more information, see the original thread in the Mod Script forum:\r\r[ScriptInfo Forum Thread](https://app.roll20.net/forum/post/11309751/script-scriptinfo-reports-scripts-versions-and-locations-of-errors-to-help-you-troubleshoot-or-to-help-you-get-help/)",
"authors": "timmaugh",
"roll20userid": "5962076",
Expand All @@ -11,6 +11,7 @@
"conflicts": [],
"previousversions": [
"0.0.1",
"0.0.2"
"0.0.2",
"0.0.3"
]
}
Loading
Loading