Hi! At the moment I'm trying to create my first character sheet for a german RPG. I stumbled over this: The user has the possibilty to add specific resources that modify the attributes of his character. He does this with a repeating section and this part works fine. But I want to make sure that the attributes aren't modified anymore if the resource is deleted from the repeating section-table while the row is not empty. For example may a character have the resource "gigantism", that modifies his size by 2. He adds the resource to the character sheet and gets the modifier. But when he deletes the row (without setting the value to 0 before) the modifier stays. Here's the code that adds the modifiers: on("change:repeating_resources", function(eventinfo) {
getSectionIDs("repeating_resources", function(idarray) {
_.each(idarray, function(currentID, i) {
getAttrs(["repeating_resources_" + currentID +"_resourcevalue", "repeating_resources_" + currentID +"_resource"], function(v) {
var resource = v["repeating_resources_" + currentID + "_resource"];
var resourcevalue = v["repeating_resources_" + currentID + "_resourcevalue"];
if (resource.toLowerCase() == "gigantism") {
setAttrs({
hiddensizemod: 2
});
} else if (resource.toLowerCase() == "midas") {
setAttrs({
hiddenmoneymod: 5
});
}
});
});
});
}); And this should delete the modifiers: on("remove:repeating_resources", function(eventInfo) {
getSectionIDs("repeating_resources", function(idarray) {
_.each(idarray, function(currentID, i) {
getAttrs(["repeating_resources_" + currentID +"_resourcevalue", "repeating_resources_" + currentID +"_resource"], function(v) {
var resource = v["repeating_resources_" + currentID + "_resource"];
var resourcevalue = v["repeating_resources_" + currentID + "_resourcevalue"];
if (resource.toLowerCase() == "gigantism") {
setAttrs({
hiddensizemod: 0
});
} else if (resource.toLowerCase() == "midas") {
setAttrs({
hiddenmoneymod: 0
});
}
});
});
});
}); My problem is that the setAttrs doesn't seem to work when I delete a specific row (while there is content in the row). But when I add a new resource to the repeating section, don't fill in anything and then delete the row, ALL modifier-textfields become 0 - But only when the row is not empty. I don't understand this mechanism and am seeking for the knowlegde of those who are more familiar with the character sheet-mechanisms. Is it possible to set the row to null before deleting the modifier or is there another solution? Greetings, Loki