Skip to content

Commit

Permalink
Merge branch 'Roll20:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
Villain1nGlasses authored Sep 14, 2024
2 parents 2bcf011 + 9b5d638 commit 218db54
Show file tree
Hide file tree
Showing 44 changed files with 42,686 additions and 2,825 deletions.
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"
]
}
Loading

0 comments on commit 218db54

Please sign in to comment.