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 wanted: why do I need to double click this to make it work?

1606182688
Steve
Plus
Sheet Author
Hey guys, I'm using the fill from left 'radio' buttons trick on my character sheet. Howerver I have found that I need to double click the radio button to ensure that changes are made properly each time. I'm pretty sure that isn't how it should work, can anybody spot what I have done? const woundValues = [ "0" , "1" , "2" , "3" , "4" , "5" , "6" , "7" , "8" , "9" , "10" , "11" , "12" , "13" , "14" , "15" , "16" , "17" , "18" , "19" , "20" , "21" , "22" , "23" , "24" , "25" , "26" , "27" , "28" , "29" , "30" , "31" , "32" , "33" , "34" , "35" , "36" , "37" , "38" , "39" , "40" , "41" , "42" , "43" , "44" , "45" , "46" , "47" , "48" , "49" , "50" ]; woundValues . forEach ( function ( value ) { on ( `clicked:wound_ ${ value } ` , function () { getAttrs ([ "wtwound" , "wound" , "maxhp" ], function ( v ) { let chp = parseInt ( v . maxhp ) - parseInt ( v . wound ) - parseInt ( v . wtwound ); setAttrs ({ wtwound : 0 , wound : value , currenthp : chp , currenthp_max : parseInt ( v . maxhp ) }); }); }); });
1606191814
Finderski
Pro
Sheet Author
Compendium Curator
Do you have the radio button input in multiple places?
1606278779
Steve
Plus
Sheet Author
Not for this one, but there is a linked smaller set of radio buttons. I also have three other sets of similar radio buttons, but all of them have different class and name tags (ie: one bank called act_manaused and mdot mt-#, another called act_secmanaused and m2dot mt2-# and another named act_termanaused and m3dot mt3-#). I'll paste the HTML code for the wounds tracker here:  < div class = "hpattributes" > < label class = "boxheading" > Health Points </ label > < label > Maximum Health Points < input class = "fourshorttextinput" type = "number" name = "attr_maxhp" min = "1" value = "1" /></ label > < label > Wounds Taken: </ label > < div class = "dots" > < input type = "hidden" name = "attr_wound" class = "sdot" value = "0" /> < input type = "hidden" name = "attr_maxhp" class = "sbody" min = "1" value = "1" /> < button title = "1" type = "action" name = "act_wound_1" class = "sdot gt-0" > < span class = "checked" ></ span > </ button > < button title = "2" type = "action" name = "act_wound_2" class = "sdot gt-0 gt-1" > < span class = "checked" ></ span > </ button > < button title = "3" type = "action" name = "act_wound_3" class = "sdot gt-0 gt-1 gt-2" > < span class = "checked" ></ span > </ button > < button title = "4" type = "action" name = "act_wound_4" class = "sdot gt-0 gt-1 gt-2 gt-3" > < span class = "checked" ></ span > </ button > < button title = "5" type = "action" name = "act_wound_5" class = "sdot gt-0 gt-1 gt-2 gt-3 gt-4" > < span class = "checked" ></ span > </ button > < button title = "6" type = "action" name = "act_wound_6" class = "sdot gt-0 gt-1 gt-2 gt-3 gt-4 gt-5" > < span class = "checked" ></ span > </ button > < button title = "7" type = "action" name = "act_wound_7" class = "sdot gt-0 gt-1 gt-2 gt-3 gt-4 gt-5 gt-6" > < span class = "checked" ></ span > </ button > < button title = "8" type = "action" name = "act_wound_8" class = "sdot gt-0 gt-1 gt-2 gt-3 gt-4 gt-5 gt-6 gt-7" > < span class = "checked" ></ span > </ button > < button title = "9" type = "action" name = "act_wound_9" class = "sdot gt-0 gt-1 gt-2 gt-3 gt-4 gt-5 gt-6 gt-7 gt-8" > < span class = "checked" ></ span > </ button > < button title = "10" type = "action" name = "act_wound_10" class = "sdot gt-0 gt-1 gt-2 gt-3 gt-4 gt-5 gt-6 gt-7 gt-8 gt-9" > < span class = "checked" ></ span > </ button >         ETC ETC ALL THE WAY TO 50... < button title = "50" type = "action" name = "act_wound_50" class = "sdot gt-0 gt-1 gt-2 gt-3 gt-4 gt-5 gt-6 gt-7 gt-8 gt-9 gt-10 gt-11 gt-12 gt-13 gt-14 gt-15 gt-16 gt-17 gt-18 gt-19 gt-20 gt-21 gt-22 gt-23 gt-24 gt-25 gt-26 gt-27 gt-28 gt-29 gt-30 gt-31 gt-32 gt-33 gt-34 gt-35 gt-36 gt-37 gt-38 gt-39 gt-40 gt-41 gt-42 gt-43 gt-44 gt-45 gt-46 gt-47 gt-48 gt-49" > < span class = "checked" ></ span > </ button > < input type = "hidden" name = "attr_wtwound" class = "wtdot" value = "0" /> < input type = "hidden" name = "attr_kohp" class = "wtbody" value = "3" /> < button title = "-1" type = "action" name = "act_wtwound_1" class = "wtdot wt-0" > < span class = "checked" ></ span > </ button > < button title = "-2" type = "action" name = "act_wtwound_2" class = "wtdot wt-0 wt-1" > < span class = "checked" ></ span > </ button > < button title = "-3" type = "action" name = "act_wtwound_3" class = "wtdot wt-0 wt-1 wt-2" > < span class = "checked" ></ span > </ button > </ div > < button type = "action" name = "act_wound_reset" class = "wound_reset" > Heal! </ button > < input type = "hidden" name = "attr_currenthp" disabled = "true" readonly />< br > Poison Save < button class = "button1 d20" type = "roll" value = "&{template:default} {{name=@{character_name} attempts to resist the effect of poison}} {{Poison Strength = [[?{Number of Dice|3}d6]]}} {{Under Target Number= [[@{finalstrength}+?{Strength Modifier?|0}]] }}" name = "roll_poisoncheck" ></ button >
1606278867
Steve
Plus
Sheet Author
The CSS code: input.sheet-sdot [ value = "0" ] ~ button.sheet-gt-0 > span.sheet-checked { display : none ; } input.sheet-sdot [ value = "1" ] ~ button.sheet-gt-1 > span.sheet-checked { display : none ; } input.sheet-sdot [ value = "2" ] ~ button.sheet-gt-2 > span.sheet-checked { display : none ; } ETC TO 50 then input.sheet-wtdot [ value = "0" ] ~ button.sheet-wt-0 > span.sheet-checked { display : none ; } input.sheet-wtdot [ value = "1" ] ~ button.sheet-wt-1 > span.sheet-checked { display : none ; } input.sheet-wtdot [ value = "2" ] ~ button.sheet-wt-2 > span.sheet-checked { display : none ; } input.sheet-wtdot [ value = "3" ] ~ button.sheet-wt-3 > span.sheet-checked { display : none ; } input.sheet-sbody [ value = "0" ] ~ button.sheet-gt-0 , input.sheet-sbody [ value = "1" ] ~ button.sheet-gt-1 , input.sheet-sbody [ value = "2" ] ~ button.sheet-gt-2 , input.sheet-sbody [ value = "3" ] ~ button.sheet-gt-3 , input.sheet-sbody [ value = "4" ] ~ button.sheet-gt-4 , input.sheet-sbody [ value = "5" ] ~ button.sheet-gt-5 , ETC to 50 then: display : none ; } input.sheet-wtbody [ value = "0" ] ~ button.sheet-wt-0 , input.sheet-wtbody [ value = "1" ] ~ button.sheet-wt-1 , input.sheet-wtbody [ value = "2" ] ~ button.sheet-wt-2 , input.sheet-wtbody [ value = "3" ] ~ button.sheet-wt-3 { display : none ; }
1606279678
Steve
Plus
Sheet Author
Here's a video demonstrating the behaviour:&nbsp; <a href="https://drive.google.com/file/d/1Ac5jz7tLPJB5wyYDdqh0DpjdH6f2Tmtv/view?usp=sharing" rel="nofollow">https://drive.google.com/file/d/1Ac5jz7tLPJB5wyYDdqh0DpjdH6f2Tmtv/view?usp=sharing</a>
1606312166
Andreas J.
Forum Champion
Sheet Author
Translator
Are you sure the changes isn't just happening super slow, instead of actually needing to double-click? try adding some console.log() commands in the sheetworker that repeats the value of the thing or something, that will make it easier to figure out what's going on with the sheet by looking at the browser's debugging console output.
1606347598
Steve
Plus
Sheet Author
I put a console log in to monitor currenthp: const woundValues = ["0","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31","32","33","34","35","36","37","38","39","40","41","42","43","44","45","46","47","48","49","50"]; woundValues.forEach(function(value) { on(`clicked:wound_${value}`, function() { getAttrs(["wtwound","wound","maxhp"], function(v) { let chp = parseInt(v.maxhp) - parseInt(v.wound) - parseInt(v.wtwound); setAttrs({ wtwound: 0, wound: value, currenthp: chp, currenthp_max: parseInt(v.maxhp) }); console.log("currenthp"); }); }); }); and here is what the debug screen says when I click on one of the wounds radios: ERROR parsing formula: undefined app.js?1606320761:567 TypeError: Cannot read property 'replace' of undefined at T.i.autoCalcFormula (app.js?1606320761:568) at app.js?1606320761:567 at NodeList.forEach (&lt;anonymous&gt;) at Function.C.each.C.forEach (base.js?1605629830:6) at T.i._updateSheetValues (app.js?1606320761:567) at r (base.js?1605629830:6) I have no idea what this means...
1606347859
Steve
Plus
Sheet Author
If I move the console.log down one step in the script, the debug log shows this instead: currenthp &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;VM4:637 ERROR parsing formula: undefined&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;app.js?1606320761:567 TypeError: Cannot read property 'replace' of undefined &nbsp;&nbsp;&nbsp;&nbsp;app.js?1606320761:567 at T.i.autoCalcFormula (app.js?1606320761:568) at app.js?1606320761:567 at NodeList.forEach (&lt;anonymous&gt;) at Function.C.each.C.forEach (base.js?1605629830:6) at T.i._updateSheetValues (app.js?1606320761:567) at r (base.js?1605629830:6)
1606349434

