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

[HELP] Writing a sheetworker that increments one counter up and another counter down

Hello forumfolk! I'm working on a character sheet for Marvel Heroic Roleplaying, and I want to include a button that both increments the XP counter down one and the PP counter up one. I'm having trouble writing a sheetworker that does this successfully in the Custom Sheet Sandbox. Here is my code: <a href="https://github.com/flynnwastaken/marvel-heroic-roleplaying-roll20-character-sheet/blob/master/character-sheet.html" rel="nofollow">https://github.com/flynnwastaken/marvel-heroic-roleplaying-roll20-character-sheet/blob/master/character-sheet.html</a> Any advice?
1587937029
GiGs
Pro
Sheet Author
API Scripter
For the futrure, we dont need to see the full character sheet, we just need to specific macro you're having trouble with and the attributes involved. Is this the worker you are having trouble getting to work? on("clicked:buypp", function() { getAttrs(["xp", "pp"], function(values) { if (xp &gt; 0) { let newXp = parseInt(values.xp,10)||0; let newPp = parseInt(values.pp,10)||0; --newXp; ++newPp; setAttrs({ xp: newXp, pp: newPp }); }; }); }); There's one obvious problem here. There is no variable named xp, so the if statement fails. Try this on("clicked:buypp", function() { getAttrs(["xp", "pp"], function(values) { let xp = parseInt(values.xp)||0; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; let pp = parseInt(values.pp)||0; if (xp &gt; 0) { --xp; ++pp; setAttrs({ xp: xp, pp: pp }); } }); }); Note you dont need the ,10 in the parseInt statement.
Thank you, that if calling xp was the issue! Your recommendation works.