Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

Custom Character Sheet Help?

Hey guys, im trying to make a custom sheet with sheet workers for a homebrew tabletop that my buds and I are doing. The issues that im running into is that no matter what, I cant get certain fields to update.  Heres my current code. <script type="text/worker"> on("change:strs sheet:opened", function () { getAttrs(["strs"], function (values) { const strs = parseInt(values["strs"], 10)||0; const mod = 0; if (strs = 1){ mod = 0;} else if (1 < strs && strs <= 11){ mod = ((strs - 1) * 5);} else if (11< strs && strs <= 19){ mod = (((strs-11)/2)*5)+50;} else{ mod = (((strs-19)/4)*5)+70;} setAttrs({ block: (mod + 15); }); }); }); </script> in the html strs is defined as attr_strs while block is attr_block. Could someone please help? Thanks.
1550109271
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Ah, I believe you posted this question with an earlier version of the code on reddit earlier. The other issue that I didn't notice when I responded on Reddit is that you are defining mod as a constant. Constants cannot be reassigned once defined. If you check your developer console log, you'll probably see error messages about unable to reassign a constant. So, your code should be: <script type="text/worker">     on("change:strs sheet:opened", function () { getAttrs(["strs"], function (values) { const strs = parseInt(values["strs"], 10)||0; let mod; if (strs = 1){             mod = 0;                 }else if (1 < strs && strs <= 11){ mod = ((strs - 1) * 5);                 }else if (11< strs && strs <= 19){ mod = (((strs-11)/2)*5)+50;                 }else{ mod = (((strs-19)/4)*5)+70;                 } setAttrs({ block: (mod + 15); }); });     }); </script> I would recommend getting in the habit of looking at your developer console (ctrl-shift-i on windows or cmd-i on mac in chrome) while doing sheetworker coding and making use of console.log() to check your processes.
Thanks for all the help. but at this point I've basically given up. Its till not working. :/ I've taken out literally everything except for the following code and still nothing.  Not quite sure what im doing wrong. <div class="3colrow"> <Label>Strength:</label><input type="text" name="attr_strs" /> </div> <script type="text/worker"> on("change:strs sheet:opened", function () { getAttrs(["strs"], function (values) { const strs = parseInt(values["strs"], 10)||0; var mod; if (strs = 1){ mod = 0;} else if (1 < strs && strs <= 11){ mod = ((strs - 1) * 5);} else if (11< strs && strs <= 19){ mod = (((strs-11)/2)*5)+50;} else{ mod = (((strs-19)/4)*5)+70;} setAttrs({ block: (mod + 15); }); }); }); </script> <Label>block</label><input type="text" name="attr_block" /> Ah well, back to google sheets for those dodge and block calcs :/
1550199982
Finderski
Pro
Sheet Author
Compendium Curator
Part of your problem is probably this: if (strs = 1) That form of equals sign is declarative, not evaluative. Try thi, instead: if (strs === 1)
Im trying to level up a character in pathfinder how do i do that
1550276345
GiGs
Pro
Sheet Author
API Scripter
Michael, I suggest starting a new thread for that question. Sheng, there's another error in the code: setAttrs({ block: (mod + 15); }); Should be setAttrs({ block: (mod + 15) }); Also I'd suggest moving your entire script block to the end of the character sheet html, not in the middle like that.
Thanks GiGs, I cant believe we (friends and I IRL) didn't catch that X_X. That was the issue blocking the update. Thanks to everyone that helped!
1550287812
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
You might find the closure compiler useful. It'll catch a lot of the issues you had. <a href="https://closure-compiler.appspot.com/home" rel="nofollow">https://closure-compiler.appspot.com/home</a>