
I have a series of basic characteristics (strength, agility, etc) in a point-buy character system where the stat values are set as the total of points directly spent on the stats themselves plus any adjustments from a repeating section of powers. The meat of the html is a repeating section (removing some formatting for clarity and using just Endurance as an example): < input type = "number" name = "attr_en_adj" title = "en_adj" /> ... and the main stat section is: < input type = "number" name = "attr_endurance_cost" title = "endurance_cost" value = "0" /> < input type = "text" name = "attr_endurance_score" title = "endurance_score" disabled value = "(@{endurance_cost}+@{en_adj_total})" /> < input type = "text" name = "attr_endurance_save" title = "endurance_save" disabled value = "@{hid_en_save}" />< input type = "hidden" name = "attr_hid_en_save" title = "hid_en_save" > An sheet worker fires when the repeating section is changed (there will be one added to the change on the _cost fields as well after I get the logic working) to get the _adj-total value for the _score calculation. on('change:repeating_powers remove:repeating_powers', function() { repeatingSum("en_adj_total", "powers", "en_adj"); }); This is all working fine; a change to any of the adjustment fields in the repeater will correctly update the appropriate _score field values. From these base scores a number of other stats get calculated, many of them by doing lookups against a table containing stat ranges and related values - the _save field above being an example. After the repeatingSum above I've added a call to this function: function updateFromBCs() { getAttrs([ "strength_score", "endurance_score", "agility_score", "intelligence_score", "cool_score" ], function(v) { let statTable = [ {min: 0, max: 0, carry: 8, hth_init: 'd2-1', save: 6, hits_st: -3, hits_en: -5, hits_ag: -2, hits_cl: -1, heal: .2}, {min: 1, max: 1, carry: 10, hth_init: 'd2-1', save: 7, hits_st: -3, hits_en: -5, hits_ag: -2, hits_cl: -1, heal: .3}, {min: 2, max: 2, carry: 12, hth_init: 'd2-1', save: 7, hits_st: -3, hits_en: -5, hits_ag: -2, hits_cl: -1, heal: .3}, <etc>.... {min: 96, max: 98, carry: 32212254720, hth_init: '3d10+2d12', save: 25, hits_st: 54, hits_en: 69, hits_ag: 35, hits_cl: 18, heal: 18.1} ]; let stResult = statTable.filter(tableRow => (tableRow.min <= v.strength_score && tableRow.max >= v.strength_score)); let enResult = statTable.filter(tableRow => (tableRow.min <= v.endurance_score && tableRow.max >= v.endurance_score)); let agResult = statTable.filter(tableRow => (tableRow.min <= v.agility_score && tableRow.max >= v.agility_score)); let inResult = statTable.filter(tableRow => (tableRow.min <= v.intelligence_score && tableRow.max >= v.intelligence_score)); let clResult = statTable.filter(tableRow => (tableRow.min <= v.cool_score && tableRow.max >= v.cool_score)); console.log('EN score ' + v.endurance_score + ' save ' + enResult[0].save); setAttrs({ hid_en_save: enResult[0].save }); }); }; I've tested the lookup function with some hard-coded numbers and it works fine. The problem is that, as shown by the console.log statement, the value of the _score in the update function always 10... which is a placeholder value I dropped in early in the build. The actual field on the form is displaying the correct value, but the function doesn't see it. Current full code is at <a href="https://github.com/drl2/roll20-character-sheets/blob/mighty_protectors/Villains%20and%20Vigilantes/VandVMightyProtectors.html" rel="nofollow">https://github.com/drl2/roll20-character-sheets/blob/mighty_protectors/Villains%20and%20Vigilantes/VandVMightyProtectors.html</a> if it's useful. (Side question - why did I have to move statTable into the function itself rather than leaving it outside as a global? Any attempts to access it were failing until I made it local.)