check if desc exists

This commit is contained in:
sq 2024-09-22 19:37:11 +08:00 committed by GitHub
parent 15aa16af65
commit d7e5eb3994
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 12 additions and 4 deletions

View File

@ -2,9 +2,13 @@
for (let elementName in elements) { for (let elementName in elements) {
let element = elements[elementName]; let element = elements[elementName];
if (element.desc && typeof element.desc === 'string' && element.desc.trim() !== '') {
if (!element.desc.includes("This Element is from")) { if (!element.desc.includes("This Element is from")) {
element.desc += "\nThis Element is from Sandboxels (Vanilla)"; element.desc += "\nThis Element is from Sandboxels (Vanilla)";
} }
} else {
element.desc = "This Element is from Sandboxels (Vanilla)";
}
} }
runAfterLoad(function() { runAfterLoad(function() {
@ -19,9 +23,13 @@ runAfterLoad(function() {
Object.keys(elements).forEach(function(elementName) { Object.keys(elements).forEach(function(elementName) {
let element = elements[elementName]; let element = elements[elementName];
if (element.desc && typeof element.desc === 'string' && element.desc.trim() !== '') {
if (!element.desc.includes("This Element is from")) { if (!element.desc.includes("This Element is from")) {
element.desc += `\nThis Element is from ${mod}`; element.desc += `\nThis Element is from ${mod}`;
} }
} else {
element.desc = `This Element is from ${mod}`;
}
}); });
}) })
.catch(error => console.error('Error fetching the mod file: ', error)); .catch(error => console.error('Error fetching the mod file: ', error));