javascript to place two squares of each element next to each other and record the results
javascript to place two squares of each element next to each other and record the results
(index):9263 Uncaught TypeError: Cannot read properties of undefined (reading 'r')
at createElementButton ((index):9263:34)
at checkUnlock ((index):9309:21)
at alchemySolver.js:34:3
at Array.forEach (<anonymous>)
at alchemySolver.js:32:18unlockedElements.forEach(element=>{
if(elements[element]===undefined) return;
checkUnlock(element);
});[
"oxygen",
"dirt",
"fire",
"water",
"alchemymod",
"foam",
"ozone",
"liquid_oxygen",
"permafrost",
"smoke",
"plasma",
"mud",
"ice",
"steam",
"mudstone",
"pyrocumulus",
"cloud",
"smog",
"molten_dirt",
"rain_cloud",
"snow_cloud",
"hail_cloud"
]if(elements[element]===undefined) return; if (elements[element].color instanceof Array) {
button.style.backgroundImage = "linear-gradient(to bottom right, "+elements[element].color.join(", ")+")";
// choose the middlemost item in array
var colorObject = elements[element].colorObject[Math.floor(elements[element].colorObject.length/2)]; // <-- HERE
if ((colorObject.r+colorObject.g+colorObject.b)/3 > 200) {
button.className += " bright"
}
}
else {
button.style.background = elements[element].color;
var colorObject = elements[element].colorObject;
if ((colorObject.r+colorObject.g+colorObject.b)/3 > 200) {
button.className += " bright"
}
}let unlockedElements = Object.keys(settings.unlocked);
let totalIterations = 100;
let iterations = 0;
function iteration() {
if(totalIterations<iterations++) return;
// Super-secret stuff...
iteration();
}
iteration();
unlockedElements.forEach(element=>{
if(elements[element]===undefined) return;
checkUnlock(element);
});