Those are some good points, GiGs. I'd assumed Chad was enforcing strict values for stats. Chad, the single sheet worker is advice GiGs provide me in the past, too. I think it's sound advice and can provide optimization, depending on how complex your sheet is perhaps. I created an event builder that allows me to easily add and review what events I'm using (helps with dev and troubleshooting)...something like this...note, I've not tested it but looks right ;)... const stats = [
'agility',
'body',
'intelligence',
'willpower',
];
const events = `change:${stats.join(" change:")} sheet:opened`;
on(events, function (eventInfo) {
const get_stats = eventInfo.triggerName === 'sheet:opened' ? stats : [`${eventInfo.sourceAttribute}`];
getAttrs(get_stats, function (values) {
const set_attrs = {};
const stat_mods = get_stats.map(v => {
const attribute = +values[v] || 0;
return attribute <= 0 ? -2 : attribute;
});
for (let i = 0, n = get_stats.length; i < n; i++) { set_attrs[get_stats[i] + 'Mod'] = stat_mods[i]; }
setAttrs(set_attrs,{slient:true});
});
}); If you wanted to use something like this with buttons or removed repeating rows, you'd just replace 'change' in const events with 'clicked' or 'remove', respectively. If you're looking to include those button or removed events in the same sheetworker, you can do that too but I'd recommend making separate event builders for each, and then string them together. Like this... let events = '';
// Input names
const input_events = [
'body',
'intellect',
];
events = `change:${input_events.join(" change:")}`;
// Button names
const button_events = [
'attack',
'spell',
];
events += ` clicked:${button_events.join(" clicked:")}`;
// Repeating sections
const remove_events = [
'repeating_spell',
'repeating_weapon',
];
events += ` remove:${remove_events.join(" remove:")}`; GiGs, I've seen you use the '+' in front of a variable in the past...assuming a numerical value... const attribute = +values[stat] || 0; ... but I'm not familiar with it. Looks like it's a good replacement for parseInt(). What are your thoughts? Are there caveats with it or does it really just replace parseInt()?