
I'm building a character sheet to test a very early version of an RPG I'm designing—something fun to play with friends. I figure this would be a good opportunity to familiarize myself with building sheets in Roll20 and javascript. Hence my probably very simple problem:
The parts: There are three fields to each skill [Career(checkbox), Aptitude Score(input:number), and Base Score]. In this case, the skill is Anthropology (shortened to 'anthro' in the code).
My goal: The Base Score is supposed to change depending on whether the Career checkbox is checked. If it is, the Base Score is the Aptitude Score * 10. Otherwise, it is 0. My problem is that nothing is calculated or appears on the character sheet in the game when the box is checked.
The code:
<script type="text/worker">
on("sheet:opened","change:anthrocareer", function() {
getAttrs(["anthroCareer","anthroApt"], function(values) {
let checked = parseInt(values.anthroCareer)||0;
let aptitude = parseInt(values.anthroApt,10)||0;
let basescore = 0;
if(checked === 1) {
basescore = aptitude * 10;
}
setAttrs({
anthroBase:basescore
});
});
});
</script>