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

Can anyone see why my sheetworker doesn't...um...work?

1732618048

Edited 1732655421
Wondering if anyone would mind helping me...  I am probably being stupid, but I cannot get this sheet worker to do ANYTHING.  The code I am using is:  <div class="sheet-spirit sheet-block">     <label>Spirit</label>     <span><input name="attr_spirit" type="number" value="@{spirit}" readonly/><input name="attr_spirit_curr" type="number" value="0"/></span>   </div>    <div class="sheet-mind sheet-block">     <label>Mind</label>     <input name="attr_mind" type="number" value="0"/>   </div>    <div class="sheet-body sheet-block">     <label>Body</label>   <input name="attr_body" type="number" value="0"/>   </div>  <script type="text/worker"> on("change:mind", function() {   getAttrs(["mind","body"],function(values) {   let mind= parseInt(values.mind)  || 0;   let body= parseInt(values.body)  || 0;   let spirit_new=(mind2 + body)2;    setAttrs({     "spirit"=spirit_new    });   }); }); </script> The idea being that when the player alters the value in mind then the sheetworker updates the value of spirit, using both mind and body in the calculation.  But in reality it does nothing at all.  Spirit is valueless (though the html input boxes are showing as I expect them to).  I have obviously missed something.  Does anyone have any ideas, please?
1732635554

Edited 1732637467
vÍnce
Pro
Sheet Author
Hi Oakmaiden, a couple things I see; <input name="attr_spirit" type="number" value="@{spirit}" readonly/> Instead of setting the value of spirit to itself, just use "0". I'm not sure what the calculation is actually supposed to be for spirit_new... let spirit_new=(mind2 + body)2; This reads like "mind2" is a variable that you haven't defined.  OR are you wanting to multiply by 2? maybe you want this; let spirit_new = (mind*2 + body)*2; Something else to consider; If you want to use spirit on a token bar, you might want use spirit for current and spirit_max as your attributes.
Thank you for your suggestions, Vince.  I hadn't noticed that when I posted the code the forum changed my calculation by taking away the * symbols. , My actual calculation is written as you suggested it should be.   I tried changing the value of attr_spirit back to 0,  but sadly there is still no effect when I change the value of mind on a character sheet. My suspicion is that the sheet worker isn't registering that the value of mind is changing (because I tried cutting it down to it's simplest form and said effectively "When the value of mind changes then change the value of spirit to 3" and that didn't work either.)
ahahaha!  ^does a happy dance^ "spirit"=spirit_new should be spirit : spirit_new Hurrah for the person who suggested this to me! And thank you for engaging with this too. Oak
1732662687
vÍnce
Pro
Sheet Author
I should have picked up on the incorrect setAttrs syntax.  Glad you got it working.
1732817749
GiGs
Pro
Sheet Author
API Scripter
Are you still having any problems? Try here for sheet building help: <a href="https://cybersphere.me/roll20/" rel="nofollow">https://cybersphere.me/roll20/</a>