So I'm not sure how I would go about it, but I want to set up a sheet worker that will add 1 to an attribute every time a certain word is entered into a text input within a repeating section. Here's what I've borrowed from a couple threads that I've dug up but it just doesn't work and I really have no idea if it ever would for what I'm trying to do. on("change:wounds", (event)=>{
const woundtype={
Moderate:{
moderatewound: 1
},
Severe:{
severewound: 1
},
Grievous:{
grievouswound: 1
},
Extreme:{
extremewound: 1
},
Fatal:{
fatalwound: 1
},
};
let setObj = woundtype[event.newValue.toLowerCase()];
if(setObj){
setAttrs(setObj);
}
}); Obviously if it did work it would just set Xwound to 1 instead of adding 1 to it, but that's not the problem. Also I'm going to change it to a dropdown later. I'm using text input to test it out. The next takes the Xwound attributes and divides it by half, multiplied by a certain number. For some reason it doesn't work. on("change:moderatewound change:severewound change:grievouswound change:extremewound change:fatalwound", function() {
getAttrs(["moderatewound","severewound","grievouswound","extremewound","fatalwound"], function(v) {
let moderatewound = parseInt(v.moderatewound,10)||0;
let severewound = parseInt(v.severewound,10)||0;
let grievouswound = parseInt(v.grievouswound,10)||0;
let extremewound = parseInt(v.extremewound,10)||0;
let fatalwound = parseInt(v.fatalwound,10)||0;
let moderatewoundpenalty = math.floor(moderatewound / 2) * 1;
let severewoundpenalty = math.floor(severewound / 2) * 2;
let grievouswoundpenalty = math.floor(grievouswound / 2) * 3;
let extremewoundpenalty = math.floor(extremewound / 2) * 4;
let fatalwoundpenalty = math.floor(fatalwound / 2) * 5;
setAttrs({
moderatewoundpenalty: moderatewoundpenalty,
severewoundpenalty: severewoundpenalty,
grievouswoundpenalty: grievouswoundpenalty,
extremewoundpenalty: extremewoundpenalty,
fatalwoundpenalty: fatalwoundpenalty
})
});
}); I could probably simplify it too but that's just the way I know how to do that. The final portion actually works so that's not a problem, but here it is. on("change:moderatewoundpenalty change:severewoundpenalty change:grievouswoundpenalty change:extremewoundpenalty change:fatalwoundpenalty", function() {
getAttrs(["moderatewoundpenalty","severewoundpenalty","grievouswoundpenalty","extremewoundpenalty","fatalwoundpenalty"], function(v) {
let moderatewoundpenalty = parseInt(v.moderatewoundpenalty,10)||0;
let severewoundpenalty = parseInt(v.severewoundpenalty,10)||0;
let grievouswoundpenalty = parseInt(v.grievouswoundpenalty,10)||0;
let extremewoundpenalty = parseInt(v.extremewoundpenalty,10)||0;
let fatalwoundpenalty = parseInt(v.fatalwoundpenalty,10)||0;
let woundpenalty = moderatewoundpenalty + severewoundpenalty + grievouswoundpenalty + extremewoundpenalty + fatalwoundpenalty;
setAttrs({
woundpenalty: woundpenalty
})
});
}); EDIT: Well that last one used to work...