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

[Bug] Attribute is 'missing' for The One Ring sheet

1416182180

Edited 1416183284
Michael H
Sheet Author
I noticed a script of mine was failing sometimes. Upon debugging, I found that it was happening because one of the characters didn't have the 'total_fatigue' attribute, which is generated by the character sheet. I checked the list of attributes, and sure enough it isn't there. What's odd though, is that the character sheet itself stores the data just fine. As far as I can tell, this is the case with another attribute, and possibly more.
1416183247
Pat S.
Forum Champion
Sheet Author
Heilemann, this is more of a sheet issue and I will move this to that forum. If you can please edit the title to specify which sheet you are referring to.
Not sure how I edit the title? So I did some digging, and here's what's happening: The characters that have the missing attribute, probably have it left-over from before we had character sheets, because it's not being updated to the correct values anymore. The character sheet's attribute for this is a auto-calculated, and (sigh) those seemingly don't work with the API.
1416183945
Pat S.
Forum Champion
Sheet Author
which sheet, I can edit your title then we can dig into this more.
The One Ring.
1416184439
Pat S.
Forum Champion
Sheet Author
let me go pull from the github and peek at the code because it looks like the input is setup but there is no output for it.
1416187238
Pat S.
Forum Champion
Sheet Author
ok, now that my eyeballs stop spinning in opposite directions (I'm not a coder and it looked all alien to me), I have a question since it seems you are the author of the sheet. On line 1069 where the fatigue is calculated, did you want it to be disabled? <td colspan="2"><input type="number" name="attr_total_fatigue" value="@{encumbrance_fatigue}+@{travel_fatigue}" disabled="true" ></td> Would that be causing your problem?
1416187249

Edited 1416187562
Riley D.
Roll20 Team
Have you entered a value other than the default for the "total_fatigue" attribute? Basically, until a field is filled in with a value that isn't blank/zero and is different than the default value, nothing will show up via the API if you attempt to fetch the attribute directly. Auto-calculated values also aren't going to show up in the Attributes list in the Attributes/Abilities tab, and they aren't going to show up as regular "Attributes" in the API either. There's an API function that specifically you should use to prevent this, getAttrByName. This is all detailed on the Wiki: <a href="https://wiki.roll20.net/API:Objects#Working_with_C" rel="nofollow">https://wiki.roll20.net/API:Objects#Working_with_C</a>... If you're already using that function and you're still having the issue let me know.
I think maybe that was added after I first wrote this script, though I may be imagining that to cover for the fact that I didn't know about it. Either way, that does indeed get me one step further, by returning instead the 'value' of that attribute, which is the formula it contains ("@{encumbrance_fatigue}+@{travel_fatigue}". Any way for me to get the calculated value out of it? It's odd to me that these aren't real attributes. In essence I can have two total_fatigue in this case. The one on the sheet, and the one in the Attributes list. @Pat: Yes, that's on purpose (it's auto-calculated, you don't want players messing with it), and no I don't think it would interfere.
1416190010

Edited 1416190103
Pat S.
Forum Champion
Sheet Author
Heilemann said: I think maybe that was added after I first wrote this script, though I may be imagining that to cover for the fact that I didn't know about it. Either way, that does indeed get me one step further, by returning instead the 'value' of that attribute, which is the formula it contains ("@{encumbrance_fatigue}+@{travel_fatigue}". Any way for me to get the calculated value out of it? Would you be able to setup a default value for those fatigues ("@{encumbrance_fatigue|1}+@{travel_fatigue|1}" or where each of those fatigues are created first? Just asking if it was possible and if that would help.
Yeah, but if I understand it correctly, it still won't return the calculated value to the script. Riley, correct me if I'm wrong.
1416190234
Pat S.
Forum Champion
Sheet Author
Riley D. said: Have you entered a value other than the default for the "total_fatigue" attribute? Basically , until a field is filled in with a value that isn't blank/zero and is different than the default value, nothing will show up via the API if you attempt to fetch the attribute directly. Auto-calculated values also aren't going to show up in the Attributes list in the Attributes/Abilities tab, and they aren't going to show up as regular "Attributes" in the API either. I was just trying to figure out if you made the basic first fatigues default to .5 or 1 then when combined. would it show up for the API (just spitballing to see if the wind catches it)
I see that the topic is marked as resolved?
1416235321

Edited 1416235699
Riley D.
Roll20 Team
Any way for me to get the calculated value out of it? As is also detailed in that paragraph on the wiki: "Note that fields which have auto-calculated values will return the formula rather than the result of the value. You can then pass that formula to sendChat() to use the dice engine to calculate the result for you automatically." So you can use sendChat() either to actually perform a roll which is visible to everyone, or your can use the optional third argument to sendChat() to capture the result of the roll and then do something with it in your script. <a href="https://wiki.roll20.net/API:Chat#Chat_Functions" rel="nofollow">https://wiki.roll20.net/API:Chat#Chat_Functions</a> If you are going to use the third argument/callback function, the section above that one gives a comprehensive overview of the contents of the "ops" object and the dice results. It's odd to me that these aren't real attributes. In essence I can have two total_fatigue in this case. The one on the sheet, and the one in the Attributes list. As you mentioned in an earlier post, this is only because you already created the total_fatigue Attribute for that character before it existed on a Character Sheet. On any new characters that only use the sheet, it will never create that attribute from the sheet. Honestly I would delete the old attribute to prevent any confusion.
Heilemann said: I see that the topic is marked as resolved? Yes, because it is not actually a bug.
It'd be a great help if there was a way to get the value of the auto-calc field. Auto-calc attributes behave differently from all other attributes, which is a little hard to grok.