Edited 1606350097
Oosh
Sheet Author
API Scripter
.replace() is a string Method in JS, I'm guessing setAttrs must use it, though I have no idea why - I've never played with the sheet sandbox. But I can't see where else it would be coming from, unless there's more code? Do all those Attributes in the setAttrs definitely exist? Does commenting out the currenthp lines stop the crash? Also, you'll need the log to be console.log(chp); You don't have currenthp stored as a variable anywhere, and it's also currently a "string" rather than a variable reference.
1606384373

Edited 1606384486
Steve
Plus
Sheet Author
Thanks Oosh, you located the source of the debug screen error - I had set currenthp a bit zealously as: &lt; input type = "hidden" name = "attr_currenthp" disabled = "true" readonly /&gt; Once I got rid of the disabled and readonly, that error message doesn't pop up anymore. However, the double click requirement has not been resolved. When I click once on the button I get this in the debug window:&nbsp;
1606397654

Edited 1606397782
Andreas J.
Forum Champion
Sheet Author
Translator
MedievalSteve said: Thanks Oosh, you located the source of the debug screen error - I had set currenthp a bit zealously as: &lt; input type = "hidden" name = "attr_currenthp" disabled = "true" readonly /&gt; Once I got rid of the disabled and readonly, that error message doesn't pop up anymore. However, the double click requirement has not been resolved. When I click once on the button I get this in the debug window: If chp in console.log(chp); didn't work, try change the attribute name used, or to move the command to another place . I think this version should work better, and be a bit more robust(not 100% it works): woundValues.forEach(function(value) { on(`clicked:wound_${value}`, function() {&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; console.log('******button pressed: ${value}********'); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; getAttrs(["wtwound","wound","maxhp"], function(v) { &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; console.log("Old values; maxhp: " + v.maxhp + " wound: " + v.wound + " wtwound: " +v.wtwound); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; let chp = parseInt(v.maxhp) - parseInt(v.wound) - parseInt(v.wtwound); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; console.log("currenthp set to: " + chp); setAttrs({ wtwound: 0, wound: value, currenthp: chp, currenthp_max: parseInt(v.maxhp) }); }); }); }); This should tell you what button the sheetworker reacts to, what the original values where, and what the supposed new currenthp will be set as.
1606437891
Steve
Plus
Sheet Author
Okay, I've put your code in and this is the result (a video catches the behaviour better than a screenshot): <a href="https://drive.google.com/file/d/1J6_byRPR-FDK8uR_LmVmjYvH8pjN0uYQ/view?usp=sharing" rel="nofollow">https://drive.google.com/file/d/1J6_byRPR-FDK8uR_LmVmjYvH8pjN0uYQ/view?usp=sharing</a> By the looks of it, the first click is collecting the correct information, but isn't changing the attribute until the second click, so an example extract below. first click on first wound on an unwounded character: ******button pressed: ${value}********&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; VM4:627 Old values; maxhp: 6 wound: 0 wtwound: 0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;VM4:629 currenthp set to: 6&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;VM4:631 Followed by the second click of the same button: ******button pressed: ${value}********&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;VM4:627 Old values; maxhp: 6 wound: 1 wtwound: 0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;VM4:629 currenthp set to: 5&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;VM4:631
1606438401

Edited 1606438477
Steve
Plus
Sheet Author
Thanks for showing me how to do that, Case Solved! Of course it was taking two clicks - the math calculations were being done on attributes that weren't being set until after the math was done... I've moved setting the wound value back into the body of the script, so that the math function could access the updated number instead of the old one.&nbsp; **Gigantic Forehead Slap** Thanks for the help everybody, at least now I've got a much better idea of how to debug using the JS console. woundValues.forEach(function(value) { on(`clicked:wound_${value}`, function() { console.log('******button pressed: ${value}********'); getAttrs(["wtwound","wound","maxhp"], function(v) { let wnd = parseInt(value); let wtwnd = 0; let chp = parseInt(v.maxhp) - wnd - wtwnd; setAttrs({ wtwound: wtwnd, wound: wnd, currenthp: chp, currenthp_max: parseInt(v.maxhp) }); }); }); });
1606438537
Andreas J.
Forum Champion
Sheet Author
Translator
Great!