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

Interactive sheet

1607536532

Edited 1607536690
Hello guys, I need your help for my own character sheet. I want to display the result of variable on my character sheet. For exemple I have two variables : "ArmeMini" = 10 and "ArmeMaxi" =13 and I need to display : "ArmeMini"+"ArmeMax" so I want to display : 23 I try this      Min : <input type="number" name='attr_ArmeMini' class='sheet-short' value='10'> Max : <input type="number" name='attr_ArmeMax' class='sheet-short' value='0'>     <input type="hidden" disabled="true" name="attr_blabla" value="([[@{ArmeMini}]]+[[@{ArmeMax}]])" />         --<input type="text" name="attr_blabla"> for test I have display "ArmeMini" like this and its works: --<input type="text" name="attr_ArmeMini">--  But.. I have this :  You can see the "10" it's my test of display of "ArmeMini", yet my variable "blabla" (the result of "ArmeMini"+"ArmeMax") dosn't work. If I display my variable on the chat (with roll) I have "23" so, my variable "blabla" works.. if you have suggestion to help me.
1607537201
Daniel T.
Sheet Author
Translator
On the value attribute, just put like this: <input type="hidden" disabled="true" name="attr_blabla" value="@{ArmeMini}+@{ArmeMax}" />
1607537885

Edited 1607537979
Thanks for help, but it's seem the same result..     Min : <input type="number" name='attr_ArmeMini' class='sheet-short' value='10'> Max : <input type="number" name='attr_ArmeMax' class='sheet-short' value='0'>     <input type="hidden" disabled="true" name="attr_blabla" value="@{ArmeMini}+@{ArmeMax}" />     --<input type="text"  name="attr_blabla">--<input type="text" name="attr_ArmeMini">-- 
1607538342
Kraynic
Pro
Sheet Author
How is the visible attribute being used?  Is it something people are expected to edit, just used as a value in macros, or something else?  If it isn't something people need to be editing, you could just use a sheetworker and set your visible field to readonly.
This principle will be used mainly in the calculation of the armor points of the characters (calculated with the different equipment that the character has). So i need that people can see this information.
1607540983
Daniel T.
Sheet Author
Translator
Ah, now I've seen the issue. If the players do not need to edit the attr_blabla field, then you don't need the hidden input. In order for auto-calc fields to work, they need to have the disabled="true" attribute. So, it should be like this: Min : <input type="number" name='attr_ArmeMini' class='sheet-short' value='10'> Max : <input type="number" name='attr_ArmeMax' class='sheet-short' value='0'>          --<input type="text" disabled="true" name="attr_blabla" value="@{ArmeMini}+@{ArmeMax}">--<input type="text" name="attr_ArmeMini">-- But if the attr_blabla field has to be editable, then you will have to use a sheetWorker for it.
1607541737

Edited 1607541819
Thanks for your help. so no solution ?
1607544390
Kraynic
Pro
Sheet Author
The solution is to not use autocalc, but switch to using a sheetworker, I think.  You might want to set a default value if this is used in macros in case it is called before the sheetworker has been triggered. Min : <input type="number" name='attr_ArmeMini' class='sheet-short' value='10'> Max : <input type="number" name='attr_ArmeMax' class='sheet-short' value='0'>        --<input type="text" name="attr_blabla" value="10" readonly> Then you add your sheetworker script section (all sheetworkers will end up in the same area) either before the beginning or after the end of your html in the same file.  <!-- Scripts --> <script type="text/worker"> on("change:ArmeMini change:ArmeMax", function () { getAttrs(['ArmeMini','ArmeMax', 'blabla'], function (values) { const minimax = ArmeMini + ArmeMax; setAttrs({ blabla: minimax }); }); }); </script> One thing I should mention is that I am on lunch break at work, so this isn't tested.  I am not sure that capital letters work in sheetworkers, so your attribute names may need to be changed to all being lower case (armemini, armemax, etc.) in both the html and the sheetworker.  If it is possible that people won't be needing to alter the armemini and armemax stats before playing a character, then you could also add a trigger for the script to run when the sheet is opened: "change:ArmeMini change:ArmeMax sheet:opened" Hopefully that will get you going.
Wow.. thanks you. it seems to be quite complicated .. I will try but I do not believe too much
so... it's don't works ! xD I have tried to modify the code (with an exemple of D&D5 sheet) <script type="text/worker">     on("change:armemini change:armemax", function(eventinfo) {         getAttrs(['armemini','armemax','blabla'], function(v) {             const minimax = v["armemini"] + v["armemax"];                 setAttrs({blabla: minimax})         });     }); </script> with this  Min : <input type="number" name='attr_armemini' class='sheet-short' value='10'> Max : <input type="number" name='attr_armemax' class='sheet-short' value='50'>        -- <input type="text" name="attr_blabla" readonly> but with the concatenation of "armemini" and "armemax" I have try some without " v[ ] " the addition between [ ], with and without " "  but i don't find the solution.. sorry, i'm so.. bad :D I am close to find the solution, its frustrating ...
1607551544
vÍnce
Pro
Sheet Author
I'm not the best to comment on sheetworkers, but try <script type="text/worker"> on("cha nge:armemini change :armemax", function(eventinfo) {   getAttrs(['armemini','armemax','blabla'], function(v) {     const minimax = (parseInt(v.armemini)||0) + (parseInt(v.armemax)||0);     setAttrs({blabla: minimax})   }); }); </script>
1607552392
vÍnce
Pro
Sheet Author
You also might consider using attribute based spans instead of readonly inputs. replace this;  -- <input type="text" name="attr_blabla" readonly> with  -- <span name="attr_blabla"></span>
1607555640

