Coal Powered Puppet said: Awesome! I got that work this morning (after coffee) after failing to get it to work last night. Now, where do I look to see an example on how to set a maximum and minimum value for the cycling image? Meaning, if I have only four images (numbered 0 to 3), how do I keep the sheetworker from exceeding the maximum value? Edit: The internet is littered with a varity of examples of how to do this in javascript, but I'm having a rough time figuring out how to apply them. Here is my code for the increasing checkbox: on("change:feat_up ", function() {
getAttrs(["feat_up", "feat"], function(values) {
setAttrs({
feat: (+values.feat + 1)
});
});
});
You could use an if/else statement and if the feat value < 0, then feat = 0, else if feat > 3 then feat = 3. Here's an example of how to use the if/else type statement: on("sheet:opened change:xp change:rank", function() {
getAttrs(["xp", "rank"], function(value) {
console.log("xp value: " + value.xp);
console.log("rank value: " + value.rank);
if (value.xp >=80) {
console.log("Setting rank to Legendary");
setAttrs({Rank: 5});
}
else if (value.xp >=60) {
console.log("Setting rank to Heroic");
setAttrs({Rank: 4});
}
else if (value.xp >=40) {
console.log("Setting rank to Veteran");
setAttrs({Rank: 3});
}
else if (value.xp >=20) {
console.log("Setting rank to Seasoned");
setAttrs({Rank: 2});
}
else {
console.log("Setting rank to Novice");
setAttrs({Rank: 1});
}
});
});
You could do the value check before or after setting the attribute once, though I'd probably recommend doing the check before setting the attribute, so you only need to set it once.