From b67f90f4aa0d12286edf25132e2e6724698a3a25 Mon Sep 17 00:00:00 2001
From: thekingofspace <37231416+thekingofspace@users.noreply.github.com>
Date: Mon, 15 Apr 2024 14:08:36 -0700
Subject: [PATCH 01/23] Updated with 2 things
Added create primitive mod
Added seperator mod
---
actions/canvas_create_primitive_MOD.js | 101 +++++++++++++++++++++++
actions/seperator_MOD.js | 110 +++++++++++++++++++++++++
2 files changed, 211 insertions(+)
create mode 100644 actions/canvas_create_primitive_MOD.js
create mode 100644 actions/seperator_MOD.js
diff --git a/actions/canvas_create_primitive_MOD.js b/actions/canvas_create_primitive_MOD.js
new file mode 100644
index 00000000..5c7bb9c9
--- /dev/null
+++ b/actions/canvas_create_primitive_MOD.js
@@ -0,0 +1,101 @@
+module.exports = {
+ name: 'Canvas Create Shape',
+ section: 'Image Editing',
+ meta: {
+ version: '1.0.0',
+ author: 'Your Name',
+ authorUrl: 'https://yourwebsite.com',
+ downloadURL: 'https://github.com/yourrepository/your-script.js',
+ },
+
+ subtitle(data) {
+ const info = parseInt(data.info, 10);
+ if (info === 0) {
+ return data.color ? `Create Circle with Color ${data.color}` : 'No color circle has been created';
+ }
+ if (info === 1) {
+ return data.color ? `Create Rectangle with Color ${data.color}` : 'No color rectangle has been created';
+ }
+ // Add more cases for different shapes as needed
+ },
+
+ variableStorage(data, varType) {
+ if (parseInt(data.storage, 10) !== varType) return;
+ return [data.varName, 'Image'];
+ },
+
+ fields: ['shapeType', 'width', 'height', 'color', 'storage', 'varName'],
+
+ html() {
+ return `
+
+
+ Shape Type
+
+ Circle
+ Rectangle
+
+
+
+
+
+
+
+
+
+
+
+
+
+`;
+ },
+
+ async action(cache) {
+ const data = cache.actions[cache.index];
+ const Canvas = require('canvas');
+ const shapeType = parseInt(data.shapeType, 10);
+ const width = parseInt(this.evalMessage(data.width, cache), 10);
+ const height = parseInt(this.evalMessage(data.height, cache), 10);
+ const canvas = Canvas.createCanvas(width, height);
+ const ctx = canvas.getContext('2d');
+ let color = this.evalMessage(data.color, cache);
+
+ switch (shapeType) {
+ case 0: // Circle
+ ctx.beginPath();
+ ctx.arc(width / 2, height / 2, Math.min(width, height) / 2, 0, 2 * Math.PI);
+ ctx.fillStyle = color;
+ ctx.fill();
+ break;
+ case 1: // Rectangle
+ ctx.fillStyle = color;
+ ctx.fillRect(0, 0, width, height);
+ break;
+ // Add more cases for different shapes
+ default:
+ break;
+ }
+
+ const result = canvas.toDataURL('image/png').replace('image/png', 'image/octet-stream');
+ const varName = this.evalMessage(data.varName, cache);
+ const storage = parseInt(data.storage, 10);
+ this.storeValue(result, storage, varName, cache);
+ this.callNextAction(cache);
+ },
+
+ mod() {},
+};
diff --git a/actions/seperator_MOD.js b/actions/seperator_MOD.js
new file mode 100644
index 00000000..1bb66ab2
--- /dev/null
+++ b/actions/seperator_MOD.js
@@ -0,0 +1,110 @@
+module.exports = {
+ name: 'Separator',
+ section: 'Other',
+ fields: ['separator', 'color', 'bold', 'underline', 'fontSize'],
+
+ meta: {
+ version: '2.1.7',
+ author: 'DBM Mods',
+ authorUrl: 'https://github.com/dbm-network/mods',
+ downloadURL: 'https://github.com/dbm-network/mods/blob/master/actions/file_control_separator.js',
+ },
+
+ subtitle(data) {
+ let style = '';
+ if (data.bold === 'true') style += 'font-weight: bold;';
+ if (data.underline === 'true') style += 'text-decoration: underline;';
+ if (data.fontSize) style += `font-size: ${parseInt(data.fontSize, 10)}px;`;
+ const separator = data.separator || 'No separator provided';
+ const color = data.color || '#000000';
+ return `${separator} `;
+ },
+
+ html() {
+ return `
+ `;
+ },
+
+ init() {
+ const { document } = this;
+ const separatorField = document.getElementById('separator');
+ const colorField = document.getElementById('color');
+ const boldField = document.getElementById('bold');
+ const underlineField = document.getElementById('underline');
+ const fontSizeField = document.getElementById('fontSize');
+
+ function updateSubtitle() {
+ const separatorValue = separatorField.value.trim();
+ const colorValue = colorField.value;
+ const boldValue = boldField.value === 'true';
+ const underlineValue = underlineField.value === 'true';
+ const fontSizeValue = fontSizeField.value;
+ const subtitle = document.querySelector('.subtitle');
+ let style = '';
+ if (boldValue) style += 'font-weight: bold;';
+ if (underlineValue) style += 'text-decoration: underline;';
+ if (fontSizeValue) style += `font-size: ${parseInt(fontSizeValue, 10)}px;`;
+ subtitle.innerHTML = `${separatorValue || 'No separator provided'} `;
+ }
+
+ separatorField.addEventListener('input', updateSubtitle);
+ colorField.addEventListener('input', updateSubtitle);
+ boldField.addEventListener('change', updateSubtitle);
+ underlineField.addEventListener('change', updateSubtitle);
+ fontSizeField.addEventListener('input', updateSubtitle);
+
+ // Trigger subtitle update on initialization
+ updateSubtitle();
+ },
+
+ async action(cache) {
+ const data = cache.actions[cache.index];
+ const separator = this.evalMessage(data.separator, cache);
+ const color = this.evalMessage(data.color, cache);
+ const bold = data.bold === 'true';
+ const underline = data.underline === 'true';
+
+ // Store separator value if provided
+ if (separator !== undefined) {
+ cache.separator = separator;
+ }
+
+ // Store color value if provided
+ if (color !== undefined) {
+ cache.color = color;
+ }
+
+ // Store bold value if provided
+ if (bold !== undefined) {
+ cache.bold = bold;
+ }
+
+ // Store underline value if provided
+ if (underline !== undefined) {
+ cache.underline = underline;
+ }
+
+ this.callNextAction(cache);
+ },
+
+ mod() {},
+};
From a6a0b260fb94465972e33205f3db618b2a4e5da6 Mon Sep 17 00:00:00 2001
From: thekingofspace <37231416+thekingofspace@users.noreply.github.com>
Date: Thu, 18 Apr 2024 21:17:36 -0700
Subject: [PATCH 02/23] Updated these with lint
---
actions/canvas_create_primitive_MOD.js | 2 +-
actions/seperator_MOD.js | 222 +++++++++++++------------
2 files changed, 113 insertions(+), 111 deletions(-)
diff --git a/actions/canvas_create_primitive_MOD.js b/actions/canvas_create_primitive_MOD.js
index 5c7bb9c9..01db6a59 100644
--- a/actions/canvas_create_primitive_MOD.js
+++ b/actions/canvas_create_primitive_MOD.js
@@ -72,7 +72,7 @@ module.exports = {
const height = parseInt(this.evalMessage(data.height, cache), 10);
const canvas = Canvas.createCanvas(width, height);
const ctx = canvas.getContext('2d');
- let color = this.evalMessage(data.color, cache);
+ const color = this.evalMessage(data.color, cache);
switch (shapeType) {
case 0: // Circle
diff --git a/actions/seperator_MOD.js b/actions/seperator_MOD.js
index 1bb66ab2..8ab631a7 100644
--- a/actions/seperator_MOD.js
+++ b/actions/seperator_MOD.js
@@ -1,110 +1,112 @@
-module.exports = {
- name: 'Separator',
- section: 'Other',
- fields: ['separator', 'color', 'bold', 'underline', 'fontSize'],
-
- meta: {
- version: '2.1.7',
- author: 'DBM Mods',
- authorUrl: 'https://github.com/dbm-network/mods',
- downloadURL: 'https://github.com/dbm-network/mods/blob/master/actions/file_control_separator.js',
- },
-
- subtitle(data) {
- let style = '';
- if (data.bold === 'true') style += 'font-weight: bold;';
- if (data.underline === 'true') style += 'text-decoration: underline;';
- if (data.fontSize) style += `font-size: ${parseInt(data.fontSize, 10)}px;`;
- const separator = data.separator || 'No separator provided';
- const color = data.color || '#000000';
- return `${separator} `;
- },
-
- html() {
- return `
- `;
- },
-
- init() {
- const { document } = this;
- const separatorField = document.getElementById('separator');
- const colorField = document.getElementById('color');
- const boldField = document.getElementById('bold');
- const underlineField = document.getElementById('underline');
- const fontSizeField = document.getElementById('fontSize');
-
- function updateSubtitle() {
- const separatorValue = separatorField.value.trim();
- const colorValue = colorField.value;
- const boldValue = boldField.value === 'true';
- const underlineValue = underlineField.value === 'true';
- const fontSizeValue = fontSizeField.value;
- const subtitle = document.querySelector('.subtitle');
- let style = '';
- if (boldValue) style += 'font-weight: bold;';
- if (underlineValue) style += 'text-decoration: underline;';
- if (fontSizeValue) style += `font-size: ${parseInt(fontSizeValue, 10)}px;`;
- subtitle.innerHTML = `${separatorValue || 'No separator provided'} `;
- }
-
- separatorField.addEventListener('input', updateSubtitle);
- colorField.addEventListener('input', updateSubtitle);
- boldField.addEventListener('change', updateSubtitle);
- underlineField.addEventListener('change', updateSubtitle);
- fontSizeField.addEventListener('input', updateSubtitle);
-
- // Trigger subtitle update on initialization
- updateSubtitle();
- },
-
- async action(cache) {
- const data = cache.actions[cache.index];
- const separator = this.evalMessage(data.separator, cache);
- const color = this.evalMessage(data.color, cache);
- const bold = data.bold === 'true';
- const underline = data.underline === 'true';
-
- // Store separator value if provided
- if (separator !== undefined) {
- cache.separator = separator;
- }
-
- // Store color value if provided
- if (color !== undefined) {
- cache.color = color;
- }
-
- // Store bold value if provided
- if (bold !== undefined) {
- cache.bold = bold;
- }
-
- // Store underline value if provided
- if (underline !== undefined) {
- cache.underline = underline;
- }
-
- this.callNextAction(cache);
- },
-
- mod() {},
-};
+module.exports = {
+ name: 'Separator',
+ section: 'Other',
+ fields: ['separator', 'color', 'bold', 'underline', 'fontSize'],
+
+ meta: {
+ version: '2.1.7',
+ author: 'DBM Mods',
+ authorUrl: 'https://github.com/dbm-network/mods',
+ downloadURL: 'https://github.com/dbm-network/mods/blob/master/actions/file_control_separator.js',
+ },
+
+ subtitle(data) {
+ let style = '';
+ if (data.bold === 'true') style += 'font-weight: bold;';
+ if (data.underline === 'true') style += 'text-decoration: underline;';
+ if (data.fontSize) style += `font-size: ${parseInt(data.fontSize, 10)}px;`;
+ const separator = data.separator || 'No separator provided';
+ const color = data.color || '#000000';
+ return `${separator} `;
+ },
+
+ html() {
+ return `
+ `;
+ },
+
+ init() {
+ const { document } = this;
+ const separatorField = document.getElementById('separator');
+ const colorField = document.getElementById('color');
+ const boldField = document.getElementById('bold');
+ const underlineField = document.getElementById('underline');
+ const fontSizeField = document.getElementById('fontSize');
+
+ function updateSubtitle() {
+ const separatorValue = separatorField.value.trim();
+ const colorValue = colorField.value;
+ const boldValue = boldField.value === 'true';
+ const underlineValue = underlineField.value === 'true';
+ const fontSizeValue = fontSizeField.value;
+ const subtitle = document.querySelector('.subtitle');
+ let style = '';
+ if (boldValue) style += 'font-weight: bold;';
+ if (underlineValue) style += 'text-decoration: underline;';
+ if (fontSizeValue) style += `font-size: ${parseInt(fontSizeValue, 10)}px;`;
+ subtitle.innerHTML = `${
+ separatorValue || 'No separator provided'
+ } `;
+ }
+
+ separatorField.addEventListener('input', updateSubtitle);
+ colorField.addEventListener('input', updateSubtitle);
+ boldField.addEventListener('change', updateSubtitle);
+ underlineField.addEventListener('change', updateSubtitle);
+ fontSizeField.addEventListener('input', updateSubtitle);
+
+ // Trigger subtitle update on initialization
+ updateSubtitle();
+ },
+
+ async action(cache) {
+ const data = cache.actions[cache.index];
+ const separator = this.evalMessage(data.separator, cache);
+ const color = this.evalMessage(data.color, cache);
+ const bold = data.bold === 'true';
+ const underline = data.underline === 'true';
+
+ // Store separator value if provided
+ if (separator !== undefined) {
+ cache.separator = separator;
+ }
+
+ // Store color value if provided
+ if (color !== undefined) {
+ cache.color = color;
+ }
+
+ // Store bold value if provided
+ if (bold !== undefined) {
+ cache.bold = bold;
+ }
+
+ // Store underline value if provided
+ if (underline !== undefined) {
+ cache.underline = underline;
+ }
+
+ this.callNextAction(cache);
+ },
+
+ mod() {},
+};
From 051774d53ec3aac6ef4290adeb5055f318e28d0f Mon Sep 17 00:00:00 2001
From: thekingofspace <37231416+thekingofspace@users.noreply.github.com>
Date: Thu, 18 Apr 2024 21:21:02 -0700
Subject: [PATCH 03/23] Updated these with lint
---
actions/canvas_create_primitive_MOD.js | 9 +++++----
actions/seperator_MOD.js | 2 +-
2 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/actions/canvas_create_primitive_MOD.js b/actions/canvas_create_primitive_MOD.js
index 01db6a59..ebb0db46 100644
--- a/actions/canvas_create_primitive_MOD.js
+++ b/actions/canvas_create_primitive_MOD.js
@@ -2,10 +2,11 @@ module.exports = {
name: 'Canvas Create Shape',
section: 'Image Editing',
meta: {
- version: '1.0.0',
- author: 'Your Name',
- authorUrl: 'https://yourwebsite.com',
- downloadURL: 'https://github.com/yourrepository/your-script.js',
+ version: '2.1.7',
+ preciseCheck: false,
+ author: 'DBM Mods',
+ authorUrl: 'https://github.com/dbm-network/mods',
+ downloadURL: 'https://github.com/dbm-network/mods/blob/master/actions/canvas_create_primitive_MOD.js',
},
subtitle(data) {
diff --git a/actions/seperator_MOD.js b/actions/seperator_MOD.js
index 8ab631a7..717675c7 100644
--- a/actions/seperator_MOD.js
+++ b/actions/seperator_MOD.js
@@ -7,7 +7,7 @@ module.exports = {
version: '2.1.7',
author: 'DBM Mods',
authorUrl: 'https://github.com/dbm-network/mods',
- downloadURL: 'https://github.com/dbm-network/mods/blob/master/actions/file_control_separator.js',
+ downloadURL: 'https://github.com/dbm-network/mods/blob/master/actions/seperator_MOD.js',
},
subtitle(data) {
From 6ab1d2361da4ce55a04d5ecfaa6df087de58268b Mon Sep 17 00:00:00 2001
From: thekingofspace <37231416+thekingofspace@users.noreply.github.com>
Date: Wed, 24 Apr 2024 10:05:36 -0700
Subject: [PATCH 04/23] Updated canvas_create_primitive_MOD.js
---
actions/canvas_create_primitive_MOD.js | 99 ++++++++++++++++++++++----
1 file changed, 86 insertions(+), 13 deletions(-)
diff --git a/actions/canvas_create_primitive_MOD.js b/actions/canvas_create_primitive_MOD.js
index ebb0db46..05d06199 100644
--- a/actions/canvas_create_primitive_MOD.js
+++ b/actions/canvas_create_primitive_MOD.js
@@ -11,13 +11,24 @@ module.exports = {
subtitle(data) {
const info = parseInt(data.info, 10);
- if (info === 0) {
- return data.color ? `Create Circle with Color ${data.color}` : 'No color circle has been created';
- }
- if (info === 1) {
- return data.color ? `Create Rectangle with Color ${data.color}` : 'No color rectangle has been created';
+ switch (info) {
+ case 0:
+ return data.color ? `Create Circle with Color ${data.color}` : 'No color circle has been created';
+ case 1:
+ return data.color ? `Create Rectangle with Color ${data.color}` : 'No color rectangle has been created';
+ case 2:
+ return data.color ? `Create Triangle with Color ${data.color}` : 'No color triangle has been created';
+ case 3:
+ return data.color ? `Create Hexagon with Color ${data.color}` : 'No color hexagon has been created';
+ case 4:
+ return data.color ? `Create Pentagon with Color ${data.color}` : 'No color pentagon has been created';
+ case 5:
+ return data.color ? `Create Ellipse with Color ${data.color}` : 'No color ellipse has been created';
+ case 6:
+ return data.color ? `Create Star with Color ${data.color}` : 'No color star has been created';
+ default:
+ return '';
}
- // Add more cases for different shapes as needed
},
variableStorage(data, varType) {
@@ -35,12 +46,15 @@ module.exports = {
Circle
Rectangle
-
+ Triangle
+ Hexagon
+ Pentagon
+ Ellipse
+ Star
-
Width (px)
@@ -52,7 +66,6 @@ module.exports = {
-
Color
@@ -60,7 +73,6 @@ module.exports = {
-
`;
},
@@ -76,17 +88,78 @@ module.exports = {
const color = this.evalMessage(data.color, cache);
switch (shapeType) {
- case 0: // Circle
+ case 0:
ctx.beginPath();
ctx.arc(width / 2, height / 2, Math.min(width, height) / 2, 0, 2 * Math.PI);
ctx.fillStyle = color;
ctx.fill();
break;
- case 1: // Rectangle
+ case 1:
ctx.fillStyle = color;
ctx.fillRect(0, 0, width, height);
break;
- // Add more cases for different shapes
+ case 2:
+ ctx.beginPath();
+ ctx.moveTo(width / 2, 0);
+ ctx.lineTo(width, height);
+ ctx.lineTo(0, height);
+ ctx.closePath();
+ ctx.fillStyle = color;
+ ctx.fill();
+ break;
+ case 3:
+ ctx.beginPath();
+ const sideLength = Math.min(width, height) / 2;
+ const xCenter = width / 2;
+ const yCenter = height / 2;
+ for (let i = 0; i < 6; i++) {
+ const angle = (Math.PI / 3) * i;
+ const x = xCenter + sideLength * Math.cos(angle);
+ const y = yCenter + sideLength * Math.sin(angle);
+ if (i === 0) {
+ ctx.moveTo(x, y);
+ } else {
+ ctx.lineTo(x, y);
+ }
+ }
+ ctx.closePath();
+ ctx.fillStyle = color;
+ ctx.fill();
+ break;
+ case 4:
+ ctx.beginPath();
+ const angleStep = (2 * Math.PI) / 5;
+ const radius = Math.min(width, height) / 2;
+ const centerX = width / 2;
+ const centerY = height / 2;
+ ctx.moveTo(centerX + radius * Math.cos(0), centerY + radius * Math.sin(0));
+ for (let i = 1; i <= 5; i++) {
+ ctx.lineTo(centerX + radius * Math.cos(angleStep * i), centerY + radius * Math.sin(angleStep * i));
+ }
+ ctx.closePath();
+ ctx.fillStyle = color;
+ ctx.fill();
+ break;
+ case 5:
+ ctx.beginPath();
+ ctx.ellipse(width / 2, height / 2, width / 2, height / 2, 0, 0, 2 * Math.PI);
+ ctx.fillStyle = color;
+ ctx.fill();
+ break;
+ case 6:
+ const numPoints = 5;
+ const outerRadius = Math.min(width, height) / 2;
+ const innerRadius = outerRadius * 0.5;
+ ctx.beginPath();
+ for (let i = 0; i < numPoints * 2; i++) {
+ const radius = i % 2 === 0 ? outerRadius : innerRadius;
+ const angle = (i * Math.PI) / numPoints - Math.PI / 2;
+ ctx.lineTo(width / 2 + radius * Math.cos(angle), height / 2 + radius * Math.sin(angle));
+ }
+ ctx.closePath();
+ ctx.fillStyle = color;
+ ctx.fill();
+ break;
default:
break;
}
From 3ae7fbdc1a083ca486bcd5fd34d075587b9eca02 Mon Sep 17 00:00:00 2001
From: thekingofspace <37231416+thekingofspace@users.noreply.github.com>
Date: Sun, 2 Jun 2024 20:48:00 -0700
Subject: [PATCH 05/23] Added json_read_MOD
added json_write_MOD.js
---
actions/json_read_MOD.js | 99 ++++++++++++++++++++
actions/json_write_MOD.js | 184 ++++++++++++++++++++++++++++++++++++++
2 files changed, 283 insertions(+)
create mode 100644 actions/json_read_MOD.js
create mode 100644 actions/json_write_MOD.js
diff --git a/actions/json_read_MOD.js b/actions/json_read_MOD.js
new file mode 100644
index 00000000..fb221b0b
--- /dev/null
+++ b/actions/json_read_MOD.js
@@ -0,0 +1,99 @@
+const fs = require('fs');
+const path = require('path');
+
+module.exports = {
+ name: 'Read JSON File',
+ section: 'File Stuff',
+ fields: ['filepath', 'title', 'contentTitle', 'storage', 'varName'],
+ meta: {
+ version: '2.1.7',
+ preciseCheck: false,
+ author: 'DBM Mods',
+ authorUrl: 'https://github.com/dbm-network/mods',
+ },
+
+ subtitle(data) {
+ return `Read JSON file ${data.filepath} content ${data.contentTitle}`;
+ },
+
+ variableStorage(data, varType) {
+ if (parseInt(data.storage, 10) !== varType) return;
+ return [data.varName, 'Unknown'];
+ },
+
+ html() {
+ return `
+
+
+ File Path
+
+
+
+ Title
+
+
+
+ Content Title
+
+
+
+
+
+
+ `;
+ },
+
+ init() {},
+
+ async action(cache) {
+ const data = cache.actions[cache.index];
+ let filepath = this.evalMessage(data.filepath, cache);
+ const title = this.evalMessage(data.title, cache);
+ const contentTitle = this.evalMessage(data.contentTitle, cache);
+ const storage = parseInt(data.storage, 10);
+ const varName = this.evalMessage(data.varName, cache);
+
+ if (filepath.startsWith('./')) {
+ filepath = path.join(__dirname, '..', filepath.substring(2));
+ }
+
+ let jsonData;
+
+ try {
+ if (fs.existsSync(filepath)) {
+ const fileData = fs.readFileSync(filepath);
+ jsonData = JSON.parse(fileData);
+ } else {
+ throw new Error('File does not exist');
+ }
+ } catch (error) {
+ console.error(`Error reading JSON file: ${error}`);
+ this.storeValue(undefined, storage, varName, cache);
+ return this.callNextAction(cache);
+ }
+
+ let result;
+ try {
+ const titleData = jsonData.find((item) => item.Title === title);
+ if (!titleData) throw new Error('Title not found');
+
+ // Split the contentTitle by '/' to handle nested content
+ const contentKeys = contentTitle.split('/');
+ let nestedContent = titleData;
+ for (const key of contentKeys) {
+ nestedContent = nestedContent[key];
+ if (nestedContent === undefined) throw new Error(`Content Key '${key}' not found`);
+ }
+ result = nestedContent;
+ } catch (error) {
+ console.error(`Error accessing data: ${error}`);
+ this.storeValue(undefined, storage, varName, cache);
+ return this.callNextAction(cache);
+ }
+
+ this.storeValue(result, storage, varName, cache);
+ this.callNextAction(cache);
+ },
+
+ mod() {},
+};
diff --git a/actions/json_write_MOD.js b/actions/json_write_MOD.js
new file mode 100644
index 00000000..7b8611c2
--- /dev/null
+++ b/actions/json_write_MOD.js
@@ -0,0 +1,184 @@
+const fs = require('fs');
+const path = require('path');
+
+module.exports = {
+ name: 'JSON File Control',
+ section: 'File Stuff',
+ fields: ['filepath', 'action', 'title', 'contentTitle', 'contentText', 'newTitle', 'oldTitle', 'deleteContentTitle'],
+ meta: {
+ version: '2.1.7',
+ preciseCheck: false,
+ author: 'DBM Mods',
+ authorUrl: 'https://github.com/dbm-network/mods',
+ },
+
+ subtitle(data) {
+ return `JSON edit on ${data.filepath} with ${data.action}`;
+ },
+
+ html() {
+ return `
+
+ `;
+ },
+
+ init() {
+ const { glob, document } = this;
+
+ glob.onChangeAction = function (event) {
+ const value = event.value;
+ document.getElementById('titleSection').style.display =
+ value === 'addTitle' || value === 'addContent' || value === 'renameContent' ? 'block' : 'none';
+ document.getElementById('contentSection').style.display = value === 'addContent' ? 'block' : 'none';
+ document.getElementById('renameSection').style.display =
+ value === 'renameContent' || value === 'renameTitle' ? 'block' : 'none';
+ document.getElementById('deleteSection').style.display = value === 'deleteContent' ? 'block' : 'none';
+ };
+
+ glob.onChangeAction(document.getElementById('action'));
+ },
+
+ async action(cache) {
+ const data = cache.actions[cache.index];
+ let filepath = this.evalMessage(data.filepath, cache);
+
+ if (filepath.startsWith('./')) {
+ filepath = path.join(__dirname, '..', filepath.substring(2));
+ }
+
+ const action = data.action;
+ const title = this.evalMessage(data.title, cache);
+ const contentTitle = this.evalMessage(data.contentTitle, cache);
+ const contentText = this.evalMessage(data.contentText, cache);
+ const oldTitle = this.evalMessage(data.oldTitle, cache);
+ const newTitle = this.evalMessage(data.newTitle, cache);
+ const deleteContentTitle = this.evalMessage(data.deleteContentTitle, cache);
+
+ // Load JSON file
+ let jsonData;
+ try {
+ if (fs.existsSync(filepath)) {
+ const fileData = fs.readFileSync(filepath);
+ jsonData = JSON.parse(fileData);
+ } else {
+ jsonData = [];
+ }
+ } catch (error) {
+ console.error(`Error reading JSON file: ${error}`);
+ jsonData = [];
+ }
+
+ switch (action) {
+ case 'addTitle':
+ if (title) {
+ jsonData.push({ Title: title });
+ }
+ break;
+ case 'addContent':
+ let target = jsonData.find((item) => item.Title === title);
+ if (!target) {
+ target = { Title: title };
+ jsonData.push(target);
+ }
+ if (contentTitle.includes('/')) {
+ const keys = contentTitle.split('/');
+ keys.reduce((obj, key, index) => {
+ if (index === keys.length - 1) {
+ obj[key] = isNaN(contentText) ? contentText : parseFloat(contentText);
+ } else {
+ obj[key] = obj[key] || {};
+ }
+ return obj[key];
+ }, target);
+ } else {
+ target[contentTitle] = isNaN(contentText) ? contentText : parseFloat(contentText);
+ }
+ break;
+ case 'renameContent':
+ jsonData.forEach((item) => {
+ if (item.Title === title && item[contentTitle]) {
+ item[newTitle] = item[contentTitle];
+ delete item[contentTitle];
+ }
+ });
+ break;
+ case 'renameTitle':
+ jsonData.forEach((item) => {
+ if (item.Title === oldTitle) {
+ item.Title = newTitle;
+ }
+ });
+ break;
+ case 'deleteContent':
+ jsonData.forEach((item) => {
+ if (item.Title === title) {
+ if (deleteContentTitle.includes('/')) {
+ const keys = deleteContentTitle.split('/');
+ keys.reduce((obj, key, index) => {
+ if (index === keys.length - 1) {
+ delete obj[key];
+ } else {
+ return obj[key];
+ }
+ }, item);
+ } else {
+ delete item[deleteContentTitle];
+ }
+ }
+ });
+ break;
+ case 'deleteTitle':
+ jsonData = jsonData.filter((item) => item.Title !== title);
+ break;
+ }
+
+ // Save JSON file
+ try {
+ fs.writeFileSync(filepath, JSON.stringify(jsonData, null, 2));
+ } catch (error) {
+ console.error(`Error writing JSON file: ${error}`);
+ }
+
+ this.callNextAction(cache);
+ },
+
+ mod() {},
+};
From b31b4817c19ce4e64ffba87e2ecbe535ac5e92e8 Mon Sep 17 00:00:00 2001
From: thekingofspace <37231416+thekingofspace@users.noreply.github.com>
Date: Sun, 2 Jun 2024 21:24:41 -0700
Subject: [PATCH 06/23] Added json_read_MOD
added json_write_MOD.js
---
actions/json_read_MOD.js | 35 +++++++++++++++++++----------------
1 file changed, 19 insertions(+), 16 deletions(-)
diff --git a/actions/json_read_MOD.js b/actions/json_read_MOD.js
index fb221b0b..ca01e309 100644
--- a/actions/json_read_MOD.js
+++ b/actions/json_read_MOD.js
@@ -5,15 +5,9 @@ module.exports = {
name: 'Read JSON File',
section: 'File Stuff',
fields: ['filepath', 'title', 'contentTitle', 'storage', 'varName'],
- meta: {
- version: '2.1.7',
- preciseCheck: false,
- author: 'DBM Mods',
- authorUrl: 'https://github.com/dbm-network/mods',
- },
subtitle(data) {
- return `Read JSON file ${data.filepath} content ${data.contentTitle}`;
+ return `Read JSON file "${data.filepath}"`;
},
variableStorage(data, varType) {
@@ -62,6 +56,11 @@ module.exports = {
try {
if (fs.existsSync(filepath)) {
const fileData = fs.readFileSync(filepath);
+ if (fileData.length === 0) {
+ console.warn('JSON file is empty.');
+ this.storeValue(undefined, storage, varName, cache);
+ return this.callNextAction(cache);
+ }
jsonData = JSON.parse(fileData);
} else {
throw new Error('File does not exist');
@@ -74,17 +73,21 @@ module.exports = {
let result;
try {
- const titleData = jsonData.find((item) => item.Title === title);
+ const titleData = jsonData.find(item => item.Title === title);
if (!titleData) throw new Error('Title not found');
- // Split the contentTitle by '/' to handle nested content
- const contentKeys = contentTitle.split('/');
- let nestedContent = titleData;
- for (const key of contentKeys) {
- nestedContent = nestedContent[key];
- if (nestedContent === undefined) throw new Error(`Content Key '${key}' not found`);
+ if (contentTitle.includes('/')) {
+ const contentKeys = contentTitle.split('/');
+ result = {};
+ for (const key of contentKeys) {
+ if (titleData[key] !== undefined) {
+ result[key] = titleData[key];
+ }
+ }
+ } else {
+ if (titleData[contentTitle] === undefined) throw new Error('Content Title not found');
+ result = titleData[contentTitle];
}
- result = nestedContent;
} catch (error) {
console.error(`Error accessing data: ${error}`);
this.storeValue(undefined, storage, varName, cache);
@@ -95,5 +98,5 @@ module.exports = {
this.callNextAction(cache);
},
- mod() {},
+ mod() {}
};
From 00cf7e4f0627f597a6be84adc4f59f43c8273d16 Mon Sep 17 00:00:00 2001
From: thekingofspace <37231416+thekingofspace@users.noreply.github.com>
Date: Sun, 2 Jun 2024 21:26:09 -0700
Subject: [PATCH 07/23] Added json_read_MOD
added json_write_MOD.js
---
actions/json_write_MOD.js | 178 ++++++++++----------------------------
1 file changed, 48 insertions(+), 130 deletions(-)
diff --git a/actions/json_write_MOD.js b/actions/json_write_MOD.js
index 7b8611c2..ca01e309 100644
--- a/actions/json_write_MOD.js
+++ b/actions/json_write_MOD.js
@@ -2,18 +2,17 @@ const fs = require('fs');
const path = require('path');
module.exports = {
- name: 'JSON File Control',
+ name: 'Read JSON File',
section: 'File Stuff',
- fields: ['filepath', 'action', 'title', 'contentTitle', 'contentText', 'newTitle', 'oldTitle', 'deleteContentTitle'],
- meta: {
- version: '2.1.7',
- preciseCheck: false,
- author: 'DBM Mods',
- authorUrl: 'https://github.com/dbm-network/mods',
- },
+ fields: ['filepath', 'title', 'contentTitle', 'storage', 'varName'],
subtitle(data) {
- return `JSON edit on ${data.filepath} with ${data.action}`;
+ return `Read JSON file "${data.filepath}"`;
+ },
+
+ variableStorage(data, varType) {
+ if (parseInt(data.storage, 10) !== varType) return;
+ return [data.varName, 'Unknown'];
},
html() {
@@ -24,161 +23,80 @@ module.exports = {
- Action
-
- Add Title
- Add Content
- Rename Content
- Rename Title
- Delete Content
- Delete Title
-
-
-
Title
-
+
-
+
Content Title
-
-
- Content Text
-
-
-
- Old Title
-
-
- New Title
-
+
-
-
Content Title to Delete
-
+
+
`;
},
- init() {
- const { glob, document } = this;
-
- glob.onChangeAction = function (event) {
- const value = event.value;
- document.getElementById('titleSection').style.display =
- value === 'addTitle' || value === 'addContent' || value === 'renameContent' ? 'block' : 'none';
- document.getElementById('contentSection').style.display = value === 'addContent' ? 'block' : 'none';
- document.getElementById('renameSection').style.display =
- value === 'renameContent' || value === 'renameTitle' ? 'block' : 'none';
- document.getElementById('deleteSection').style.display = value === 'deleteContent' ? 'block' : 'none';
- };
-
- glob.onChangeAction(document.getElementById('action'));
- },
+ init() {},
async action(cache) {
const data = cache.actions[cache.index];
let filepath = this.evalMessage(data.filepath, cache);
+ const title = this.evalMessage(data.title, cache);
+ const contentTitle = this.evalMessage(data.contentTitle, cache);
+ const storage = parseInt(data.storage, 10);
+ const varName = this.evalMessage(data.varName, cache);
if (filepath.startsWith('./')) {
filepath = path.join(__dirname, '..', filepath.substring(2));
}
- const action = data.action;
- const title = this.evalMessage(data.title, cache);
- const contentTitle = this.evalMessage(data.contentTitle, cache);
- const contentText = this.evalMessage(data.contentText, cache);
- const oldTitle = this.evalMessage(data.oldTitle, cache);
- const newTitle = this.evalMessage(data.newTitle, cache);
- const deleteContentTitle = this.evalMessage(data.deleteContentTitle, cache);
-
- // Load JSON file
let jsonData;
+
try {
if (fs.existsSync(filepath)) {
const fileData = fs.readFileSync(filepath);
+ if (fileData.length === 0) {
+ console.warn('JSON file is empty.');
+ this.storeValue(undefined, storage, varName, cache);
+ return this.callNextAction(cache);
+ }
jsonData = JSON.parse(fileData);
} else {
- jsonData = [];
+ throw new Error('File does not exist');
}
} catch (error) {
console.error(`Error reading JSON file: ${error}`);
- jsonData = [];
+ this.storeValue(undefined, storage, varName, cache);
+ return this.callNextAction(cache);
}
- switch (action) {
- case 'addTitle':
- if (title) {
- jsonData.push({ Title: title });
- }
- break;
- case 'addContent':
- let target = jsonData.find((item) => item.Title === title);
- if (!target) {
- target = { Title: title };
- jsonData.push(target);
- }
- if (contentTitle.includes('/')) {
- const keys = contentTitle.split('/');
- keys.reduce((obj, key, index) => {
- if (index === keys.length - 1) {
- obj[key] = isNaN(contentText) ? contentText : parseFloat(contentText);
- } else {
- obj[key] = obj[key] || {};
- }
- return obj[key];
- }, target);
- } else {
- target[contentTitle] = isNaN(contentText) ? contentText : parseFloat(contentText);
- }
- break;
- case 'renameContent':
- jsonData.forEach((item) => {
- if (item.Title === title && item[contentTitle]) {
- item[newTitle] = item[contentTitle];
- delete item[contentTitle];
- }
- });
- break;
- case 'renameTitle':
- jsonData.forEach((item) => {
- if (item.Title === oldTitle) {
- item.Title = newTitle;
- }
- });
- break;
- case 'deleteContent':
- jsonData.forEach((item) => {
- if (item.Title === title) {
- if (deleteContentTitle.includes('/')) {
- const keys = deleteContentTitle.split('/');
- keys.reduce((obj, key, index) => {
- if (index === keys.length - 1) {
- delete obj[key];
- } else {
- return obj[key];
- }
- }, item);
- } else {
- delete item[deleteContentTitle];
- }
- }
- });
- break;
- case 'deleteTitle':
- jsonData = jsonData.filter((item) => item.Title !== title);
- break;
- }
-
- // Save JSON file
+ let result;
try {
- fs.writeFileSync(filepath, JSON.stringify(jsonData, null, 2));
+ const titleData = jsonData.find(item => item.Title === title);
+ if (!titleData) throw new Error('Title not found');
+
+ if (contentTitle.includes('/')) {
+ const contentKeys = contentTitle.split('/');
+ result = {};
+ for (const key of contentKeys) {
+ if (titleData[key] !== undefined) {
+ result[key] = titleData[key];
+ }
+ }
+ } else {
+ if (titleData[contentTitle] === undefined) throw new Error('Content Title not found');
+ result = titleData[contentTitle];
+ }
} catch (error) {
- console.error(`Error writing JSON file: ${error}`);
+ console.error(`Error accessing data: ${error}`);
+ this.storeValue(undefined, storage, varName, cache);
+ return this.callNextAction(cache);
}
+ this.storeValue(result, storage, varName, cache);
this.callNextAction(cache);
},
- mod() {},
+ mod() {}
};
From 88b9f75329cffdf9e4cfade44d25832b10d6a818 Mon Sep 17 00:00:00 2001
From: thekingofspace <37231416+thekingofspace@users.noreply.github.com>
Date: Sun, 2 Jun 2024 21:27:30 -0700
Subject: [PATCH 08/23] Added json_read_MOD
added json_write_MOD.js
---
actions/json_read_MOD.js | 4 ++--
actions/json_write_MOD.js | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/actions/json_read_MOD.js b/actions/json_read_MOD.js
index ca01e309..dd85f0f0 100644
--- a/actions/json_read_MOD.js
+++ b/actions/json_read_MOD.js
@@ -73,7 +73,7 @@ module.exports = {
let result;
try {
- const titleData = jsonData.find(item => item.Title === title);
+ const titleData = jsonData.find((item) => item.Title === title);
if (!titleData) throw new Error('Title not found');
if (contentTitle.includes('/')) {
@@ -98,5 +98,5 @@ module.exports = {
this.callNextAction(cache);
},
- mod() {}
+ mod() {},
};
diff --git a/actions/json_write_MOD.js b/actions/json_write_MOD.js
index ca01e309..dd85f0f0 100644
--- a/actions/json_write_MOD.js
+++ b/actions/json_write_MOD.js
@@ -73,7 +73,7 @@ module.exports = {
let result;
try {
- const titleData = jsonData.find(item => item.Title === title);
+ const titleData = jsonData.find((item) => item.Title === title);
if (!titleData) throw new Error('Title not found');
if (contentTitle.includes('/')) {
@@ -98,5 +98,5 @@ module.exports = {
this.callNextAction(cache);
},
- mod() {}
+ mod() {},
};
From 918a269a5e2678506bcd0e424e4064429f7070d2 Mon Sep 17 00:00:00 2001
From: thekingofspace <37231416+thekingofspace@users.noreply.github.com>
Date: Sun, 2 Jun 2024 21:51:15 -0700
Subject: [PATCH 09/23] Fixed lint issue I hope
---
actions/canvas_create_primitive_MOD.js | 40 +++++++++++++++++---------
1 file changed, 27 insertions(+), 13 deletions(-)
diff --git a/actions/canvas_create_primitive_MOD.js b/actions/canvas_create_primitive_MOD.js
index 05d06199..eee55c92 100644
--- a/actions/canvas_create_primitive_MOD.js
+++ b/actions/canvas_create_primitive_MOD.js
@@ -87,6 +87,20 @@ module.exports = {
const ctx = canvas.getContext('2d');
const color = this.evalMessage(data.color, cache);
+ let sideLength;
+ let xCenter;
+ let yCenter;
+ let angle;
+ let x;
+ let y;
+ let angleStep;
+ let radius;
+ let centerX;
+ let centerY;
+ let numPoints;
+ let outerRadius;
+ let innerRadius;
+
switch (shapeType) {
case 0:
ctx.beginPath();
@@ -109,13 +123,13 @@ module.exports = {
break;
case 3:
ctx.beginPath();
- const sideLength = Math.min(width, height) / 2;
- const xCenter = width / 2;
- const yCenter = height / 2;
+ sideLength = Math.min(width, height) / 2;
+ xCenter = width / 2;
+ yCenter = height / 2;
for (let i = 0; i < 6; i++) {
- const angle = (Math.PI / 3) * i;
- const x = xCenter + sideLength * Math.cos(angle);
- const y = yCenter + sideLength * Math.sin(angle);
+ angle = (Math.PI / 3) * i;
+ x = xCenter + sideLength * Math.cos(angle);
+ y = yCenter + sideLength * Math.sin(angle);
if (i === 0) {
ctx.moveTo(x, y);
} else {
@@ -128,10 +142,10 @@ module.exports = {
break;
case 4:
ctx.beginPath();
- const angleStep = (2 * Math.PI) / 5;
- const radius = Math.min(width, height) / 2;
- const centerX = width / 2;
- const centerY = height / 2;
+ angleStep = (2 * Math.PI) / 5;
+ radius = Math.min(width, height) / 2;
+ centerX = width / 2;
+ centerY = height / 2;
ctx.moveTo(centerX + radius * Math.cos(0), centerY + radius * Math.sin(0));
for (let i = 1; i <= 5; i++) {
ctx.lineTo(centerX + radius * Math.cos(angleStep * i), centerY + radius * Math.sin(angleStep * i));
@@ -147,9 +161,9 @@ module.exports = {
ctx.fill();
break;
case 6:
- const numPoints = 5;
- const outerRadius = Math.min(width, height) / 2;
- const innerRadius = outerRadius * 0.5;
+ numPoints = 5;
+ outerRadius = Math.min(width, height) / 2;
+ innerRadius = outerRadius * 0.5;
ctx.beginPath();
for (let i = 0; i < numPoints * 2; i++) {
const radius = i % 2 === 0 ? outerRadius : innerRadius;
From 5d2c22bf9c9ee8403f6931319bcc0ae45e8b3258 Mon Sep 17 00:00:00 2001
From: thekingofspace <37231416+thekingofspace@users.noreply.github.com>
Date: Mon, 3 Jun 2024 02:31:07 -0700
Subject: [PATCH 10/23] Fixed lint issue I hope
---
actions/json_write_MOD.js | 176 +++++++++++++++++++++++++++-----------
1 file changed, 128 insertions(+), 48 deletions(-)
diff --git a/actions/json_write_MOD.js b/actions/json_write_MOD.js
index dd85f0f0..7e510811 100644
--- a/actions/json_write_MOD.js
+++ b/actions/json_write_MOD.js
@@ -2,17 +2,18 @@ const fs = require('fs');
const path = require('path');
module.exports = {
- name: 'Read JSON File',
+ name: 'JSON File Control',
section: 'File Stuff',
- fields: ['filepath', 'title', 'contentTitle', 'storage', 'varName'],
-
- subtitle(data) {
- return `Read JSON file "${data.filepath}"`;
+ fields: ['filepath', 'action', 'title', 'contentTitle', 'contentText', 'newTitle', 'oldTitle', 'deleteContentTitle'],
+ meta: {
+ version: '2.1.7',
+ preciseCheck: false,
+ author: 'DBM Mods',
+ authorUrl: 'https://github.com/dbm-network/mods',
},
- variableStorage(data, varType) {
- if (parseInt(data.storage, 10) !== varType) return;
- return [data.varName, 'Unknown'];
+ subtitle(data) {
+ return `Perform JSON operations on ${data.filepath}`;
},
html() {
@@ -23,80 +24,159 @@ module.exports = {
+ Action
+
+ Add Title
+ Add Content
+ Rename Content
+ Rename Title
+ Delete Content
+ Delete Title
+
+
+
Title
-
+
-
+
Content Title
-
+
+
+ Content Text
+
-
`;
},
- init() {},
+ init() {
+ const { glob, document } = this;
+
+ glob.onChangeAction = function(event) {
+ const value = event.value;
+ document.getElementById('titleSection').style.display = value === 'addTitle' || value === 'addContent' || value === 'renameContent' ? 'block' : 'none';
+ document.getElementById('contentSection').style.display = value === 'addContent' ? 'block' : 'none';
+ document.getElementById('renameSection').style.display = value === 'renameContent' || value === 'renameTitle' ? 'block' : 'none';
+ document.getElementById('deleteSection').style.display = value === 'deleteContent' ? 'block' : 'none';
+ };
+
+ glob.onChangeAction(document.getElementById('action'));
+ },
async action(cache) {
const data = cache.actions[cache.index];
let filepath = this.evalMessage(data.filepath, cache);
- const title = this.evalMessage(data.title, cache);
- const contentTitle = this.evalMessage(data.contentTitle, cache);
- const storage = parseInt(data.storage, 10);
- const varName = this.evalMessage(data.varName, cache);
if (filepath.startsWith('./')) {
filepath = path.join(__dirname, '..', filepath.substring(2));
}
- let jsonData;
+ const action = data.action;
+ const title = this.evalMessage(data.title, cache);
+ const contentTitle = this.evalMessage(data.contentTitle, cache);
+ const contentText = this.evalMessage(data.contentText, cache);
+ const oldTitle = this.evalMessage(data.oldTitle, cache);
+ const newTitle = this.evalMessage(data.newTitle, cache);
+ const deleteContentTitle = this.evalMessage(data.deleteContentTitle, cache);
+ // Load JSON file
+ let jsonData;
try {
if (fs.existsSync(filepath)) {
const fileData = fs.readFileSync(filepath);
- if (fileData.length === 0) {
- console.warn('JSON file is empty.');
- this.storeValue(undefined, storage, varName, cache);
- return this.callNextAction(cache);
- }
jsonData = JSON.parse(fileData);
} else {
- throw new Error('File does not exist');
+ jsonData = [];
}
} catch (error) {
console.error(`Error reading JSON file: ${error}`);
- this.storeValue(undefined, storage, varName, cache);
- return this.callNextAction(cache);
+ jsonData = [];
}
- let result;
- try {
- const titleData = jsonData.find((item) => item.Title === title);
- if (!titleData) throw new Error('Title not found');
-
- if (contentTitle.includes('/')) {
- const contentKeys = contentTitle.split('/');
- result = {};
- for (const key of contentKeys) {
- if (titleData[key] !== undefined) {
- result[key] = titleData[key];
- }
+ switch (action) {
+ case 'addTitle':
+ if (title) {
+ jsonData.push({ Title: title });
}
- } else {
- if (titleData[contentTitle] === undefined) throw new Error('Content Title not found');
- result = titleData[contentTitle];
- }
+ break;
+ case 'addContent':
+ let target = jsonData.find(item => item.Title === title);
+ if (!target) {
+ target = { Title: title };
+ jsonData.push(target);
+ }
+ if (contentTitle.includes('/')) {
+ const keys = contentTitle.split('/');
+ keys.reduce((obj, key, index) => {
+ if (index === keys.length - 1) {
+ obj[key] = isNaN(contentText) ? contentText : parseFloat(contentText);
+ } else {
+ obj[key] = obj[key] || {};
+ }
+ return obj[key];
+ }, target);
+ } else {
+ target[contentTitle] = isNaN(contentText) ? contentText : parseFloat(contentText);
+ }
+ break;
+ case 'renameContent':
+ jsonData.forEach(item => {
+ if (item.Title === title && item[contentTitle]) {
+ item[newTitle] = item[contentTitle];
+ delete item[contentTitle];
+ }
+ });
+ break;
+ case 'renameTitle':
+ jsonData.forEach(item => {
+ if (item.Title === oldTitle) {
+ item.Title = newTitle;
+ }
+ });
+ break;
+ case 'deleteContent':
+ jsonData.forEach(item => {
+ if (item.Title === title) {
+ if (deleteContentTitle.includes('/')) {
+ const keys = deleteContentTitle.split('/');
+ keys.reduce((obj, key, index) => {
+ if (index === keys.length - 1) {
+ delete obj[key];
+ } else {
+ return obj[key];
+ }
+ }, item);
+ } else {
+ delete item[deleteContentTitle];
+ }
+ }
+ });
+ break;
+ case 'deleteTitle':
+ jsonData = jsonData.filter(item => item.Title !== title);
+ break;
+ }
+
+ // Save JSON file
+ try {
+ fs.writeFileSync(filepath, JSON.stringify(jsonData, null, 2));
} catch (error) {
- console.error(`Error accessing data: ${error}`);
- this.storeValue(undefined, storage, varName, cache);
- return this.callNextAction(cache);
+ console.error(`Error writing JSON file: ${error}`);
}
- this.storeValue(result, storage, varName, cache);
this.callNextAction(cache);
},
- mod() {},
+ mod() {}
};
From 6044bffee798ae01a3fe25cfb825ba4275b32ff4 Mon Sep 17 00:00:00 2001
From: thekingofspace <37231416+thekingofspace@users.noreply.github.com>
Date: Mon, 3 Jun 2024 07:29:12 -0700
Subject: [PATCH 11/23] Fixed prettier issues
Fixed linting issues inside json write
Fixed issue with canvas paint not using cases
---
actions/json_write_MOD.js | 27 ++++++++++++++++-----------
1 file changed, 16 insertions(+), 11 deletions(-)
diff --git a/actions/json_write_MOD.js b/actions/json_write_MOD.js
index 7e510811..682462b5 100644
--- a/actions/json_write_MOD.js
+++ b/actions/json_write_MOD.js
@@ -63,11 +63,13 @@ module.exports = {
init() {
const { glob, document } = this;
- glob.onChangeAction = function(event) {
+ glob.onChangeAction = function onChangeAction(event) {
const value = event.value;
- document.getElementById('titleSection').style.display = value === 'addTitle' || value === 'addContent' || value === 'renameContent' ? 'block' : 'none';
+ document.getElementById('titleSection').style.display =
+ value === 'addTitle' || value === 'addContent' || value === 'renameContent' ? 'block' : 'none';
document.getElementById('contentSection').style.display = value === 'addContent' ? 'block' : 'none';
- document.getElementById('renameSection').style.display = value === 'renameContent' || value === 'renameTitle' ? 'block' : 'none';
+ document.getElementById('renameSection').style.display =
+ value === 'renameContent' || value === 'renameTitle' ? 'block' : 'none';
document.getElementById('deleteSection').style.display = value === 'deleteContent' ? 'block' : 'none';
};
@@ -104,6 +106,8 @@ module.exports = {
jsonData = [];
}
+ let target;
+
switch (action) {
case 'addTitle':
if (title) {
@@ -111,14 +115,14 @@ module.exports = {
}
break;
case 'addContent':
- let target = jsonData.find(item => item.Title === title);
+ target = jsonData.find((item) => item.Title === title);
if (!target) {
target = { Title: title };
jsonData.push(target);
}
if (contentTitle.includes('/')) {
const keys = contentTitle.split('/');
- keys.reduce((obj, key, index) => {
+ keys.reduce(function addNestedContent(obj, key, index) {
if (index === keys.length - 1) {
obj[key] = isNaN(contentText) ? contentText : parseFloat(contentText);
} else {
@@ -131,7 +135,7 @@ module.exports = {
}
break;
case 'renameContent':
- jsonData.forEach(item => {
+ jsonData.forEach((item) => {
if (item.Title === title && item[contentTitle]) {
item[newTitle] = item[contentTitle];
delete item[contentTitle];
@@ -139,23 +143,24 @@ module.exports = {
});
break;
case 'renameTitle':
- jsonData.forEach(item => {
+ jsonData.forEach((item) => {
if (item.Title === oldTitle) {
item.Title = newTitle;
}
});
break;
case 'deleteContent':
- jsonData.forEach(item => {
+ jsonData.forEach((item) => {
if (item.Title === title) {
if (deleteContentTitle.includes('/')) {
const keys = deleteContentTitle.split('/');
- keys.reduce((obj, key, index) => {
+ keys.reduce(function deleteNestedContent(obj, key, index) {
if (index === keys.length - 1) {
delete obj[key];
} else {
return obj[key];
}
+ return obj;
}, item);
} else {
delete item[deleteContentTitle];
@@ -164,7 +169,7 @@ module.exports = {
});
break;
case 'deleteTitle':
- jsonData = jsonData.filter(item => item.Title !== title);
+ jsonData = jsonData.filter((item) => item.Title !== title);
break;
}
@@ -178,5 +183,5 @@ module.exports = {
this.callNextAction(cache);
},
- mod() {}
+ mod() {},
};
From a744bcbcf3a9145ceea7003ad20e5af8eb7420fe Mon Sep 17 00:00:00 2001
From: thekingofspace <37231416+thekingofspace@users.noreply.github.com>
Date: Tue, 4 Jun 2024 04:41:41 -0700
Subject: [PATCH 12/23] Added json random
---
actions/json_random_MOD.js | 99 ++++++++++++++++++++++++++++++++++++++
1 file changed, 99 insertions(+)
create mode 100644 actions/json_random_MOD.js
diff --git a/actions/json_random_MOD.js b/actions/json_random_MOD.js
new file mode 100644
index 00000000..38587f8e
--- /dev/null
+++ b/actions/json_random_MOD.js
@@ -0,0 +1,99 @@
+const fs = require('fs');
+const path = require('path');
+
+module.exports = {
+ name: 'Pick Random JSON Item',
+ section: 'File Stuff',
+ fields: ['filepath', 'title', 'storage', 'varName'],
+
+ subtitle(data) {
+ return `Pick random item from JSON file "${data.filepath}"`;
+ },
+
+ variableStorage(data, varType) {
+ if (parseInt(data.storage, 10) !== varType) return;
+ return [data.varName, 'Text'];
+ },
+
+ html() {
+ return `
+
+
+ File Path
+
+
+
+ Title
+
+
+
+
+
+
+ `;
+ },
+
+ init() {},
+
+ async action(cache) {
+ const data = cache.actions[cache.index];
+ let filepath = this.evalMessage(data.filepath, cache);
+ const title = this.evalMessage(data.title, cache);
+ const storage = parseInt(data.storage, 10);
+ const varName = this.evalMessage(data.varName, cache);
+
+ if (filepath.startsWith('./')) {
+ filepath = path.join(__dirname, '..', filepath.substring(2));
+ }
+
+ let jsonData;
+
+ try {
+ if (fs.existsSync(filepath)) {
+ const fileData = fs.readFileSync(filepath);
+ if (fileData.length === 0) {
+ console.warn('JSON file is empty.');
+ this.storeValue(undefined, storage, varName, cache);
+ return this.callNextAction(cache);
+ }
+ jsonData = JSON.parse(fileData);
+ } else {
+ throw new Error('File does not exist');
+ }
+ } catch (error) {
+ console.error(`Error reading JSON file: ${error}`);
+ this.storeValue(undefined, storage, varName, cache);
+ return this.callNextAction(cache);
+ }
+
+ let result;
+
+ try {
+ if (title) {
+ const titleData = jsonData.find((item) => item.Title === title);
+ if (!titleData) throw new Error('Title not found');
+
+ const keys = Object.keys(titleData).filter((key) => key !== 'Title');
+ if (keys.length === 0) throw new Error('No items found under specified title');
+
+ const randomKey = keys[Math.floor(Math.random() * keys.length)];
+ result = randomKey;
+ } else {
+ const items = jsonData.flatMap((item) => Object.keys(item).filter((key) => key !== 'Title'));
+ if (items.length === 0) throw new Error('No items found in JSON');
+
+ const randomItem = items[Math.floor(Math.random() * items.length)];
+ result = randomItem;
+ }
+ } catch (error) {
+ console.error(`Error accessing data: ${error}`);
+ this.storeValue(undefined, storage, varName, cache);
+ return this.callNextAction(cache);
+ }
+
+ this.storeValue(result, storage, varName, cache);
+ this.callNextAction(cache);
+ },
+
+ mod() {},
+};
From a3e1010a0a6c66fe5879808a899bc235bb30e993 Mon Sep 17 00:00:00 2001
From: thekingofspace <37231416+thekingofspace@users.noreply.github.com>
Date: Thu, 6 Jun 2024 05:08:46 -0700
Subject: [PATCH 13/23] **Changelog**
* Fixed json_random_MOD.js meta data
* Fixed json_read_MOD.js meta data
* Added json_check_MOD.json
---
actions/json_check_MOD.js | 127 +++++++++++++++++++++++++++++++++++++
actions/json_random_MOD.js | 6 ++
actions/json_read_MOD.js | 6 ++
3 files changed, 139 insertions(+)
create mode 100644 actions/json_check_MOD.js
diff --git a/actions/json_check_MOD.js b/actions/json_check_MOD.js
new file mode 100644
index 00000000..12f30159
--- /dev/null
+++ b/actions/json_check_MOD.js
@@ -0,0 +1,127 @@
+const fs = require('fs');
+const path = require('path');
+
+module.exports = {
+ name: 'Check JSON File',
+
+ section: 'File Stuff',
+
+ subtitle(data) {
+ return `Check JSON file "${data.filepath}"`;
+ },
+
+ meta: {
+ version: '2.1.7',
+ preciseCheck: false,
+ author: 'DBM Mods',
+ authorUrl: 'https://github.com/dbm-network/mods',
+ },
+
+ fields: ['filepath', 'checkType', 'title', 'contentTitle', 'branch'],
+
+ html() {
+ // Removed 'isEvent' and 'data'
+ return `
+
+ File Path
+
+
+
+ Check Type
+
+ Check if File is JSON Formatted
+ Check if Title Exists
+ Check if Content Exists Under Title
+
+
+
+ Title
+
+
+
+ Content Title
+
+
+
`;
+ },
+
+ init() {
+ const { glob, document } = this;
+
+ glob.onCheckTypeChanged = function handleCheckTypeChange(event) {
+ // Named function
+ const titleSection = document.getElementById('titleSection');
+ const contentTitleSection = document.getElementById('contentTitleSection');
+ switch (event.value) {
+ case '0':
+ titleSection.style.display = 'none';
+ contentTitleSection.style.display = 'none';
+ break;
+ case '1':
+ titleSection.style.display = null;
+ contentTitleSection.style.display = 'none';
+ break;
+ case '2':
+ titleSection.style.display = null;
+ contentTitleSection.style.display = null;
+ break;
+ }
+ };
+
+ glob.onCheckTypeChanged(document.getElementById('checkType'));
+ },
+
+ async action(cache) {
+ const data = cache.actions[cache.index];
+ let filepath = this.evalMessage(data.filepath, cache);
+ const checkType = parseInt(data.checkType, 10);
+ const title = this.evalMessage(data.title, cache);
+ const contentTitle = this.evalMessage(data.contentTitle, cache);
+
+ if (filepath.startsWith('./')) {
+ filepath = path.join(__dirname, '..', filepath.substring(2));
+ }
+
+ let jsonData;
+
+ try {
+ if (fs.existsSync(filepath)) {
+ const fileData = fs.readFileSync(filepath);
+ if (fileData.length === 0) throw new Error('JSON file is empty.');
+ jsonData = JSON.parse(fileData);
+ } else {
+ throw new Error('File does not exist');
+ }
+ } catch (error) {
+ console.error(`Error reading JSON file: ${error}`);
+ this.executeResults(false, data.branch, cache);
+ return;
+ }
+
+ let result = false;
+
+ try {
+ switch (checkType) {
+ case 0:
+ result = true;
+ break;
+ case 1: {
+ result = jsonData.some((item) => item.Title === title);
+ break;
+ }
+ case 2: {
+ const titleData = jsonData.find((item) => item.Title === title);
+ if (!titleData) throw new Error('Title not found');
+ result = contentTitle in titleData;
+ break;
+ }
+ }
+ } catch (error) {
+ console.error(`Error checking JSON data: ${error}`);
+ }
+
+ this.executeResults(result, data.branch, cache);
+ },
+
+ mod() {},
+};
diff --git a/actions/json_random_MOD.js b/actions/json_random_MOD.js
index 38587f8e..df6f63cd 100644
--- a/actions/json_random_MOD.js
+++ b/actions/json_random_MOD.js
@@ -5,6 +5,12 @@ module.exports = {
name: 'Pick Random JSON Item',
section: 'File Stuff',
fields: ['filepath', 'title', 'storage', 'varName'],
+ meta: {
+ version: '2.1.7',
+ preciseCheck: false,
+ author: 'DBM Mods',
+ authorUrl: 'https://github.com/dbm-network/mods',
+ },
subtitle(data) {
return `Pick random item from JSON file "${data.filepath}"`;
diff --git a/actions/json_read_MOD.js b/actions/json_read_MOD.js
index dd85f0f0..c0c21207 100644
--- a/actions/json_read_MOD.js
+++ b/actions/json_read_MOD.js
@@ -5,6 +5,12 @@ module.exports = {
name: 'Read JSON File',
section: 'File Stuff',
fields: ['filepath', 'title', 'contentTitle', 'storage', 'varName'],
+ meta: {
+ version: '2.1.7',
+ preciseCheck: false,
+ author: 'DBM Mods',
+ authorUrl: 'https://github.com/dbm-network/mods',
+ },
subtitle(data) {
return `Read JSON file "${data.filepath}"`;
From f4c7c7c415b8b725abe719450c9c087ed74ab377 Mon Sep 17 00:00:00 2001
From: thekingofspace <37231416+thekingofspace@users.noreply.github.com>
Date: Thu, 6 Jun 2024 06:38:22 -0700
Subject: [PATCH 14/23] **Changelog**
* Fixed json_random_MOD.js meta data
* Fixed json_read_MOD.js meta data
* Added json_check_MOD.json
---
actions/json_check_MOD.js | 39 +++++++++++++++++++++++++--------------
1 file changed, 25 insertions(+), 14 deletions(-)
diff --git a/actions/json_check_MOD.js b/actions/json_check_MOD.js
index 12f30159..634b5690 100644
--- a/actions/json_check_MOD.js
+++ b/actions/json_check_MOD.js
@@ -12,15 +12,15 @@ module.exports = {
meta: {
version: '2.1.7',
- preciseCheck: false,
- author: 'DBM Mods',
- authorUrl: 'https://github.com/dbm-network/mods',
+ preciseCheck: true,
+ author: 'ChatGPT',
+ authorUrl: null,
+ downloadUrl: null
},
fields: ['filepath', 'checkType', 'title', 'contentTitle', 'branch'],
- html() {
- // Removed 'isEvent' and 'data'
+ html(isEvent, data) {
return `
File Path
@@ -34,11 +34,11 @@ module.exports = {
Check if Content Exists Under Title
-
+
Title
-
+
Content Title
@@ -48,8 +48,7 @@ module.exports = {
init() {
const { glob, document } = this;
- glob.onCheckTypeChanged = function handleCheckTypeChange(event) {
- // Named function
+ glob.onCheckTypeChanged = function (event) {
const titleSection = document.getElementById('titleSection');
const contentTitleSection = document.getElementById('contentTitleSection');
switch (event.value) {
@@ -105,16 +104,28 @@ module.exports = {
case 0:
result = true;
break;
- case 1: {
+ case 1:
result = jsonData.some((item) => item.Title === title);
break;
- }
- case 2: {
+ case 2:
const titleData = jsonData.find((item) => item.Title === title);
if (!titleData) throw new Error('Title not found');
- result = contentTitle in titleData;
+
+ if (contentTitle.includes('/')) {
+ const contentKeys = contentTitle.split('/');
+ let nestedData = titleData;
+ for (const key of contentKeys) {
+ if (nestedData[key] !== undefined) {
+ nestedData = nestedData[key];
+ } else {
+ throw new Error('Nested content title not found');
+ }
+ }
+ result = true;
+ } else {
+ result = contentTitle in titleData;
+ }
break;
- }
}
} catch (error) {
console.error(`Error checking JSON data: ${error}`);
From fc97572f009dcd030a313893fbb43cda19d6ad20 Mon Sep 17 00:00:00 2001
From: thekingofspace <37231416+thekingofspace@users.noreply.github.com>
Date: Thu, 6 Jun 2024 06:42:16 -0700
Subject: [PATCH 15/23] **Changelog**
* Fixed json_random_MOD.js meta data
* Fixed json_read_MOD.js meta data
* Added json_check_MOD.json
---
actions/json_check_MOD.js | 17 +++++++++--------
actions/json_random_MOD.js | 8 ++++----
actions/json_read_MOD.js | 4 ++--
3 files changed, 15 insertions(+), 14 deletions(-)
diff --git a/actions/json_check_MOD.js b/actions/json_check_MOD.js
index 634b5690..846324c7 100644
--- a/actions/json_check_MOD.js
+++ b/actions/json_check_MOD.js
@@ -12,15 +12,14 @@ module.exports = {
meta: {
version: '2.1.7',
- preciseCheck: true,
- author: 'ChatGPT',
- authorUrl: null,
- downloadUrl: null
+ preciseCheck: false,
+ author: 'DBM Mods',
+ authorUrl: 'https://github.com/dbm-network/mods',
},
fields: ['filepath', 'checkType', 'title', 'contentTitle', 'branch'],
- html(isEvent, data) {
+ html(_, data) {
return `
File Path
@@ -48,7 +47,7 @@ module.exports = {
init() {
const { glob, document } = this;
- glob.onCheckTypeChanged = function (event) {
+ function onCheckTypeChanged(event) {
const titleSection = document.getElementById('titleSection');
const contentTitleSection = document.getElementById('contentTitleSection');
switch (event.value) {
@@ -65,9 +64,11 @@ module.exports = {
contentTitleSection.style.display = null;
break;
}
- };
+ }
+
+ glob.onCheckTypeChanged = onCheckTypeChanged;
- glob.onCheckTypeChanged(document.getElementById('checkType'));
+ onCheckTypeChanged(document.getElementById('checkType'));
},
async action(cache) {
diff --git a/actions/json_random_MOD.js b/actions/json_random_MOD.js
index cd5bc059..df6f63cd 100644
--- a/actions/json_random_MOD.js
+++ b/actions/json_random_MOD.js
@@ -76,16 +76,16 @@ module.exports = {
try {
if (title) {
- const titleData = jsonData.find(item => item.Title === title);
+ const titleData = jsonData.find((item) => item.Title === title);
if (!titleData) throw new Error('Title not found');
- const keys = Object.keys(titleData).filter(key => key !== 'Title');
+ const keys = Object.keys(titleData).filter((key) => key !== 'Title');
if (keys.length === 0) throw new Error('No items found under specified title');
const randomKey = keys[Math.floor(Math.random() * keys.length)];
result = randomKey;
} else {
- const items = jsonData.flatMap(item => Object.keys(item).filter(key => key !== 'Title'));
+ const items = jsonData.flatMap((item) => Object.keys(item).filter((key) => key !== 'Title'));
if (items.length === 0) throw new Error('No items found in JSON');
const randomItem = items[Math.floor(Math.random() * items.length)];
@@ -101,5 +101,5 @@ module.exports = {
this.callNextAction(cache);
},
- mod() {}
+ mod() {},
};
diff --git a/actions/json_read_MOD.js b/actions/json_read_MOD.js
index 4668b981..c0c21207 100644
--- a/actions/json_read_MOD.js
+++ b/actions/json_read_MOD.js
@@ -79,7 +79,7 @@ module.exports = {
let result;
try {
- const titleData = jsonData.find(item => item.Title === title);
+ const titleData = jsonData.find((item) => item.Title === title);
if (!titleData) throw new Error('Title not found');
if (contentTitle.includes('/')) {
@@ -104,5 +104,5 @@ module.exports = {
this.callNextAction(cache);
},
- mod() {}
+ mod() {},
};
From 2c24c47293683c6526d55f399b2e9600d37c94bd Mon Sep 17 00:00:00 2001
From: thekingofspace <37231416+thekingofspace@users.noreply.github.com>
Date: Thu, 6 Jun 2024 06:49:16 -0700
Subject: [PATCH 16/23] **Changelog**
* Fixed json_random_MOD.js meta data
* Fixed json_read_MOD.js meta data
* Added json_check_MOD.json
---
actions/json_check_MOD.js | 38 +++++++++++++-------------------------
1 file changed, 13 insertions(+), 25 deletions(-)
diff --git a/actions/json_check_MOD.js b/actions/json_check_MOD.js
index 846324c7..12f30159 100644
--- a/actions/json_check_MOD.js
+++ b/actions/json_check_MOD.js
@@ -19,7 +19,8 @@ module.exports = {
fields: ['filepath', 'checkType', 'title', 'contentTitle', 'branch'],
- html(_, data) {
+ html() {
+ // Removed 'isEvent' and 'data'
return `
File Path
@@ -33,11 +34,11 @@ module.exports = {
Check if Content Exists Under Title
-
+
Title
-
+
Content Title
@@ -47,7 +48,8 @@ module.exports = {
init() {
const { glob, document } = this;
- function onCheckTypeChanged(event) {
+ glob.onCheckTypeChanged = function handleCheckTypeChange(event) {
+ // Named function
const titleSection = document.getElementById('titleSection');
const contentTitleSection = document.getElementById('contentTitleSection');
switch (event.value) {
@@ -64,11 +66,9 @@ module.exports = {
contentTitleSection.style.display = null;
break;
}
- }
-
- glob.onCheckTypeChanged = onCheckTypeChanged;
+ };
- onCheckTypeChanged(document.getElementById('checkType'));
+ glob.onCheckTypeChanged(document.getElementById('checkType'));
},
async action(cache) {
@@ -105,28 +105,16 @@ module.exports = {
case 0:
result = true;
break;
- case 1:
+ case 1: {
result = jsonData.some((item) => item.Title === title);
break;
- case 2:
+ }
+ case 2: {
const titleData = jsonData.find((item) => item.Title === title);
if (!titleData) throw new Error('Title not found');
-
- if (contentTitle.includes('/')) {
- const contentKeys = contentTitle.split('/');
- let nestedData = titleData;
- for (const key of contentKeys) {
- if (nestedData[key] !== undefined) {
- nestedData = nestedData[key];
- } else {
- throw new Error('Nested content title not found');
- }
- }
- result = true;
- } else {
- result = contentTitle in titleData;
- }
+ result = contentTitle in titleData;
break;
+ }
}
} catch (error) {
console.error(`Error checking JSON data: ${error}`);
From 3bb0c99bcaab2421894d5f328af21eb5b772b6cc Mon Sep 17 00:00:00 2001
From: thekingofspace <37231416+thekingofspace@users.noreply.github.com>
Date: Thu, 6 Jun 2024 06:57:09 -0700
Subject: [PATCH 17/23] **Changelog**
* added nested check
---
actions/json_check_MOD.js | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/actions/json_check_MOD.js b/actions/json_check_MOD.js
index 12f30159..63ee11a4 100644
--- a/actions/json_check_MOD.js
+++ b/actions/json_check_MOD.js
@@ -112,7 +112,15 @@ module.exports = {
case 2: {
const titleData = jsonData.find((item) => item.Title === title);
if (!titleData) throw new Error('Title not found');
- result = contentTitle in titleData;
+ const nestedTitles = contentTitle.split('/');
+ let nestedData = titleData;
+ for (const nestedTitle of nestedTitles) {
+ if (!(nestedTitle in nestedData)) {
+ throw new Error('Content title not found');
+ }
+ nestedData = nestedData[nestedTitle];
+ }
+ result = true;
break;
}
}
From a471aa6530d7cd1339b77add9db1f7fe3ec681c0 Mon Sep 17 00:00:00 2001
From: thekingofspace <37231416+thekingofspace@users.noreply.github.com>
Date: Thu, 6 Jun 2024 07:42:50 -0700
Subject: [PATCH 18/23] **Changelog**
* removed error handler
---
actions/json_check_MOD.js | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/actions/json_check_MOD.js b/actions/json_check_MOD.js
index 63ee11a4..8e4b70d2 100644
--- a/actions/json_check_MOD.js
+++ b/actions/json_check_MOD.js
@@ -20,7 +20,6 @@ module.exports = {
fields: ['filepath', 'checkType', 'title', 'contentTitle', 'branch'],
html() {
- // Removed 'isEvent' and 'data'
return `
File Path
@@ -49,7 +48,6 @@ module.exports = {
const { glob, document } = this;
glob.onCheckTypeChanged = function handleCheckTypeChange(event) {
- // Named function
const titleSection = document.getElementById('titleSection');
const contentTitleSection = document.getElementById('contentTitleSection');
switch (event.value) {
@@ -84,16 +82,18 @@ module.exports = {
let jsonData;
- try {
- if (fs.existsSync(filepath)) {
+ if (fs.existsSync(filepath)) {
+ try {
const fileData = fs.readFileSync(filepath);
if (fileData.length === 0) throw new Error('JSON file is empty.');
jsonData = JSON.parse(fileData);
- } else {
- throw new Error('File does not exist');
+ } catch (error) {
+ console.error(`Error reading JSON file: ${error}`);
+ this.executeResults(false, data.branch, cache);
+ return;
}
- } catch (error) {
- console.error(`Error reading JSON file: ${error}`);
+ } else {
+ console.error('File does not exist');
this.executeResults(false, data.branch, cache);
return;
}
From 60cf3afdaf729a2283932511d86b973eac2891b5 Mon Sep 17 00:00:00 2001
From: thekingofspace <37231416+thekingofspace@users.noreply.github.com>
Date: Thu, 6 Jun 2024 07:44:29 -0700
Subject: [PATCH 19/23] **Changelog**
* removed error handler
---
actions/json_check_MOD.js | 1 -
1 file changed, 1 deletion(-)
diff --git a/actions/json_check_MOD.js b/actions/json_check_MOD.js
index 8e4b70d2..bd2cad8d 100644
--- a/actions/json_check_MOD.js
+++ b/actions/json_check_MOD.js
@@ -93,7 +93,6 @@ module.exports = {
return;
}
} else {
- console.error('File does not exist');
this.executeResults(false, data.branch, cache);
return;
}
From ead3a35e2521827f298b266ee508d34c5a499d62 Mon Sep 17 00:00:00 2001
From: thekingofspace <37231416+thekingofspace@users.noreply.github.com>
Date: Thu, 6 Jun 2024 16:15:43 -0700
Subject: [PATCH 20/23] **Changelog**
* Updated all json actions to make them more clear
---
actions/json_check_MOD.js | 4 ++--
actions/json_random_MOD.js | 2 +-
actions/json_read_MOD.js | 4 ++--
actions/json_write_MOD.js | 4 ++--
4 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/actions/json_check_MOD.js b/actions/json_check_MOD.js
index bd2cad8d..da2b2fa1 100644
--- a/actions/json_check_MOD.js
+++ b/actions/json_check_MOD.js
@@ -23,7 +23,7 @@ module.exports = {
return `
File Path
-
+
Check Type
@@ -39,7 +39,7 @@ module.exports = {
Content Title
-
+
`;
},
diff --git a/actions/json_random_MOD.js b/actions/json_random_MOD.js
index df6f63cd..1e8ca918 100644
--- a/actions/json_random_MOD.js
+++ b/actions/json_random_MOD.js
@@ -26,7 +26,7 @@ module.exports = {
File Path
-
+
Title
diff --git a/actions/json_read_MOD.js b/actions/json_read_MOD.js
index c0c21207..49c00861 100644
--- a/actions/json_read_MOD.js
+++ b/actions/json_read_MOD.js
@@ -26,7 +26,7 @@ module.exports = {
File Path
-
+
Title
@@ -34,7 +34,7 @@ module.exports = {
Content Title
-
+
diff --git a/actions/json_write_MOD.js b/actions/json_write_MOD.js
index 682462b5..a4905337 100644
--- a/actions/json_write_MOD.js
+++ b/actions/json_write_MOD.js
@@ -21,7 +21,7 @@ module.exports = {
File Path
-
+
Action
@@ -40,7 +40,7 @@ module.exports = {
Content Title
-
+
Content Text
From b0d36204ffded4f85a58316a6a809e8de0b3475d Mon Sep 17 00:00:00 2001
From: thekingofspace <37231416+thekingofspace@users.noreply.github.com>
Date: Thu, 6 Jun 2024 16:30:33 -0700
Subject: [PATCH 21/23] **Changelog**
* Created a mod version of get_list_length_MOD.js this one only returns a number for the list length and not a list like 1,2,3. this also makes it so if the list is empty or is not a list it will be undefined
---
actions/get_list_length_MOD.js | 62 ++++++++++++++++++++++++++++++++++
1 file changed, 62 insertions(+)
create mode 100644 actions/get_list_length_MOD.js
diff --git a/actions/get_list_length_MOD.js b/actions/get_list_length_MOD.js
new file mode 100644
index 00000000..6df8f81e
--- /dev/null
+++ b/actions/get_list_length_MOD.js
@@ -0,0 +1,62 @@
+module.exports = {
+ name: "Get List Length",
+ section: "Lists and Loops",
+
+ subtitle(data, presets) {
+ const list = presets.lists;
+ return `Get ${list[parseInt(data.list, 10)]} Length`;
+ },
+
+ variableStorage(data, varType) {
+ const type = parseInt(data.storage, 10);
+ if (type !== varType) return;
+ return [data.varName2, "Number"];
+ },
+
+ meta: { version: "2.1.7", preciseCheck: true, author: null, authorUrl: null, downloadUrl: null },
+
+ fields: ["list", "varName", "storage", "varName2"],
+
+ html(isEvent, data) {
+ return `
+
+
+ Source List:
+
+ ${data.lists[isEvent ? 1 : 0]}
+
+
+
+ Variable Name:
+
+
+
+
+
+
+
`;
+ },
+
+ init() {
+ const { glob, document } = this;
+ glob.listChange(document.getElementById("list"), "varNameContainer");
+ },
+
+ async action(cache) {
+ const data = cache.actions[cache.index];
+ const list = await this.getListFromData(data.list, data.varName, cache);
+ const varName2 = this.evalMessage(data.varName2, cache);
+ const storage2 = parseInt(data.storage, 10);
+
+ if (Array.isArray(list)) {
+ const length = list.length > 0 ? list.length : "undefined";
+ this.storeValue(length, storage2, varName2, cache);
+ } else {
+ this.storeValue("undefined", storage2, varName2, cache);
+ }
+
+ this.callNextAction(cache);
+ },
+
+ mod() {},
+};
From 2756ffe93ede0f62daec2e9c004dd1f0c7aa63af Mon Sep 17 00:00:00 2001
From: thekingofspace <37231416+thekingofspace@users.noreply.github.com>
Date: Thu, 6 Jun 2024 16:31:47 -0700
Subject: [PATCH 22/23] **Changelog**
* Created a mod version of get_list_length_MOD.js this one only returns a number for the list length and not a list like 1,2,3. this also makes it so if the list is empty or is not a list it will be undefined
---
actions/get_list_length_MOD.js | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/actions/get_list_length_MOD.js b/actions/get_list_length_MOD.js
index 6df8f81e..d27bd679 100644
--- a/actions/get_list_length_MOD.js
+++ b/actions/get_list_length_MOD.js
@@ -1,6 +1,6 @@
module.exports = {
- name: "Get List Length",
- section: "Lists and Loops",
+ name: 'Get List Length',
+ section: 'Lists and Loops',
subtitle(data, presets) {
const list = presets.lists;
@@ -10,12 +10,12 @@ module.exports = {
variableStorage(data, varType) {
const type = parseInt(data.storage, 10);
if (type !== varType) return;
- return [data.varName2, "Number"];
+ return [data.varName2, 'Number'];
},
- meta: { version: "2.1.7", preciseCheck: true, author: null, authorUrl: null, downloadUrl: null },
+ meta: { version: '2.1.7', preciseCheck: true, author: null, authorUrl: null, downloadUrl: null },
- fields: ["list", "varName", "storage", "varName2"],
+ fields: ['list', 'varName', 'storage', 'varName2'],
html(isEvent, data) {
return `
@@ -39,7 +39,7 @@ module.exports = {
init() {
const { glob, document } = this;
- glob.listChange(document.getElementById("list"), "varNameContainer");
+ glob.listChange(document.getElementById('list'), 'varNameContainer');
},
async action(cache) {
@@ -49,10 +49,10 @@ module.exports = {
const storage2 = parseInt(data.storage, 10);
if (Array.isArray(list)) {
- const length = list.length > 0 ? list.length : "undefined";
+ const length = list.length > 0 ? list.length : 'undefined';
this.storeValue(length, storage2, varName2, cache);
} else {
- this.storeValue("undefined", storage2, varName2, cache);
+ this.storeValue('undefined', storage2, varName2, cache);
}
this.callNextAction(cache);
From 48f73f3d5097d43554a1ca175cd4fab8ebbbc778 Mon Sep 17 00:00:00 2001
From: thekingofspace <37231416+thekingofspace@users.noreply.github.com>
Date: Thu, 6 Jun 2024 16:33:09 -0700
Subject: [PATCH 23/23] Fixed Title
---
actions/get_list_length_MOD.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/actions/get_list_length_MOD.js b/actions/get_list_length_MOD.js
index d27bd679..13b1e0c7 100644
--- a/actions/get_list_length_MOD.js
+++ b/actions/get_list_length_MOD.js
@@ -1,5 +1,5 @@
module.exports = {
- name: 'Get List Length',
+ name: 'Get List Length MOD',
section: 'Lists and Loops',
subtitle(data, presets) {