fix not detecting other mods

This commit is contained in:
sq 2024-09-22 19:50:42 +08:00 committed by GitHub
parent 657fb6bb3b
commit 0f65f98c0a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 27 additions and 19 deletions

View File

@ -11,30 +11,38 @@ for (let elementName in elements) {
}
}
let modDescriptions = {};
runAfterLoad(function() {
let modDescriptions = {};
let fetchPromises = enabledMods.map(mod => {
return fetch(mod)
.then(response => response.text())
.then(data => {
console.log(`Loaded mod: ${mod}`);
modDescriptions[mod] = data;
})
.catch(error => console.error('Error fetching the mod file: ', error));
});
let fetchPromises = enabledMods.map(mod => {
return fetch(mod)
.then(response => response.text())
.then(data => {
console.log(`Loaded mod: ${mod}`);
modDescriptions[mod] = data;
})
.catch(error => console.error('Error fetching the mod file: ', error));
});
Promise.all(fetchPromises).then(() => {
Object.keys(elements).forEach(function(elementName) {
let element = elements[elementName];
for (let mod of enabledMods) {
Promise.all(fetchPromises).then(() => {
Object.keys(elements).forEach(function(elementName) {
let element = elements[elementName];
let elementMod = "Sandboxels (Vanilla)";
for (let mod of enabledMods) {
if (modDescriptions[mod].includes(elementName)) {
elementMod = mod;
break;
}
}
if (element.desc && typeof element.desc === 'string' && element.desc.trim() !== '') {
if (!element.desc.includes("This Element is from")) {
element.desc += `\nThis Element is from ${mod}`;
element.desc += `\nThis Element is from ${elementMod}`;
}
} else {
element.desc = `This Element is from ${mod}`;
element.desc = `This Element is from ${elementMod}`;
}
}
});
});
});
});