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 Sept 6 #1972

Merged
merged 1 commit into from
Sep 10, 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
778 changes: 778 additions & 0 deletions APILogic/2.0.9/APILogic.js

Large diffs are not rendered by default.

28 changes: 17 additions & 11 deletions APILogic/APILogic.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
Name : APILogic
GitHub : https://github.com/TimRohr22/Cauldron/tree/master/APILogic
Roll20 Contact : timmaugh
Version : 2.0.8
Last Update : 26 Jan 2023
Version : 2.0.9
Last Update : 5 SEP 2024
=========================================================
*/
var API_Meta = API_Meta || {};
Expand All @@ -18,9 +18,9 @@ const APILogic = (() => {
// VERSION
// ==================================================
const apiproject = 'APILogic';
API_Meta[apiproject].version = '2.0.8';
API_Meta[apiproject].version = '2.0.9';
const schemaVersion = 0.1;
const vd = new Date(1674771283027);
const vd = new Date(1725559091022);
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 @@ -76,14 +76,14 @@ const APILogic = (() => {
elserx = /(\()?{&\s*else\s*(?=})/i,
endrx = /(\()?{&\s*end\s*}((?<=\({&\s*end\s*})\)|\1)/i;
// FORMERLY in IFTREEPARSER =============================
const groupopenrx = /^\s*(?<negation>!?)\s*\(\s*/,
const groupopenrx = /^\s*(?<negation>!?)\s*\((?!{&\d+}\))\s*/,
namerx = /^\[(?<groupname>[^\s]+?)]\s*/i,
comprx = /^(?<operator>(?:>=|<=|~|!~|=|!=|<|>))\s*/,
operatorrx = /^(?<operator>(?:&&|\|\|))\s*/,
groupendrx = /^\)\s*/,
ifendrx = /^\s*}/,
ifendparenrx = /^\s*}\)/,
textrx = /^(?<negation>!?)\s*(`|'|"?)(?<argtext>.+?)\2\s*(?=!=|!~|>=|<=|[=~><]|&&|\|\||\)|})/;
textrx = /^(?<negation>!?)\s*(`|'|"?)(?<argtext>\({&\d+}\)|.+?)\2\s*(?=!=|!~|>=|<=|[=~><]|&&|\|\||\)|})/;
// TOKEN MARKERS ========================================
const iftm = { rx: ifrx, type: 'if' },
elseiftm = { rx: elseifrx, type: 'elseif' },
Expand Down Expand Up @@ -583,7 +583,9 @@ const APILogic = (() => {
item.metavalue = true;
switch (item.type) {
case 'text':
item.groups.argtext = item.groups.argtext.replace(/\$\[\[(\d+)]]/g, ((r, g1) => o.parsedinline[g1].value || 0));
item.groups.argtext = item.groups.argtext
.replace(/\$\[\[(\d+)]]/g, ((r, g1) => o.parsedinline[g1].value || 0))
.replace(/\({&(\d+)}\)/, ((r, g1) => o.parsedinline[g1].value || 0));
if (grouplib.hasOwnProperty(item.groups.argtext)) {
if (grouplib[item.groups.argtext]) item.value = true;
else {
Expand Down Expand Up @@ -619,6 +621,8 @@ const APILogic = (() => {
let logcolor = 'lightseagreen';
let groupname = '';
let negate = false;
let res;
c.memo = c.hasOwnProperty("memo") ? c.memo : { value: false, next: '||' };
nestlog(`CONDITIONS TEST BEGINS`, c.indent, logcolor, msgstate.logging);
let o = c.tokens.reduce((m, v, i) => {
if ((!m.value && m.next === '&&') || (m.value && m.next === '||')) {
Expand All @@ -628,22 +632,24 @@ const APILogic = (() => {
nestlog(`==AND-GROUP DETECTED: ${v.name || 'no name'}`, c.indent, logcolor, msgstate.logging);
groupname = v.name;
negate = v.negate;
v = areConditionsTruthy({ tokens: v.contents, indent: c.indent + 1 });
res = areConditionsTruthy({ tokens: v.contents, indent: c.indent + 1, memo: { ...m } });
v.value = res.value;
if (groupname) {
grouplib[groupname] = v.value;
}
if (negate) v.value = !v.value;
} else {
nestlog(`==AND-CONDITION DETECTED: lhs>${v.contents[0]} type>${v.type} rhs>${v.contents[1] || ''}`, c.indent, logcolor, msgstate.logging);
v = resolveCondition(v);
ret = resolveCondition(v);
v.value = ret.value;
}
nestlog(`==VALUE: ${v.value}`, c.indent, logcolor, msgstate.logging);
m.value = m.next === '&&' ? m.value && v.value : m.value || v.value;
}
nestlog(`==LOOP END MEMO VALUE: ${m.value}, ${m.next}`, c.indent, logcolor, msgstate.logging);
m.next = v.next;
nestlog(`==LOOP END MEMO VALUE: ${m.value}, ${m.next}`, c.indent, logcolor, msgstate.logging);
return m;
}, { value: false, next: '||' });
}, c.memo);

nestlog(`CONDITIONS TEST ENDS: Conditions are ${o.value}, ${o.next}`, c.indent, logcolor, msgstate.logging);
return o;
Expand Down
5 changes: 3 additions & 2 deletions APILogic/script.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "APILogic",
"script": "APILogic.js",
"version": "2.0.8",
"version": "2.0.9",
"description": "APILogic is a meta-script and part of the Meta-Toolbox. APILogic provides chat input logical constructs for shaping the command line, including IF, ELSEIF, and ELSE. It provides a way to define terms for text-replacment operations, or to name condition sets to re-use later in the logical processing. \r\rFor more information, see the original API forum thread:\r\r[APILogic Forum Thread](https://app.roll20.net/forum/post/9771314/script-apilogic-gives-if-slash-elseif-slash-else-processing-to-other-scripts/)\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 @@ -29,6 +29,7 @@
"2.0.4",
"2.0.5",
"2.0.6",
"2.0.7"
"2.0.7",
"2.0.8"
]
}
234 changes: 234 additions & 0 deletions MetaScriptToolbox/0.0.2/MetaScriptToolbox.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,234 @@
/*
=========================================================
Name : MetaScriptToolbox
GitHub :
Roll20 Contact : timmaugh
Version : 0.0.2
Last Update : 6 SEP 2024
=========================================================
*/
var API_Meta = API_Meta || {};
API_Meta.MetaScriptToolbox = { offset: Number.MAX_SAFE_INTEGER, lineCount: -1 };
{ try { throw new Error(''); } catch (e) { API_Meta.MetaScriptToolbox.offset = (parseInt(e.stack.split(/\n/)[1].replace(/^.*:(\d+):.*$/, '$1'), 10) - (12)); } }

const MetaScriptToolbox = (() => { // eslint-disable-line no-unused-vars
const apiproject = 'MetaScriptToolbox';
const version = '0.0.2';
const schemaVersion = 0.1;
API_Meta[apiproject].version = version;
const vd = new Date(1725630209434);
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}`);
};
const logsig = () => {
// initialize shared namespace for all signed projects, if needed
state.torii = state.torii || {};
// initialize siglogged check, if needed
state.torii.siglogged = state.torii.siglogged || false;
state.torii.sigtime = state.torii.sigtime || Date.now() - 3001;
if (!state.torii.siglogged || Date.now() - state.torii.sigtime > 3000) {
const logsig = '\n' +
' _____________________________________________ ' + '\n' +
' )_________________________________________( ' + '\n' +
' )_____________________________________( ' + '\n' +
' ___| |_______________| |___ ' + '\n' +
' |___ _______________ ___| ' + '\n' +
' | | | | ' + '\n' +
' | | | | ' + '\n' +
' | | | | ' + '\n' +
' | | | | ' + '\n' +
' | | | | ' + '\n' +
'______________|_|_______________|_|_______________' + '\n' +
' ' + '\n';
log(`${logsig}`);
state.torii.siglogged = true;
state.torii.sigtime = Date.now();
}
return;
};
const checkInstall = () => {
if (!state.hasOwnProperty(apiproject) || state[apiproject].version !== schemaVersion) {
log(` > Updating ${apiproject} Schema to v${schemaVersion} <`);
switch (state[apiproject] && state[apiproject].version) {

case 0.1:
/* falls through */

case 'UpdateSchemaVersion':
state[apiproject].version = schemaVersion;
break;

default:
state[apiproject] = {
settings: {},
defaults: {},
version: schemaVersion
}
break;
}
}
};
let stateReady = false;
const assureState = () => {
if (!stateReady) {
checkInstall();
stateReady = true;
}
};

const checkDependencies = (deps) => {
/* pass array of objects like
{ name: 'ModName', version: '#.#.#' || '', mod: ModName || undefined, checks: [ [ExposedItem, type], [ExposedItem, type] ] }
*/
const dependencyEngine = (deps) => {
const versionCheck = (mv, rv) => {
let modv = [...mv.split('.'), ...Array(4).fill(0)].slice(0, 4);
let reqv = [...rv.split('.'), ...Array(4).fill(0)].slice(0, 4);
return reqv.reduce((m, v, i) => {
if (m.pass || m.fail) return m;
if (i < 3) {
if (parseInt(modv[i]) > parseInt(reqv[i])) m.pass = true;
else if (parseInt(modv[i]) < parseInt(reqv[i])) m.fail = true;
} else {
// all betas are considered below the release they are attached to
if (reqv[i] === 0 && modv[i] === 0) m.pass = true;
else if (modv[i] === 0) m.pass = true;
else if (reqv[i] === 0) m.fail = true;
else if (parseInt(modv[i].slice(1)) >= parseInt(reqv[i].slice(1))) m.pass = true;
}
return m;
}, { pass: false, fail: false }).pass;
};

let result = { passed: true, failures: {}, optfailures: {} };
deps.forEach(d => {
let failObj = d.optional ? result.optfailures : result.failures;
if (!d.mod) {
if (!d.optional) result.passed = false;
failObj[d.name] = 'Not found';
return;
}
if (d.version && d.version.length) {
if (!(API_Meta[d.name].version && API_Meta[d.name].version.length && versionCheck(API_Meta[d.name].version, d.version))) {
if (!d.optional) result.passed = false;
failObj[d.name] = `Incorrect version. Required v${d.version}. ${API_Meta[d.name].version && API_Meta[d.name].version.length ? `Found v${API_Meta[d.name].version}` : 'Unable to tell version of current.'}`;
return;
}
}
d.checks.reduce((m, c) => {
if (!m.passed) return m;
let [pname, ptype] = c;
if (!d.mod.hasOwnProperty(pname) || typeof d.mod[pname] !== ptype) {
if (!d.optional) m.passed = false;
failObj[d.name] = `Incorrect version.`;
}
return m;
}, result);
});
return result;
};
let depCheck = dependencyEngine(deps);
let failures = '', contents = '', msg = '';
if (Object.keys(depCheck.optfailures).length) { // optional components were missing
failures = Object.keys(depCheck.optfailures).map(k => `&bull; <code>${k}</code> : ${depCheck.optfailures[k]}`).join('<br>');
contents = `<span style="font-weight: bold">${apiproject}</span> utilizies one or more other scripts for optional features, and works best with those scripts installed. You can typically find these optional scripts in the 1-click Mod Library:<br>${failures}`;
msg = `<div style="width: 100%;border: none;border-radius: 0px;min-height: 60px;display: block;text-align: left;white-space: pre-wrap;overflow: hidden"><div style="font-size: 14px;font-family: &quot;Segoe UI&quot;, Roboto, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, sans-serif"><div style="background-color: #000000;border-radius: 6px 6px 0px 0px;position: relative;border-width: 2px 2px 0px 2px;border-style: solid;border-color: black;"><div style="border-radius: 18px;width: 35px;height: 35px;position: absolute;left: 3px;top: 2px;"><img style="background-color: transparent ; float: left ; border: none ; max-height: 40px" src="${typeof apilogo !== 'undefined' ? apilogo : 'https://i.imgur.com/kxkuQFy.png'}"></div><div style="background-color: #c94d4d;font-weight: bold;font-size: 18px;line-height: 36px;border-radius: 6px 6px 0px 0px;padding: 4px 4px 0px 43px;color: #ffffff;min-height: 38px;">MISSING MOD DETECTED</div></div><div style="background-color: white;padding: 4px 8px;border: 2px solid #000000;border-bottom-style: none;color: #404040;">${contents}</div><div style="background-color: white;text-align: right;padding: 4px 8px;border: 2px solid #000000;border-top-style: none;border-radius: 0px 0px 6px 6px"></div></div></div>`;
sendChat(apiproject, `/w gm ${msg}`);
}
if (!depCheck.passed) {
failures = Object.keys(depCheck.failures).map(k => `&bull; <code>${k}</code> : ${depCheck.failures[k]}`).join('<br>');
contents = `<span style="font-weight: bold">${apiproject}</span> requires other scripts to work. Please use the 1-click Mod Library to correct the listed problems:<br>${failures}`;
msg = `<div style="width: 100%;border: none;border-radius: 0px;min-height: 60px;display: block;text-align: left;white-space: pre-wrap;overflow: hidden"><div style="font-size: 14px;font-family: &quot;Segoe UI&quot;, Roboto, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, sans-serif"><div style="background-color: #000000;border-radius: 6px 6px 0px 0px;position: relative;border-width: 2px 2px 0px 2px;border-style: solid;border-color: black;"><div style="border-radius: 18px;width: 35px;height: 35px;position: absolute;left: 3px;top: 2px;"><img style="background-color: transparent ; float: left ; border: none ; max-height: 40px" src="${typeof apilogo !== 'undefined' ? apilogo : 'https://i.imgur.com/kxkuQFy.png'}"></div><div style="background-color: #c94d4d;font-weight: bold;font-size: 18px;line-height: 36px;border-radius: 6px 6px 0px 0px;padding: 4px 4px 0px 43px;color: #ffffff;min-height: 38px;">MISSING MOD DETECTED</div></div><div style="background-color: white;padding: 4px 8px;border: 2px solid #000000;border-bottom-style: none;color: #404040;">${contents}</div><div style="background-color: white;text-align: right;padding: 4px 8px;border: 2px solid #000000;border-top-style: none;border-radius: 0px 0px 6px 6px"></div></div></div>`;
sendChat(apiproject, `/w gm ${msg}`);
return false;
}
return true;
};

on('ready', () => {
versionInfo();
assureState();
logsig();
let reqs = [
{
name: 'ZeroFrame',
version: `1.2.2`,
mod: typeof ZeroFrame !== 'undefined' ? ZeroFrame : undefined,
checks: [['RegisterMetaOp', 'function']],
},
{
name: 'APILogic',
version: `2.0.9`,
mod: typeof APILogic !== 'undefined' ? APILogic : undefined,
checks: [],
},
{
name: 'Fetch',
version: `2.1.1`,
mod: typeof Fetch !== 'undefined' ? Fetch : undefined,
checks: [],
},
{
name: 'SelectManager',
version: `1.1.8`,
mod: typeof SelectManager !== 'undefined' ? SelectManager : undefined,
checks: [['GetPlayerID', 'function'], ['GetSelected', 'function'], ['GetWho', 'function']],
},
{
name: 'Muler',
version: `2.0.2`,
mod: typeof Muler !== 'undefined' ? Muler : undefined,
checks: [],
},
{
name: 'Plugger',
version: `1.0.9`,
mod: typeof Plugger !== 'undefined' ? Plugger : undefined,
checks: [],
},
{
name: 'MathOps',
version: `1.0.8`,
mod: typeof MathOps !== 'undefined' ? MathOps : undefined,
checks: [['MathProcessor', 'function']],
},
{
name: 'libTokenMarkers',
version: `0.1.2`,
mod: typeof libTokenMarkers !== 'undefined' ? libTokenMarkers : undefined,
checks: [['getStatus', 'function'], ['getStatuses', 'function'], ['getOrderedList', 'function']]
},
{
name: 'libTable',
version: `1.0.0`,
mod: typeof libTable !== 'undefined' ? libTable : undefined,
checks: [
['getTable', 'function'],
['getTables', 'function'],
['getItems', 'function'],
['getItemsByIndex', 'function'],
['getItemsByName', 'function'],
['getItemsByWeight', 'function'],
['getItemsByWeightedIndex', 'function']
]
},
{
name: 'checkLightLevel',
// version: `1.0.0.b3`,
mod: typeof checkLightLevel !== 'undefined' ? checkLightLevel : undefined,
checks: [['isLitBy', 'function']],
optional: true
},
{
name: 'Messenger',
version: `1.0.1`,
mod: typeof Messenger !== 'undefined' ? Messenger : undefined,
checks: [['Button', 'function'], ['MsgBox', 'function'], ['HE', 'function'], ['Html', 'function'], ['Css', 'function']]
}
];
if (!checkDependencies(reqs)) return;
});
return {};
})();

{ try { throw new Error(''); } catch (e) { API_Meta.MetaScriptToolbox.lineCount = (parseInt(e.stack.split(/\n/)[1].replace(/^.*:(\d+):.*$/, '$1'), 10) - API_Meta.MetaScriptToolbox.offset); } }
Loading
Loading