I can't find line where DNA is called, before I added some lines of code the code was executing just fine. Now the error is running and won't let me quit the execution.
Here is the line where Dna is created on index.js. I see it calls for variable races and race but I don't know how races makes the dna
const createDna = (_races, _race) => {
let randNum = [];
_races[_race].layers.forEach((layer) => {
let randElementNum = Math.floor(Math.random() * 100) + 1;
let num = 0;
layer.elements.forEach((element) => {
if (randElementNum >= 100 - element.weight) {
num = element.id;
}
});
randNum.push(num);
});
return randNum;
};
Then, in config.js the variable _races appears here. I don't know if what follows from the rest of the code is important for your answer, but this is what I've got so far...
const fs = require("fs");
const width = 708;
const height = 1080;
const dir = __dirname;
const description = "This is an NFT made by the coolest generative code.";
const baseImageUri = "https://hashlips/nft";
const startEditionFrom = 1;
const endEditionAt = 34;
const editionSize = 34;
const raceWeights = [
{
value: "skull",
from: 1,
to: editionSize,
},
];
const races = {
skull: {
name: "skull",
layers: [
{
name: "Background",
elements: [
{
id: 0,
name: "Light pink",
path: `${dir}/1-background/PRDE_0008s_0000_Capa-5.png`,
weight: 100,
},
]
// etc...
]
}
When I break the execution, the process exits with this message
Uncaught TypeError: Cannot read properties of undefined (reading 'layers')
and it only produces 24 layers of pngs out of the total 34 I asked it to produce. What's wrong?