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 .
×

[Help] Autocalc fields ignoring text, only taking numbers

Sort of a weird issue here. In the sheet I'm working on, you can add powers, setting their "mana" costs across one or two resources. To give an example, I can add the power Fireball, and set its resource 1 cost, using a select field, to be: Free 1, 2, 3, 4, or 5 1d4, 1d6, 1d8, 1d10, or 1d12 Special X, Xd4, Xd6, Xd8, Xd10, or Xd12 I have an edit view and a "use" view, with the latter being what the player will see on their sheets, with nicer formatting and everything shown on disabled fields (similar to how the Pathfinder sheet lets you click the lock icon to go back and forth). I want to have a "cost" section on the nicer view that pulls together the resource costs and names and displays them properly. I have a sheetworker watching for changes in power costs, which then makes a new string listing the costs and puts it in a hidden field, which is then grabbed by an autocalc to actually be displayed. The problem is that if there are any numbers in the string in the hidden text field, the autocalc seems to only grab the numbers and ignores all text.  For example, if the field pwr_costs reads "1 Justice, 1d4 Fervor", the autocalc (value="@{pwr_costs}") will show only 114. I'm assuming autocalc is seeing numbers then figuring that's all I want, but I don't know how to make it... not do that. If the pwr_costs field only has non-numeric characters in it, the display works fine.  Any help or explanation as to this behaviour would be greatly appreciated!
1533431390
GiGs
Pro
Sheet Author
API Scripter
I'm pretty sure autocalc fields are only meant for use with numbers, and the behaviour you're seeing is normal. If you have a sheet worker calculating the field's value, why not get rid of the autocalc field and use the sheet worker to update it directly? Change the disabled tag to readonly , and this will stop players being able to edit it - only the sheet worker will be able to update it. Generally speaking, sheet workers and autocalc fields don't play well with each other, so if you have a sheet worker in any of the attributes that an attribute draws on, it's a good idea to change all relevant calculations to sheet workers.
That's great! I had no idea about the readonly tag - that makes my life SO much easier. Time to delete, like, 50 intermediate autocalc fields that I don't need any more. Side question: my console is FULL of warnings like this for a lot of my autocalc fields: "The specified value "@{ARCalc}" is not a valid number. The value must match to the following regular expression: -?(\d+|\d+\.\d+|\.\d+)([eE][-+]?\d+)?" It doesn't seem to actually stop things from working, but I'm curious as to what's causing it (I'd assume not consistently using parseInt?)