
I am trying to condense a long section of code, but the full code below does not work. Other sheetworkers stop working too, so I think it's a syntax error. Probably something with the template literals I am using without being completely versed in their usage.
const spellclasses = ["spellclass01", "spellclass02"];I know that the problem is somewhere in the bolded code above. When I remove that section and put in a console.log(); command, it shows in the console when one of the right attributes from spellcountEvents is changed.
const spelllevels = ["00", "01", "02", "03", "04", "05", "06", "07", "08", "09"];
const spellcountAttrs = (_.map(spellclasses,(c)=>`${c}_castertype`) + ',' + _.flatten(_.map(spellclasses,(c)=>_.map(spelllevels, (s)=>`${c}_spells${s}_count_base`))) +
',' + _.flatten(_.map(spellclasses,(c)=>_.map(spelllevels, (s)=>`${c}_spells${s}_count_ability`))) + ',' + _.flatten(_.map(spellclasses,(c)=>_.map(spelllevels, (s)=>`${c}_spells${s}_count_extra`))));
const spellcountEvents = _.map((spellcountAttrs.split(",")),(a)=>`change:${a}`);
on(`${spellcountEvents.join(' ')}`, function() {
getAttrs(spellcountAttrs, function (value) =>{
let update = {};
_.each((spellclasses, c)=>{
_.each((spelllevels, s)=>{
if (value[`${c}_spells${s}_count_base`] == "-") {
update[`${c}_spells${s}_count_max`] = 0;
} else {
update[`${c}_spells${s}_count_max`] = (parseInt(value[`${c}_spells${s}_count_base`],10) || 0) +
(parseInt(value[`${c}_spells${s}_count_ability`],10) || 0) + (parseInt(value[`${c}_spells${s}_count_extra`],10) || 0);
};
});
});
setAttrs(update);
});
});
Thanks in advance for any assistance/advice/pointing out of errors.