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] ... a little help plz

1458992683

Edited 1458992832
erwan l.
Sheet Author
hello, i am trying to make a checkbox that could aply a modification. both checkbox and modifications attributes are in this repeating section : <fieldset> <table> <tr> <th><h3>forme actuelle</h3> <input type='checkbox' name='attr_forme_actuelle' value='1' /><span></span> </th> <th style="width:200px;"><h2>nom de la forme</h2><input type="text" name="attr_forme_nom"/></th> <th style="width:45px;">giri<input type="number" name="attr_forme_giri"/></th> <th>temps de transformation<input type="number" name="forme_temps"/>minutes</th> <th style="width:400px">liste des capacités <textarea name="attr_forme_capacités" style="height:50px; width:350px;"></textarea></th> </tr> <table align="center"> <tr><h3 align="center"> bonus au caracaractéristiques</h3> <tr> <th><h4>int</h4></th> <th><h4>ref</h4></th> <th><h4>tech</h4></th> <th><h4>dex</h4></th> <th><h4>pers</h4></th> <th><h4>vol</h4></th> <th><h4>for</h4></th> <th><h4>const</h4></th> <th><h4>mouv</h4></th> <th><h4>phy</h4></th> </tr> <tr> <th> <input type="number" name="attr_forme_int"/> </th> <th><input type="number" name="attr_forme_ref"/></th> <th><input type="number" name="attr_forme_tech"/></th> <th><input type="number" name="attr_forme_dex"/></th> <th><input type="number" name="attr_forme_pers"/></th> <th><input type="number" name="attr_forme_vol"/></th> <th><input type="number" name="attr_forme_for"/></th> <th><input type="number" name="attr_forme_cons"/></th> <th><input type="number" name="attr_forme_mouv"/></th> <th><input type="number" name="attr_forme_phy"/></th> </tr> </table> </fieldset> i also have an attribute called "int_mod" here : <tr> <th>Intéligence</th> <th> <input type="text" style="width: 45px;" name="attr_int_mod" Value="0" /> </th> <th><input type="text" style="width: 45px;" name="attr_int_base" Value="0" /></th> <th><input type="number" style="width: 45px;" name="attr_int" Value="@{int_mod}+@{int_base}" disabled="true" /></th> <th><button type='roll' value='/e @{nom} fait un jet -intéligence- [[1d10! + [[@{int}]] ]] contre une difficulté de [[?{niveau de difficuté|14}]]'></button></th> </tr> and here is my script : <script type="text/worker"> on("sheet:opened change:repeating_transforme:forme_actuelle ", function() { getAttrs(["int_mod", "repeating_transforme_forme_int"], function(value) { if (value.repeating_transforme_forme_actuelle ==1) { setAttrs({int_mod: values.int_mod+values.repeating_transforme_forme_int}); } else { setAttrs{(int_mod:values.int_mod-values.repeating_transforme_forme_int)}; } }); }); </script> i know i must do it the wrong way (because it doesn't work) but can't figure it out... thanks in advance
1459024455
Lithl
Pro
Sheet Author
API Scripter
Well, first and foremost, unless something got messed up when you pasted the HTML into your post, you don't have class="repeating_transforme" on your fieldset to make it a repeating section.
something hapenned during the copy/paste because all my classes disapeared ; here is the real code : <fieldset class="repeating_transforme">         <table class="sheet-damagetable">         <tr>             <th><h3>forme actuelle</h3> <input type='checkbox' name='attr_forme_actuelle' value='1' /><span></span></th>             <th style="width:200px;"><h2 class="sheet-titrepartie">nom de la forme</h2><input type="text" name="attr_forme_nom"/></th>                    <th style="width:45px;">giri<input type="number" name="attr_forme_giri"/></th>             <th>temps de transformation<input type="number" name="forme_temps"/>minutes</th>             <th style="width:400px">liste des capacités <textarea name="attr_forme_capacités"  style="height:50px; width:350px;"></textarea></th>                         </tr>                    <table class="sheet-damagetable" align="center">             <tr><h3 align="center"> bonus au caracaractéristiques</h3>                     <tr>                         <th><h4>int</h4></th>                         <th><h4>ref</h4></th>                         <th><h4>tech</h4></th>                         <th><h4>dex</h4></th>                         <th><h4>pers</h4></th>                         <th><h4>vol</h4></th>                         <th><h4>for</h4></th>                         <th><h4>const</h4></th>                         <th><h4>mouv</h4></th>                         <th><h4>phy</h4></th>                                              </tr>                      <tr>                         <th><input type="number" name="attr_forme_int"/></th>                         <th><input type="number" name="attr_forme_ref"/></th>                         <th><input type="number" name="attr_forme_tech"/></th>                         <th><input type="number" name="attr_forme_dex"/></th>                         <th><input type="number" name="attr_forme_pers"/></th>                         <th><input type="number" name="attr_forme_vol"/></th>                         <th><input type="number" name="attr_forme_for"/></th>                         <th><input type="number" name="attr_forme_cons"/></th>                         <th><input type="number" name="attr_forme_mouv"/></th>                         <th><input type="number" name="attr_forme_phy"/></th>                                              </tr>                                      </table>                           </fieldset>
1459052804
Lithl
Pro
Sheet Author
API Scripter
Looks like you're not including repeating_transforme_forme_actuelle in your getAttrs  array, so  value.repeating_transforme_forme_actuelle ==1  will always be false. In your setAttrs  calls, you're using values , but your parameter name is value Your values are most likely coming in as strings, and you're attempting to perform calculations with them. Use parseInt  if the values are supposed to be whole numbers, or parseFloat  if they're allowed to have decimals in them. (eg: parseInt(values.int_mod)+parseInt(values.repeating_transforme_int) ) That covers everything I can see just looking at the code. If the above doesn't get it working, I'll have to run the code to debug it.
So ... i made the corrections you pointed at ; and... nothing better... i tried to change all my "input text" in "input number" : nothing more... i am getting mad -_-'