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

[HTML] Why doesn't this create an attribute on the Attributes section?

It calculates and enters it in the assign area on the sheet, but it doesn't create the needed Attribute. Can someone shed some light as to why or how I can get it to create the Attribute? Here is the line: <input type="text" name="attr_INTmod" value="floor((0.0009*@{Intellingence}*@{Intellingence}*@{Intellingence})+(-0.029*@{Intellingence}*@{Intellingence})+(0.6*@{Intellingence})+0.41)-4" disabled="true"/> I know if you remove the disabled="true" at the end, it won't calculate the formula. That's about all I know on it.
Autocalculated values are generated on the fly, and do not create final attributes. The value of the INTmod attribute is the formula itself. I highly recommend using sheet workers to do the math. That way, you will get attributes generated.
Thanks for the response. I don't know anything about sheet workers and have reached my limit of coding knowledge. One odd thing I found is that those values can't be referenced, but changing attrib_INTmod to attrib_Imod allows it. Can't use INT as part of a name, eh?
1521391416

Edited 1521391467
I am not sure what you mean by "can't be referenced." You can reference autocalc values sometimes by using double square brackets around them to execute the formula. For example, select a token tied to your sheet and type in the chat: [[ @{selected|INTmod} ]] and it should return the value. For stuff like this, sheetworkers are not that hard. I really gathered a lot from looking at other character sheet code and asking helpful folks here on the forums.
I looked at the sheet workers wiki. LOL. Not for me. Anyone care to take a stab at converting this into a sheet worker version?
Rabulias said: For example, select a token tied to your sheet and type in the chat: [[ @{selected|INTmod} ]] and it should return the value. [[ @{selected|INTmod} ]]  wouldn't work, but changing it to [[ @{selected|Imod} ]]  did. EDIT: There was a long standing syntax error that got adjusted and wouldn't let me call on it because it made the INTmod untrue
1521395820

Edited 1521405303
GiGs
Pro
Sheet Author
API Scripter
Sheet worker version: Is the typo in the attribute name Intellingence intended? It should be Intelligence. I've used your spelling for simplicity. Also, that is an interesting calculation. What is it meant to be calculating? Here's a sheet worker version: put this at the very end of your character sheet. //sections beginning with two slashes like these are COMMENTS, they are ignored by the script, and are here to explain you how the script works. <script type="text/worker"> // this tells the browser there are scripts coming. No matter how many scripts you have, you only have this line once. Put all scripts after this line and before the script ending line at the end. on("change:intellingence ", function() { //this sets up a watcher on the intellingence stat: whenever that stat changes, this script activates. Note: stats in change lines must always be lower case.     getAttrs(["Intellingence"], function(v) { // this line grabs the contents of the attribute, so that the script below can use it. Sheet workers dont automatically know what attributes are, so this is needed.                  let int = parseInt(v.Intellingence)||0); // this line converts the intellingence attribute into an integer. The ||0 at the end says "or 0", its basically saying if the attribute has a value it cant read, swap it to a zero. This helps avoid some common script errors.         let result = Math.floor((0.0009*int *int *int )+(-0.029*int*int)+(0.6*int)+0.41)-4; // here's your calculation. This is the simple part!         setAttrs({ // this function is needed to change attributes             "INTmod": result         }); // all these close brackets are confusing, but just remember to keep the right number in the right places.     }); // they match up with earlier open brackets, and are needed to ensure the script ends properly. }); </script>  // put all scripts before this line. IMPORTANT: change your attribute in the html to  <input type="text" name="attr_INTmod" value="0"/>
G G said: Sheet worker version: Is the typo in the attribute name Intellingence intended? It should be Intelligence. I've used your spelling for simplicity. Also, that is an interesting calculation. What is it meant to be calculating? This is all coding from the 1st version of the BECMI character sheet. I modified the look and layout, but didn't fiddle with any of the other things. I just looked at the sheet and it is spelled incorrectly on there as well. I edited the sheet. Crazy I have used this sheet for 3 years and never noticed that! BECMI had similar stat mods as D&D 3-5th editions, but at different increments. Wonky math needed to get that increment to auto calc. Thank you for the work. I might be able to understand more by studying this.
1521405798
GiGs
Pro
Sheet Author
API Scripter
I just noticed I had a typo in my code: the line "let result = " was wrong, I've corrected it. Having checked out that calculation, it looks like that is from a table, with 1 = -4, 2-3 = -3. 4-5 = -2, 6-8 = -1. 9-12 = 0, 13-15 = 1, 16-17 = 2, 18 = 3.  If that's the case you can avoid the wonky math by building the value in the sheetworker. The above code would become <script type="text/worker"> on("change:intellingence ", function() {     getAttrs(["Intellingence"], function(v) {                  let int = parseInt(v.Intellingence)||0);         let result = 0; if (int < 2) result = -4; else if (int < 4) result = -3; else if (int < 6) result = -2; else if (int < 9) result = -1; else if (int > 17) result = 3; else if (int > 15) result = 2; else if (int > 12) result = 1;         setAttrs({             "INTmod": result         });     }); }); </script>  // put all scripts before this line. This isnt as short as the version with the wonky math, but it's easier to follow, i think.
Even better!