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

Sheet Worker not refreshing

Hi ! As you can see from this post my issue is now completely different from the title issue. I made this sheet worker, and it works fine, but the issue is that after rangefinal updates itself once, it won't update anymore.. if I change the attributes again, rangefinal will stay with its first value.. The only way to make it refresh again is to upload the HTML once again, but the same issue occurs after the first update. Any idea ? <input name="attr_rangefinal" class="faimtest" type="range" min="0" max="100" value=""> <input name="attr_testfaim" class="faimtest" type="number" min="0" value=""> <input name="attr_testfaim_max" class="faimtest" type="number" min="0" value=""> <script type="text/worker"> on("change:testfaim change:testfaim_max", function () { getAttrs(["testfaim","testfaim_max"], function(values) { let testfaim = parseInt(values.testfaim)||0; let testfaim_max = parseInt(values.testfaim_max)||0; let rangefinalnew = (testfaim/testfaim_max)*100; setAttrs({ "rangefinal": rangefinalnew }); }); }); </script>
1616439367

Edited 1616439406
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
I believe it's because you have rangefinal's type set to range, which is not a valid type on character sheets. It should be type="number"
I'm getting the exact same issue with type="number" Which means it's not the type that's keeping the script from updating again :/
1616444427
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
I just loaded your code up in a test game and tried it with both the range and the number version. Works fine for me. I'd guess you've got an error going on somewhere else. Perhaps an extension that's interfering or something along those lines. And, TIL you can use ranges on Roll20 sheets, so thanks for that.
It updates everytime for you ? I took a gif of my issue :
1616446967
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Check your console log (Ctrl/CMD - Shift - J in chromium browsers) and see if you've got any errors. I'd also recommend using some console.log() to see if things are happening like you expect, but yeah, the code seems to work just fine in my test and all I did was copy/paste it into a custom sheet in a test game.
1616448362

Edited 1616448867
Andreas J.
Forum Champion
Sheet Author
Translator
Scott C. said: I believe it's because you have rangefinal's type set to range, which is not a valid type on character sheets. It should be type="number" *smirk* Oh it works, at least partially, but nobody have looked into it much further, apart from me discovering &amp; documenting it. <a href="https://wiki.roll20.net/CSS_Wizardry#Custom_Progress_Bar" rel="nofollow">https://wiki.roll20.net/CSS_Wizardry#Custom_Progress_Bar</a> Edit: now it has it's own section to be more easily found: <a href="https://wiki.roll20.net/Building_Character_Sheets#type.3D.22range.22" rel="nofollow">https://wiki.roll20.net/Building_Character_Sheets#type.3D.22range.22</a>
I added a console log right after the "on change" in order to see if the issue was detecting the change or after : Turns out the first time I change the value, the console log works, but then it won't work anymore. Which means that after the first change, the sheet worker stops listening ? on("change:testfaim change:testfaim_max", function () { console.log("faim changed !") by the way, here's everything I have in the script tab : &lt;script type="text/worker"&gt; on("sheet:opened", function() { getAttrs([ "Willpower", "Body" ], function(values) { const WILL = parseInt(values.Willpower)||0; const BODY = parseInt(values.Body)||0; var maxhp = 10 + 5 * Math.ceil((WILL+BODY)/2); setAttrs({ "hp_max" : maxhp }); }); }); on("change:testfaim change:testfaim_max", function () { console.log("faim changed !") getAttrs(["testfaim","testfaim_max"], function(values) { let testfaim = parseInt(values.testfaim)||0; let testfaim_max = parseInt(values.testfaim_max)||0; let rangefinalnew = (testfaim/testfaim_max)*100; setAttrs({ "rangefinal": rangefinalnew }); }); }); const buttonlist = ["character","lifepath", "registre","netrunning"]; buttonlist.forEach(button =&gt; { on(`clicked:${button}`, function() { setAttrs({ sheetTab: button }); }); }); &lt;/script&gt; And one thing I could notice was that the rangefinal stop detecting anything if I remove this first function : on("sheet:opened", function() { getAttrs([ "Willpower", "Body" ], function(values) { const WILL = parseInt(values.Willpower)||0; const BODY = parseInt(values.Body)||0; var maxhp = 10 + 5 * Math.ceil((WILL+BODY)/2); setAttrs({ "hp_max" : maxhp }); }); }); Any idea on why ?
1616451325
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Not sure what's going on, but I'm fairly confident it's something with your computer/browser or perhaps with your game. Your code works for me just fine: Maybe try your code in a fresh game?
1616452776
GiGs
Pro
Sheet Author
API Scripter
And if not in a fresh game, in a different browser, or in chrome ingognito mode, to make sure its not an extension interfering.
After testing it in a fresh game, I find out that changing the values on the sheet directly would update it, but changing it from the "attributes &amp; abilites" tab won't update anything However, I don't want to change these values from the sheet, I kinda want to hide these numbers from the player.. Atleast now I know it's not from the script, but I'm really lost Here's 2 gifs to explain it : Here everything works And here rangefinal won't update