Two sheetworker questions. I have code that does the same thing for multiple different attributes, for example: on("sheet:opened change:str_base change:str_race change:str_magic change:str_misc change:str_temp", function() {
getAttrs(["str", "str_base", "str_race", "str_magic", "str_misc", "str_temp"], function(values) {
setAttrs({
str: ( (parseInt(values["str_base"],10) || 10) + (parseInt(values["str_race"],10) || 0) + (parseInt(values["str_magic"],10) || 0)
+ (parseInt(values["str_misc"],10) || 0) + (parseInt(values["str_temp"],10) || 0) )
});
});
}); I have a separate block of code like the above for each ability score (Str, Dex, Con, etc.). How do I make this a generic function that will work for each ability? I thought I had seen something like this in the forums here, but I cannot find it now. Secondly, a "best practices" type of question. Say I have code like the above that watches a number of attributes for changes, and I have another block of code that executes only when one of those attributes changes. For example, I have another sheetworker that only executes when str_base changes. Is it more efficient/better coding to combine them into one event, or should I keep them separate ones? Or does it matter at the scales character sheets work at? Thanks in advance for any insight/advice!