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

[Rogue Trader Improved] Need help with auto-calc fields

1609929643

Edited 1609929809
Mago
Pro
Sheet Author
hello forum im one of the authors of the Rogue Trader Improved sheet (source code:&nbsp; <a href="https://github.com/Roll20/roll20-character-sheets/tree/master/Rogue%20Trader%20Improved" rel="nofollow">https://github.com/Roll20/roll20-character-sheets/tree/master/Rogue%20Trader%20Improved</a> &nbsp;) I need help with an important flaw that i could not find a permanent solution for: *In the CORE tab of the sheet the player must fill the Characteristics of the character in order to use most of the macros of the sheet, the problem arises when these values are saved on the sheet as static numbers and dont update if the value is changed later, unless that value is deleted on the "attributes and abilities tab", the value of these fields is an auto-calc of several other inputs: Starting (value) + Adv. Check box 1,2,3,4. here is a snip: &lt;button name="roll_WS" type="roll" style="width:10%;height:60px" &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; value="&amp;{template:custom} {{name=**@{character_name} Test Weapon Skill**}} {{result=[[(@{WeaponSkill}+?{Modifier|0}-1d100cf100cs1)/10]] }}"&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;input disabled name="attr_WeaponSkill" type="number" style="font-size:38px;height:55px" value="[[(@{StartingWS}+@{AdvancedWS1}+@{AdvancedWS2}+@{AdvancedWS3}+@{AdvancedWS4})]]"&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/input&gt;&lt;/button&gt; the issue here is that in the above example the attr_WeaponSkill&nbsp; will be saved as a static number in the "attributes and abilities tab", and will not update, the work around solution i found is to simply Delete the attribute from that tab and let the auto-calc recalculate, however in some instances the sheet will save that updated value again and the problem repeats. is there a way to prevent the sheet from saving that static number in the "attributes and abilities tab" but still retain the auto-calc value for macros? i did some experiments with those values and apparently there is some sort of limit on how many values are saved on the "attributes and abilities tab", since that tab does not show all "attr" values of the sheet (like checkboxes, hidden values and other auto-calc fields further down the code) any insight on this issue will be greatly appreciated, thanks!&nbsp;
1609932183

Edited 1609932239
GiGs
Pro
Sheet Author
API Scripter
First thing, there's a bit of a common misconception here. If you are using a character sheet, you should be ignoring the Attributes pane of the Attributes &amp; Abilities tab. It's a legacy feature, which allows people to create custom attributes that aren't on the character sheet, but for any attributes on the character sheet, you should not mess with them on the Attributes pane. One reason for this, is that autocalcs do not show up on the attributes pane properly, and judging attribute values by what is shown there will often lead to error. That weaponskill attribute should be updating for the purpose of macros; if it appears not to be, there's a problem somehwere in its construction. The Second Thing: one you start having problems with autocalc attributes, the advice you'll be given is to switch over to using sheet workers. The reason this advice is given is because it really is the best way to handle dynamic attribute values. Autocalcs are another legacy feature, that are not very efficient and can be difficult to manage. The main issue is that once you switch to a sheet worker for one stat, you need to switch for all stats that are constituents.&nbsp; Sheet workers cannot read autocalc stat values. Here's some code to do change all your stat calculations to sheet workers. First you need to change the html for each of your stats. For strength, you'd change it like so: &lt;input name="attr_WeaponSkill" type="number" value="0" style="font-size:38px;height:55px" readonly&gt; Change the other stats the same way, down to fellowship. Then search for the line&nbsp; &lt;/ script &gt; Immediately before that, put this code: const&nbsp;stats&nbsp;=&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;WeaponSkill:&nbsp;'WS', &nbsp;&nbsp;&nbsp;&nbsp;BallisticSkill:&nbsp;'BS', &nbsp;&nbsp;&nbsp;&nbsp;Strength:&nbsp;'S', &nbsp;&nbsp;&nbsp;&nbsp;Toughness:&nbsp;'T', &nbsp;&nbsp;&nbsp;&nbsp;Agility:&nbsp;'AG', &nbsp;&nbsp;&nbsp;&nbsp;Intelligence:&nbsp;'INT', &nbsp;&nbsp;&nbsp;&nbsp;Perception:&nbsp;'PER', &nbsp;&nbsp;&nbsp;&nbsp;Willpower:&nbsp;'WP', &nbsp;&nbsp;&nbsp;&nbsp;Fellowship:&nbsp;'FEL' }; Object.keys(stats).forEach(stat&nbsp;=&gt;&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;const&nbsp;abbr&nbsp;=&nbsp;stats.stat.toLowerCase(); &nbsp;&nbsp;&nbsp;&nbsp;on(`change:starting${abbr}&nbsp;change:advanced${abbr}1&nbsp;change:advanced${abbr}2&nbsp;change:advanced${abbr}3&nbsp;change:advanced${abbr}4&nbsp;sheet:opened`,&nbsp;()&nbsp;=&gt;&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;getAttrs([`Starting${abbr}`,&nbsp;`Advanced${abbr}1`,&nbsp;`Advanced${abbr}2`,&nbsp;`Advanced${abbr}3`,&nbsp;`Advanced${abbr}4`],&nbsp;values&nbsp;=&gt;&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;const&nbsp;starting&nbsp;=&nbsp;+values[`Starting${abbr}`]&nbsp;||&nbsp;0; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;const&nbsp;adv1&nbsp;&nbsp;=&nbsp;+values[`Advanced${abbr}1`]&nbsp;||&nbsp;0; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;const&nbsp;adv2&nbsp;&nbsp;=&nbsp;+values[`Advanced${abbr}2`]&nbsp;||&nbsp;0; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;const&nbsp;adv3&nbsp;&nbsp;=&nbsp;+values[`Advanced${abbr}3`]&nbsp;||&nbsp;0; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;const&nbsp;adv4&nbsp;&nbsp;=&nbsp;+values[`Advanced${abbr}4`]&nbsp;||&nbsp;0; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;const&nbsp;score&nbsp;=&nbsp;starting&nbsp;+&nbsp;adv1&nbsp;+&nbsp;adv2&nbsp;+&nbsp;adv3&nbsp;+&nbsp;adv4; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;setAttrs({ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[stat]:&nbsp;score &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}); &nbsp;&nbsp;&nbsp;&nbsp;}); }); The sheet worker above should handle all 9 stats, if you change the html for them from disabled to readonly attributes (and as long as I havent made a typo somewhere - quite possible!).
1609939751
Mago
Pro
Sheet Author
Thank you GiGs i do have some questions "That weaponskill attribute should be updating for the purpose of macros; if it appears not to be, there's a problem somewhere in its construction." can you expand on this point? for what i understand, any attr_ that has values in the sheet has a counterpart on "attributes and abilities" up to some unknown limit, there are attr_ values that do not show up there after that limit is reached.&nbsp; does script workers negate that tab recording those values that do not update? (due to been part of an auto-calc) does it work like the repeatingsum scripts? im not literate enough on those. because this will require significant reworks i think , we used many autocalc fields everywhere, are there other alternatives besides script workers? otherwise i will have a read at script workers and implement what you suggest.&nbsp;
1609974910
GiGs
Pro
Sheet Author
API Scripter
for what i understand, any attr_ that has values in the sheet has a counterpart on "attributes and abilities" up to some unknown limit, there are attr_ values that do not show up there after that limit is reached.&nbsp; This isnt accurate. There are many attributes that dont show up in the attributes pane on that tab. Any attributes in a repeating section dont show up there. autocalc attributes shouldnt be showing up there either. As I said, and this is very important &nbsp;for sheet designers to realise, the attributes &nbsp;pane on the attributes and abilities &nbsp;tab should be completely ignored &nbsp;when developing a sheet. Do not trust the attribute values that are shown there, and do not try to change them. They are not reliable, when you already have a character sheet. When trying to check the value of attributes, either look at the values on the character sheet tab or create macros to print the attribute scores to chat. Like, say, @{selected|WeaponSkill}. These are the only way to know what the stat actually is. Regarding your final question: The only alternative to autocalcs&nbsp; are sheet workers. You can use them together, as long as sheetworkers are earlier in the chain. Adopting sheet workers for part of your sheet, and autocalc for other parts is fine, as long s you do it in the right order. With autocalcs after &nbsp;sheet workers, not before. For example, say you have stat calculation, which leads to skill modifiers: If the stat calculation is done by sheet workers, the skill modifiers can be autocalcs. But if the stat calculation is done by autocalcs, you cant do the skill modifiers with sheet workers. Basically, if there's a chain of calculations, sheet workers have to be early in the chain, you cant add them at the end with autocalcs earlier in the chain. So the code I gave you is good even if you are using a lot of autocalcs: the stat scores are the earliest point of any calculations, so having them done with sheet workers is fine - you can have autocalcs using the generated stat scores. It's a lot easier for people to start working with autoalcs than it is with sheet workers, and it's a shame that sheet workers are so arcane, relatively speaking, but they are far superior once you get the grips with them.
1610011780

Edited 1610011806
Andreas J.
Forum Champion
Sheet Author
Translator
GiGs said: for what i understand, any attr_ that has values in the sheet has a counterpart on "attributes and abilities" up to some unknown limit, there are attr_ values that do not show up there after that limit is reached.&nbsp; This isnt accurate. There are many attributes that dont show up in the attributes pane on that tab. Any attributes in a repeating section dont show up there. autocalc attributes shouldnt be showing up there either. As I said, and this is very important &nbsp;for sheet designers to realise, the attributes &nbsp;pane on the attributes and abilities &nbsp;tab should be completely ignored &nbsp;when developing a sheet. Do not trust the attribute values that are shown there, and do not try to change them. They are not reliable, when you already have a character sheet. Hm, probably should document that somewhere on the wiki, but dunno where.