Edited 1607555653
Kraynic
Pro
Sheet Author
Apparently I skipped a step.  GiGs would be disappointed in me after all the help he gave me....  I still know pretty much nil about javascript though. I plugged this code into a test game and it works for me.  I forgot to "construct" the 2 stats that are used in the calculations.  Min : <input type="number" name='attr_armemini' class='sheet-short' value='10'> Max : <input type="number" name='attr_armemax' class='sheet-short' value='0'> --<input type="text" name="attr_blabla" value="10" readonly> <!-- Scripts --> <script type="text/worker"> on("change:armemini change:armemax", function () { getAttrs(['armemini','armemax', 'blabla'], function (values) { const armemini = parseInt(values['armemini'])||0; const armemax = parseInt(values['armemax'])||0; const blabla = armemini + armemax; setAttrs({ blabla }); }); }); </script> I simplified it a bit so that I'm not using an intermediary attribute (removed minimax). Anyway, that sheetworker should work for you, since it works in my test game.  You could set the armemini to 10 in the script I think, but I wasn't sure if it was possible for it to ever be below 10.  Having the 0 there keeps it from failing if there is ever not a value plugged in for that attribute.
yes Kraynic, this sheetworker works ! Really thanks everybody for your help ! I need to understand how it's works, but now i can continue my character sheet ! 
1607613666
Kraynic
Pro
Sheet Author
It would take some searching through the replies on that profile, but you might look through some posts by GiGs .&nbsp; GiGs sometimes went out of the way to try to do a good explanation for sheetworkers.&nbsp; This thread is one example:&nbsp; <a href="https://app.roll20.net/forum/post/8916702/more-sheetworker-butchering-if-else-if-with-2-things-that-need-to-be-true/?pageforid=8916702#post-8916702" rel="nofollow">https://app.roll20.net/forum/post/8916702/more-sheetworker-butchering-if-else-if-with-2-things-that-need-to-be-true/?pageforid=8916702#post-8916702</a> The wiki also has a couple pretty good articles on sheetworkers that should get you going on simpler uses: <a href="https://wiki.roll20.net/Sheet_Worker_Scripts" rel="nofollow">https://wiki.roll20.net/Sheet_Worker_Scripts</a> <a href="https://wiki.roll20.net/Sheetworker_examples_for_Non-programmers" rel="nofollow">https://wiki.roll20.net/Sheetworker_examples_for_Non-programmers</a> <a href="https://wiki.roll20.net/Sheet_Worker_Snippets" rel="nofollow">https://wiki.roll20.net/Sheet_Worker_Snippets</a> <a href="https://wiki.roll20.net/UniversalSheetWorkers" rel="nofollow">https://wiki.roll20.net/UniversalSheetWorkers</a>
1607630785
vÍnce
Pro
Sheet Author
Kraynic said: It would take some searching through the replies on that profile, but you might look through some posts by GiGs .&nbsp; GiGs sometimes went out of the way to try to do a good explanation for sheetworkers.&nbsp; This thread is one example:&nbsp; <a href="https://app.roll20.net/forum/post/8916702/more-sheetworker-butchering-if-else-if-with-2-things-that-need-to-be-true/?pageforid=8916702#post-8916702" rel="nofollow">https://app.roll20.net/forum/post/8916702/more-sheetworker-butchering-if-else-if-with-2-things-that-need-to-be-true/?pageforid=8916702#post-8916702</a> The wiki also has a couple pretty good articles on sheetworkers that should get you going on simpler uses: <a href="https://wiki.roll20.net/Sheet_Worker_Scripts" rel="nofollow">https://wiki.roll20.net/Sheet_Worker_Scripts</a> <a href="https://wiki.roll20.net/Sheetworker_examples_for_Non-programmers" rel="nofollow">https://wiki.roll20.net/Sheetworker_examples_for_Non-programmers</a> <a href="https://wiki.roll20.net/Sheet_Worker_Snippets" rel="nofollow">https://wiki.roll20.net/Sheet_Worker_Snippets</a> <a href="https://wiki.roll20.net/UniversalSheetWorkers" rel="nofollow">https://wiki.roll20.net/UniversalSheetWorkers</a> Agree 100% ;-)
Thanks all for help :)
I need your help again.. i'm so bad..&nbsp; I have tab with spell. is a repeating section like this: the name of spell, the mimum and maximum dammage, the cooldown and the class of spell (for exemple pyrokinesis) and the roll button. I have on other tab with skill like this&nbsp; (I know is french but isn't important) I want when i click on roll button, one script calculate the dammage.&nbsp; The dammage depends on 1d20 (with 1=min, 20=max), the level of skill (for exemple, the skill is pyrokinesis, if the character has 1 point on pyro, the damage is 5% more powerfull). my problem because i'm beginner on script, i don't understand how i can to read variables on repeating section. (maybe the if,else section is an other problem for me..) I have read this wiki :&nbsp; <a href="https://wiki.roll20.net/Sheet_Worker_Scripts" rel="nofollow">https://wiki.roll20.net/Sheet_Worker_Scripts</a> &nbsp;but, it's doesn't work for me... for simple exemple i make this &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;fieldset class="repeating_skill"&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;divstyle="width:10px;margin-left:1px;" &gt;nom&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;input type="text" name="attr_skill_name"style="margin-left:5px;width:100px;"/&gt;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;divstyle="width:10px;margin-left:1px;" &gt;Min&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;input type="number" name="attr_sortmin"style="width:60px;margin-left:1px;font-weight:lighter;"/&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;divstyle="width:10px;margin-left:1px;" &gt;max&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;input type="number" name="attr_sortmax"style="width:60px;margin-left:1px;font-weight:lighter;"/&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;divstyle="width:10px;margin-left:1px;" &gt;Nombre de tour : &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;input type="number" name="attr_nombretour"style="width:50px;margin-left:1px;font-weight:lighter;"/&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; |&amp;nbsp;0 : &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;input type="radio" name="attr_trun0" value="1"checked/&gt;&nbsp; &nbsp; &lt;!--1/2--&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; |&amp;nbsp;1 : &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;input type="radio" name="attr_trun1" value="2"/&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;!-- taken--&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; |&amp;nbsp;2 : &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;input type="radio" name="attr_trun2" value="3"/&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;!-- +10%--&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; |&amp;nbsp;3 : &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;input type="radio" name="attr_trun3" value="4"/&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; |&amp;nbsp;4 : &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;input type="radio" name="attr_trun4" value="5"/&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;!-- +20% --&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;select class="hiding class" name="attr_catsort" style="width:120px"&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;option value="" data-i18n="choose"&gt;Compétance&lt;/option&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;option value="guerre"&gt;Art de guerre&lt;/option&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;option value="Chasseur"&gt;Chasseur&lt;/option&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;option value="Fripouille"&gt;Fripouille&lt;/option&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;option value="Pyrokinésie"&gt;Pyrokinésie&lt;/option&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;option value="Aérothurge"&gt;Aérothurge&lt;/option&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;option value="Géomencien"&gt;Géomencien&lt;/option&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;option value="Necromencien"&gt;Necromencien&lt;/option&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;option value="Invocation"&gt;Invocation&lt;/option&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;option value="Metamorphose"&gt;Metamorphose&lt;/option&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/select&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;button type='roll' name='roll_sort' value='&amp;{template:default} {{name=@{character_name}}} {{[[@{degatsort}]]}}'&gt;&lt;/button&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;textarea name="comp_Description" style="height:10px width :30px"&gt;&lt;/textarea&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/fieldset&gt;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/div&gt; and the script : &lt;!--test--&gt; &lt;script type="text/worker"&gt; on("change:repeating_skill:sortmin sheet:opened", function() {&nbsp;&nbsp; getAttrs(["repeating_skill:sortmin"], function(values) { let min = parseInt(values.repeating_skill:sortmin)||0; setAttrs({&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; repeating_skill:degatsort: min }); }); }); &lt;/script&gt; &lt;!--______________________________________________________--&gt;