Hey, Im trying to have 2 actions buttons in a repeating field section. But im having some problems to get it to get the attributes right. So the 2 buttons will increase or decrease attr_mastery_current by 1. But right now it set it to either 1 or -1, so im thinking that my problem is in getting the current attribute. HTML code: <h3>Mastery Points</h3>
<fieldset class="repeating_mastery">
<div class="mastery_points">
<span>Type</span>
<input type="text" name="attr_mastery_type">
<span>Max</span>
<input type="number" name="attr_mastery_max">
<span>Current</span>
<button type="action" name="act_mastery-down" class="downaction" style="font-family: 'Pictos'">}</button>
<input type="number" name="attr_mastery_current" value="0">
<button type="action" name="act_mastery-up" class="upaction" style="font-family: 'Pictos'">{</button>
</div>
</fieldset> Sheet-worker: on('clicked:repeating_mastery:mastery-up', function(eventInfo) {
const rowid = eventInfo.sourceAttribute.split('_')[2];
getAttrs(['repeating_mastery_${rowid}_mastery_current'], function(values) {
// get the level stat, and coerce into a numerical value.
const current = +values.mastery_current || 0;
// increase by 1
const newcurrent = current +1;
// save the updated attribute to the sheet
setAttrs({
[`repeating_mastery_${rowid}_mastery_current`]: newcurrent
});
});
});
on('clicked:repeating_mastery:mastery-down', function(eventInfo) {
const rowid = eventInfo.sourceAttribute.split('_')[2];
getAttrs(['repeating_mastery_${rowid}_mastery_current'], function(values) {
// get the level stat, and coerce into a numerical value.
const current = +values.mastery_current || 0;
// decrease by 1
const newcurrent = current -1;
// save the updated attribute to the sheet
setAttrs({
[`repeating_mastery_${rowid}_mastery_current`]: newcurrent
});
});
}); Hope you guys can help me! Thanks