My code structure currently looks like this: Sheet.Calculate.ClassLevelsCallback = function(attributes,classLevelIdsArray){
for(var i = 0; i < classLevelIdsArray.length; i++){
-- Do code for class levels in order;
}
};
Sheet.Calculate.ClassLevels = function(){
getAttributeArrayForRepeatingSection("classlevels",["clName","clHPRoll","clPSPRoll","clCalculatedHPRoll","clCalculatedHPRoll"],Sheet.Calculate.ClassLevelsCallback);
};
on("change:repeating_classlevels",function(eventInfo){
Sheet.Calculate.ClassLevels();
});
function getAttributeArrayForRepeatingSection(sectionName,propertyArray,callback){
getSectionIDsOrdered(sectionName,function(idArray){
var attributeArray = [];
for(var i = 0; i < idarray.length; i++){
var id = idarray[i];
for(var j = 0; j < propertyArray.length;j++){
attributeArray.push(`repeating_${sectionName}_${id}_${propertyArray[j]}`);
}
}
getAttrs(attributeArray,callback);
});
};
function getSectionIDsOrdered(sectionName, callback, argsArray) {
'use strict';
getAttrs([`_reporder_${sectionName}`], function (v) {
getSectionIDs(sectionName, function (idArray) {
let reporderArray = v[`_reporder_${sectionName}`] ? v[`_reporder_${sectionName}`].toLowerCase().split(',') : [],
ids = [...new Set(reporderArray.filter(x => idArray.includes(x)).concat(idArray))];
callback(ids);
});
});
};
In getAttributeArrayForRepeatingSection(...) I have an idarray that comes in as a callback arg from getSectionIDsOrdered (found here ) and I need to pass that into the callback for the getAttrs(...,callback) function. There is certain logic that is only implemented on the first class level (such as getting max HP at level 1), and other house-rule logic that is only implemented based on the order in which class levels are taken. Anyone know how to handle this?