Skip to content

Commit

Permalink
MetaScript Updates 10 April 2024
Browse files Browse the repository at this point in the history
SelectManager:
--selection criteria by character tags
--syntax change for selection criteria by status marker

Fetch:
--select unique token across pages by name
--new character properties
--new handout properties
--card properties
--table/item properties
--"is" propety for marker/tag presence

Plugger:
--replace function (text find/replace)

ZeroFrame:
--{&tracker} tag for adding tokens to the Turn Tracker
  • Loading branch information
TimRohr22 committed Apr 10, 2024
1 parent 8920bd0 commit 14a3f7a
Show file tree
Hide file tree
Showing 12 changed files with 5,916 additions and 416 deletions.
1,741 changes: 1,741 additions & 0 deletions Fetch/2.1.0/Fetch.js

Large diffs are not rendered by default.

1,035 changes: 665 additions & 370 deletions Fetch/Fetch.js

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions Fetch/script.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "Fetch",
"script": "Fetch.js",
"version": "2.0.9",
"version": "2.1.0",
"description": "Fetch is a meta-script and part of the Meta-Toolbox. Fetch offers a unified syntax to expand the amount of things that can be retrieved with simple token or sheet calls. You can retrieve any token property, character property, sheet attribute, repeating attribute, ability, or macro with syntax that is intentionally very similar to Roll20 Galactic Standard syntax structures. As of v2.0.0, you can also retrieve page properties, player properties, campaign properties, token marker properties, or statusmarker properties.\r\rToken property : @(selected.currentside)\rSheet Attribute: @(selected.Strength)\rSheet Attribute: @(Bob the Hirsute.Strength.max)\rRepeating Attr : *(Englebert Slaptiback.spells.[spell_name~Fireball prepared].spell_roll)\r\rIt also expands the source of the returned sheet item to include 'speaker'.\r\r@(speaker.Strength.max) ... and can return the rowID of a repeating attribute, the row number ($0), or the name of either brand of reference.\r\rNot only do these offer the advantage of not breaking the chat message if they don't exist (the way a standard token or sheet item call would), they also give you the ability to substitute in a default value should the one you are looking for not exist: \r\r@(The President of Burundi.Coffee[default value here]) \r\rFor more information, see the original API forum thread:\r\rhttps://app.roll20.net/forum/post/10005732/meta-script-fetch-retrieve-attributes-repeating-attributes-abilities-or-token-properties)\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 Down Expand Up @@ -34,7 +34,8 @@
"2.0.5",
"2.0.6",
"2.0.7",
"2.0.8"
"2.0.8",
"2.0.9"
]

}
674 changes: 674 additions & 0 deletions Plugger/1.0.8/Plugger.js

Large diffs are not rendered by default.

135 changes: 129 additions & 6 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.7
Last Update : 6/6/2022
Version : 1.0.8
Last Update : 05 APRIL 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.6';
const version = '1.0.8';
const schemaVersion = 0.1;
API_Meta[apiproject].version = version;
const vd = new Date(1654543510049);
const vd = new Date(1712322138494);
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,13 +354,109 @@ const PluggerPlugins01 = (() => {
// VERSION
// ==================================================
const apiproject = 'PluggerPlugins01';
const version = '0.0.2';
const version = '0.0.3';
const vd = new Date(1620099268834);
const versionInfo = () => {
log(`\u0166\u0166 ${apiproject} v${version}, ${vd.getFullYear()}/${vd.getMonth() + 1}/${vd.getDate()} \u0166\u0166 -- offset continues from Plugger`);
return;
};

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

class ArgToken {
constructor(type = '') {
this.type = type;
this.results = [];
}
}

const validate = () => {
if (
split && Array.isArray(split) && split.length &&
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');
openrx = new RegExp(`^\\s+${escapeRegExp(mark).replace(/\s/g, '\\s')}`);
splitrx = new RegExp(`^($|${split.map(s => escapeRegExp(s)).join('|')})`);
return true;
}
};

const getTick = () => {
let tick = '';
ticks.some(t => {
let res;
let rx = new RegExp(`^${escapeRegExp(t)}`);
if ((res = rx.exec(s.slice(index))) !== null) {
tick = t;
index += res[0].length;
return true;
}
});
return tick;
};

const transition = (tick) => {
let res;
if (tick) {
let tickrx = new RegExp(`^${escapeRegExp(tick)}`);
if ((res = tickrx.exec(s.slice(index))) !== null) {
index += res[0].length;
}
}
if (index < s.length) {
if ((res = splitrx.exec(s.slice(index))) !== null) {
index += res[0].length;
}
}
};

const getPart = (token) => {
let tick = getTick();
let rx;
if (tick) {
rx = new RegExp(`^.+?(?=$|${escapeRegExp(tick)})`);
} else {
rx = new RegExp(`^.+?(?=$|${split.map(s => escapeRegExp(s)).join('|')}|\\s+${escapeRegExp(mark).replace(/\s/g, '\\s')})`);
}
let res = rx.exec(s.slice(index));
token.results.push(res[0]);
index += res[0].length;
if (index < s.length) {
transition(tick);
}
};

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

if (validate()) {
while (index < s.length) {
getArg();
}
return tokens;
}
};

const listen = (m) => {
// expected syntax: !listen ~~object|<identifier> ~~delay|1000 ~~test|(propA|+ && propB|-) command
if (!/^!listen\s/.test(m.content)) return;
Expand Down Expand Up @@ -537,10 +633,37 @@ const PluggerPlugins01 = (() => {
}
};

const replace = (m) => {
// expected syntax: !replace --source|source text --find|search text 1|replace text 1|i --find|'search text|2'|replace text 2'
const escapeRegExp = (string) => { return string.replace(/[.*+\-?^${}()|[\]\\]/g, '\\$&'); };

let args = tickSplit(m.content);
let source;
let findargs = args.reduce((m, v) => {
if (/^source$/i.test(v.type)) {
source = v.results[0] || '';
} else if (/^find$/i.test(v.type)) {
//m.push(v);
if (v.results.length === 2 || (v.results.length > 2 && !/i/i.test(v.results[2]))) {
m.push([new RegExp(escapeRegExp(v.results[0]), 'g'), v.results[1]]);
} else if (v.results.length === 3 && /i/i.test(v.results[2])) {
m.push([new RegExp(escapeRegExp(v.results[0]), 'gi'), v.results[1]]);
}
}
return m;
}, []);


return findargs.reduce((m, v) => {
m = m.replace(...v);
return m;
}, source);
};

on('ready', () => {
versionInfo();
try {
Plugger.RegisterRule(getDiceByVal, getDiceByPos, filter);
Plugger.RegisterRule(getDiceByVal, getDiceByPos, filter, replace);
} catch (error) {
log(`ERROR Registering to PlugEval: ${error.message}`);
}
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.7",
"version": "1.0.8",
"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 @@ -15,6 +15,7 @@
"1.0.3",
"1.0.4",
"1.0.5",
"1.0.6"
"1.0.6",
"1.0.7"
]
}
Loading

0 comments on commit 14a3f7a

Please sign in to comment.