I'm refactoring my code to be more efficient (thanks again for the perspective Chris D and Scott C!) but I'm running into an issue that can be summed up in the immortal words of Jacobim Mugatu, "I feel like I'm taking crazy pills!" I found this post for guidance, here , where Scott C suggests building an object variable to be used in a setAttrs() function call. However, when I do this the attribute does not get set. I believe I've gone through all permutations but to no avail. If I pipe the object into the console I can see that the object is correctly constructed: {repeating_fluxattributes_-lr0cvx67yq2c3k7xf50_fluxenable: 0} Any suggestions are welcome! Below is my code, the code that is failing is in bold. // *** Main Script *** //
if (eventInfo.sourceType == "sheetworker") return;
var repeating_source = eventInfo.sourceAttribute.substring(0, eventInfo.sourceAttribute.lastIndexOf('_')),
sourceattr = eventInfo.sourceAttribute.split('_'),
isFluxAttr = (sourceattr[1] == "fluxattributes" || sourceattr[1] == "itemfluxattributes") ? 1:0,
activate = parseInt(eventInfo.newValue),
getAttrsString = [repeating_source+"_attribute","CONST_SHOW_DEBUGGING_MESSAGES"];
if (isFluxAttr) getAttrsString.push(repeating_source+"_fluxenable");
getAttrs(getAttrsString, function(value) {
var debug = parseInt(value.CONST_SHOW_DEBUGGING_MESSAGES),
attribute = value[repeating_source+"_attribute"],
fluxenable = parseInt(value[repeating_source+"_fluxenable"]);
if (isFluxAttr && !fluxenable && activate) {
var equipstate = {};
equipstate[repeating_source+"_fluxenable"] = 0;
setAttrs(equipstate);
return;
}
}); My ultimate goal here is to have a script run through all the attributes that will need to get set, build an object with those attributes and values, and then call settAttrs() with this object to write all the attributes in one call rather than 20-30+ individual calls. This is just my first iteration, and failing miserably. :'(