
I want a field to be reset to 0 after a button is clicked. Everything works fine until the very end where the input is set to 0 and I was wondering if there is an issue with two setAttrs
on("clicked:repeating_spells1:mpcostspellmulti", function(eventInfo) {
let rowId = eventInfo.sourceAttribute.split("_")[2];
let attributes = [
`repeating_spells1_${rowId}_spell_single_mp1`,
`repeating_spells1_${rowId}_spell_multi_target_selected1`,
"mp"
];
getAttrs(attributes, function(values) {
let mpCost = parseInt(values[`repeating_spells1_${rowId}_spell_single_mp1`]) || 0;
let targetSelect = parseInt(values[`repeating_spells1_${rowId}_spell_multi_target_selected1`]) || 0;
let mpCurrent = parseInt(values.mp) || 0;
let updatedMp = mpCurrent - (mpCost * targetSelect);
setAttrs({
mp: updatedMp,
[`repeating_spells1_${rowId}_checkbox_spell_target_query`]: "0" }, function() {
startRoll(`@{repeating_spells1_${rowId}_roll_spell_single1}`, function(rollResult) {
finishRoll(rollResult.rollId, {}, function() {
setAttrs({
[`repeating_spells1_${rowId}_spell_multi_target_selected1`]: "0"
});
});
});
});
});
});