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

Inconsistent Character Sheet Values

Hi, it seems like I can't get the correct attribute's value from a character sheet from an API.  If I use the following code directly in chat or in the character sheet's abilities I get "10" which is the correct value. @{John|level} //result: 10 But if I use it in an API call it returns "1" (which is the initial value for a new character sheet). I tried for other fields with the same results, I get 10 for "ac", 0 for "initiative" and so on. Which are all initial values and once again all of these work from chat or character sheet's abilities. sendChat('John', '@{John|level}'); //result: 1 Even more problematic is that if I use the same API with different character names in the same game it works... I've tried changing the name "John" for something else, still fails. I did a copy in the Character Vault and tried from a copy, fails again. Been trying to wrap my head around this for a while now, but I really don't see how to fix it. Thanks for any input
1701721748
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
I don't think the order of operations will allow that sort of construction in an API-generated message. You will probably have to use something like  getAttrByName(character.id, 'level') After having gotten the character object first, of course.
I guess that would be a way to do it. What bugs me is that it works for all the other character sheets in the same game. It fails on that single CS and I'm wondering why. For example, if I use : sendChat('John', '@{John|level}'); // John: 1 sendChat('Garvuk', '@{Garvuk|level}'); // Garvuk: 10 Both characters are level 10. And as stated before I get the correct results for John if I use it directly in chat or in the CS's abilities I really don't get why it bugs but only for that particular CS Thanks for your help
1701723398

Edited 1701723991
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Hm. That was just a guess without testing based on the results you reported. Sorry for any unnecessary confusion. Is there perhaps more than one character sheet in the game named "John"?
There isn't. Made sure of it from the get go. I will probably end up using your method but I don't like "skipping" a bug without knowing the underlying reason.
1701730072
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Here's a possibility. Change the value to something other than 10, and then change it back again.
Changed to 8. in Chat/CS abilities -> 8 /  API => 1 Back to 10. in Chat/CS abilities -> 10 /  API => 1 And yet doing the same for any other CS gives the right values. I remember the player having to refresh his browser a few times since his CS was showing as level 1. Refresh setting it back to level 10. Every time I checked the CS was showing as level 10 on my side. Feels like if the API is fetching from a different CS but there is none with "John" as a character name...
1701734502
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Maddening. Maybe a sheet author will chime in with better information.
1701734985
vÍnce
Pro
Sheet Author
Might look for the attribute in the attributes and abilities tab and delete it.  Also, make sure it isn't showing up more than once in the list as well.
Ding ding! Seems like many attributes have doubles, even triples. Any reason why attributes would be duplicated?
1701735624
vÍnce
Pro
Sheet Author
I've only experienced it when editing/creating sheets.  I suppose some API scripts or sheetworkers that generate attributes might be able to create duplicates attributes as well.  IDK
Well at least I know what to do to fix it. Thanks a lot guys